summaryrefslogtreecommitdiff
path: root/test/ruby/test_time.rb
AgeCommit message (Collapse)Author
2023-11-24[DOC] State timezone info in the string wins `in:` keywordNobuyoshi Nakada
2023-11-07Use embedded TypedData for Time objectsPeter Zhu
This drops the total size of a Time object from 86 bytes to 80 bytes. Running the benchmark benchmark/time_now.yml, this commit improves performance of Time.now by about 30%: ``` Time.now Branch: 13159405.4 i/s Master: 10036908.7 i/s - 1.31x slower Time.now(in: "+09:00") Branch: 2712172.6 i/s Master: 2138637.9 i/s - 1.27x slower ``` It also decreases memory usage by about 20%: ``` ary = 10_000_000.times.map { Time.now } puts `ps -o rss= -p #{$$}` ``` Branch: 961792 Master: 1196544 Co-Authored-By: Jean Boussier <byroot@ruby-lang.org>
2023-08-03Remove --disable-gems for assert_separatelyPeter Zhu
assert_separately adds --disable=gems so we don't need to add --disable-gems when calling assert_separately. Notes: Merged: https://github.com/ruby/ruby/pull/8162
2023-07-13Tighten Time.new(string) parsingJeremy Evans
Disallow: * Only year-month * Only year-month-day * Preceding whitespace * Trailing whitespace Fixes [Bug #19293] Notes: Merged: https://github.com/ruby/ruby/pull/7974
2023-04-04Fix crash in Time on 32-bit systemsPeter Zhu
[Bug #19575] struct vtm is packed causing it to have a size that is not aligned on 32-bit systems. When allocating it on the stack, it will have unaligned addresses which means that the fields won't be marked by the GC when scanning the stack (since the GC only marks aligned addresses). This can cause crashes when the fields are heap allocated objects like Bignums. This commit moves the flags in struct time_object into struct vtm for space efficiency and removes the need for packing. This is an example of a crash: ruby(rb_print_backtrace+0xd) [0x56848945] ../src/vm_dump.c:785 ruby(rb_vm_bugreport) ../src/vm_dump.c:1101 ruby(rb_assert_failure+0x7a) [0x56671857] ../src/error.c:878 ruby(vm_search_cc+0x0) [0x56666e47] ../src/vm_method.c:1366 ruby(rb_vm_search_method_slowpath) ../src/vm_insnhelper.c:2090 ruby(callable_method_entry+0x5) [0x568232d3] ../src/vm_method.c:1406 ruby(rb_callable_method_entry) ../src/vm_method.c:1413 ruby(gccct_method_search_slowpath) ../src/vm_eval.c:427 ruby(gccct_method_search+0x20f) [0x568237ef] ../src/vm_eval.c:476 ruby(opt_equality_by_mid_slowpath+0x2c) [0x5682388c] ../src/vm_insnhelper.c:2338 ruby(rb_equal+0x37) [0x566fe577] ../src/object.c:133 ruby(rb_big_eq+0x34) [0x56876ee4] ../src/bignum.c:5554 ruby(rb_int_equal+0x14) [0x566f3ed4] ../src/numeric.c:4640 ruby(rb_int_equal) ../src/numeric.c:4634 ruby(vm_call0_cfunc_with_frame+0x6d) [0x568303c2] ../src/vm_eval.c:148 ruby(vm_call0_cfunc) ../src/vm_eval.c:162 ruby(vm_call0_body) ../src/vm_eval.c:208 ruby(rb_funcallv_scope+0xd1) [0x56833971] ../src/vm_eval.c:85 ruby(RB_TEST+0x0) [0x567e8488] ../src/time.c:78 ruby(eq) ../src/time.c:78 ruby(small_vtm_sub) ../src/time.c:1523 ruby(timelocalw+0x23b) [0x567f3e9b] ../src/time.c:1593 ruby(time_s_alloc+0x0) [0x567f536b] ../src/time.c:3698 ruby(time_new_timew) ../src/time.c:2694 ruby(time_s_mktime) ../src/time.c:3698 Notes: Merged: https://github.com/ruby/ruby/pull/7650
2023-01-30bignum.c: rb_int_parse_cstr handle `0` stringsJean Boussier
[Bug #19390] We shouldn't check the string length when skipping zeros, as the string might only contains zero characters, resulting in an empty string. Notes: Merged: https://github.com/ruby/ruby/pull/7196
2023-01-02[Bug #19296] Precheck bits of time componentsNobuyoshi Nakada
2023-01-02Add missing assertionNobuyoshi Nakada
2023-01-01[Bug #19292] Re-initialize tm when wday or yday is not setNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7051
2022-12-16[Feature #18033] Parse more strictly conformant with ISO-8601Nobuyoshi Nakada
* 4-digits or more is required as year * Minutes and seconds parts are not ommittable Notes: Merged: https://github.com/ruby/ruby/pull/4825
2022-12-16[Feature #18033] Add `precision:` optionNobuyoshi Nakada
Which limits the precision of subsecond. Defaulted to 9, that means nanosecond. Notes: Merged: https://github.com/ruby/ruby/pull/4825
2022-12-16[Feature #18033] More strict checksNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4825
2022-12-16[Feature #18033] Make Time.new parse time stringsNobuyoshi Nakada
`Time.new` now parses strings such as the result of `Time#inspect` and restricted ISO-8601 formats. Notes: Merged: https://github.com/ruby/ruby/pull/4825
2022-11-22Add Time#deconstruct_keyszverok
Notes: Merged: https://github.com/ruby/ruby/pull/6594
2022-07-18[Bug #18922] Normalize time at 24:00:00 UTCNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6146 Merged-By: nobu <nobu@ruby-lang.org>
2022-02-02Decouple GC slot sizes from RVALUEPeter Zhu
Add a new macro BASE_SLOT_SIZE that determines the slot size. For Variable Width Allocation (compiled with USE_RVARGC=1), all slot sizes are powers-of-2 multiples of BASE_SLOT_SIZE. For USE_RVARGC=0, BASE_SLOT_SIZE is set to sizeof(RVALUE). Notes: Merged: https://github.com/ruby/ruby/pull/5517
2022-01-04Use omit instead of skip: test/ruby/**/*.rbHiroshi SHIBATA
2021-12-25Raise proper exception when month argument is not a nameNobuyoshi Nakada
https://bugs.ruby-lang.org/issues/17485#change-89871 Notes: Merged: https://github.com/ruby/ruby/pull/5344
2021-12-09Check month overflow when marshalNobuyoshi Nakada
https://hackerone.com/reports/1244185 Notes: Merged: https://github.com/ruby/ruby/pull/5238
2021-12-03Add tests of string argument to Time.atNobuyoshi Nakada
2021-11-17`Primitive.mandatory_only?` consider splat argsJean Boussier
`vm_ci_argc` gives the number of arguments, but `*[1, 2, 3]` only counts for one. Notes: Merged: https://github.com/ruby/ruby/pull/5124
2021-11-08[Feature #18290] Remove tests that test use of rb_gc_force_recyclePeter Zhu
Remove tests that assume objects get force recycled. Notes: Merged: https://github.com/ruby/ruby/pull/5096
2021-10-28Fix leap day with UTC offset [Bug #18274]Nobuyoshi Nakada
`struct vtm::year` is a Ruby integer instance, but not a C integer type. Notes: Merged: https://github.com/ruby/ruby/pull/5041
2021-09-11Use Test::Unit::Runner instead of MiniTest::UnitHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/4813
2021-09-11Use MiniTestHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/4813
2021-06-15Time#getlocal tests for [Feature #17544]Nobuyoshi Nakada
2021-02-16UTC zone should be still "+00:00" [Feature #17544]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4075
2021-02-16strftime.c: support unknown offset UTC in RFC 3339 [Feature #17544]Nobuyoshi Nakada
In RFC 3339, -00:00 is used for the time in UTC is known, but the offset to local time is unknown. Support that representation by `-` flag for `z`. Notes: Merged: https://github.com/ruby/ruby/pull/4075
2021-01-13Allow UTC offset without colons per ISO-8601 [Bug #17504]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4020
2021-01-12Convert time component strings to integers more strictlyNobuyoshi Nakada
https://bugs.ruby-lang.org/issues/17485#change-89871
2021-01-12Show seconds of utc_offset if not zeroNobuyoshi Nakada
2021-01-03Added tests for Time#getlocal with UTC offsetNobuyoshi Nakada
2020-12-17test/ruby: suppress some warningsYusuke Endoh
follow up to 9908177857a28633d6279c43a1ad4dfedcb98596
2020-12-17test/ruby: Check warning messages at a finer granularityNobuyoshi Nakada
Instead of suppressing all warnings wholly in each test scripts by setting `$VERBOSE` to `nil` in `setup` methods. Notes: Merged: https://github.com/ruby/ruby/pull/3925 Merged-By: nobu <nobu@ruby-lang.org>
2020-12-07Removed deprecated Time#succNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3841
2020-07-28Fix Time#ceil when result should be the same as the receiverJeremy Evans
Fixes [Bug #17025] Notes: Merged: https://github.com/ruby/ruby/pull/3362
2020-04-08Fixed formatted substring expansion [Bug #16767]Nobuyoshi Nakada
2020-02-20TestTime#test_memsize: skip when on GC_DEBUG卜部昌平
GC_DEBUG=1 makes this test fail because it changes the size of struct RVALUE. I don't think the test is useful then. Let's just skip.
2020-01-28support multi-run for test/ruby/test_time.rbKoichi Sasada
ruby/test_time_tz.rb (not sure only this file affects) changes TZ and it seems to change internal state. This internal state change fails test_2038 and test_timegm on 2nd time execution. At this time I have no idea how to fix this issue, so I skips these tests on 2nd trial. You can try this failure with the following command without this patch. $ make test-all TESTS='--repeat-count=2 ruby/require ruby/time ruby/time_tz'
2020-01-13Simplify obj2ubits checksJohn Hawthorn
If this value is less than zero, then the mask check is guaranteed to fail as well, so we might as well rely on that. Notes: Merged: https://github.com/ruby/ruby/pull/2808
2019-10-17Update test to handle x32 ABI compiled Ruby on LinuxJeremy Evans
Suggestion from Laurence Parry. Fixes [Bug #16030] Notes: Merged: https://github.com/ruby/ruby/pull/2572
2019-09-19Separate Time#inspect from to_s and show subsec [Feature #15958]NARUSE, Yui
2019-07-13Relaxed delta of nanosec from Float timeNobuyoshi Nakada
2019-06-19Marshal distant past/futureNobuyoshi Nakada
[Feature #15160]
2019-05-23Add `Time#ceil`.manga_osyo
Closes: https://github.com/ruby/ruby/pull/2133
2019-04-20Add `Time#floor`nobu
[Feature #15653] [Fix GH-2092] From: manga_osyo <manga.osyo@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-24time.c: zone in fixoff modenobu
* time.c (time_set_utc_offset): reset zone when setting to fixoff mode. while previously TZMODE_SET_FIXOFF has reset it always, the zone is kept for loaded zone since r65025. [ruby-core:90627] [Bug #15439] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-25Normalize month-mday before finding epochnaruse
Especially over the year 2038, 30 Feb and so on may cause odd behavior on validating found epoch with given year-month-day [Bug #15340] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30support theap for T_HASH. [Feature #14989]ko1
* hash.c, internal.h: support theap for small Hash. Introduce RHASH_ARRAY (li_table) besides st_table and small Hash (<=8 entries) are managed by an array data structure. This array data can be managed by theap. If st_table is needed, then converting array data to st_table data. For st_table using code, we prepare "stlike" APIs which accepts hash value and are very similar to st_ APIs. This work is based on the GSoC achievement by tacinight <tacingiht@gmail.com> and refined by ko1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-08test/ruby (*no_hidden_garbage): disable GC and skip if multi-threadednormal
Any single object allocation can reduce object count, and object counts are global, so multi-threading leads to unpredictable results. See also similar commits: r60699 and r62608 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e