aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_struct.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use Integer instead of Fixnum and Bignum.akr2016-05-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | * object.c, numeric.c, enum.c, ext/-test-/bignum/mul.c, lib/rexml/quickpath.rb, lib/rexml/text.rb, lib/rexml/xpath_parser.rb, lib/rubygems/specification.rb, lib/uri/generic.rb, bootstraptest/test_eval.rb, basictest/test.rb, test/-ext-/bignum/test_big2str.rb, test/-ext-/bignum/test_div.rb, test/-ext-/bignum/test_mul.rb, test/-ext-/bignum/test_str2big.rb, test/csv/test_data_converters.rb, test/date/test_date.rb, test/json/test_json_generate.rb, test/minitest/test_minitest_mock.rb, test/openssl/test_cipher.rb, test/rexml/test_jaxen.rb, test/ruby/test_array.rb, test/ruby/test_basicinstructions.rb, test/ruby/test_bignum.rb, test/ruby/test_case.rb, test/ruby/test_class.rb, test/ruby/test_complex.rb, test/ruby/test_enum.rb, test/ruby/test_eval.rb, test/ruby/test_iseq.rb, test/ruby/test_literal.rb, test/ruby/test_math.rb, test/ruby/test_module.rb, test/ruby/test_numeric.rb, test/ruby/test_range.rb, test/ruby/test_rational.rb, test/ruby/test_refinement.rb, test/ruby/test_rubyvm.rb, test/ruby/test_struct.rb, test/ruby/test_variable.rb, test/rubygems/test_gem_specification.rb, test/thread/test_queue.rb: Use Integer instead of Fixnum and Bignum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* struct.c: unique membersnobu2016-04-161-0/+7
| | | | | | | * struct.c (struct_make_members_list, rb_struct_s_def): member names should be unique. [ruby-core:74971] [Bug #12291] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add frozen_string_literal: false for all filesnaruse2015-12-161-0/+1
| | | | | | When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test_struct.rb: Test that initialize is overridable [#11708]marcandre2015-12-161-0/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* struct.c: dignobu2015-11-161-0/+7
| | | | | | | | * object.c (rb_obj_dig): dig in nested structs too. * struct.c (rb_struct_dig): new method Struct#dig. [Feature #11688] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* struct.c: fix index in messagenobu2015-11-161-4/+4
| | | | | | | | * struct.c (rb_struct_aref, rb_struct_aset): show the given index, not offset index, in the error messages when the offset is out of the range. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: struct accessorsnobu2014-12-161-0/+33
| | | | | | | | | | | * iseq.c (rb_method_for_self_aref, rb_method_for_self_aset): call accessor functions directly, not to be affected by [] and []= methods. [ruby-core:66846] [Bug #10601] * struct.c (define_aref_method, define_aset_method): ditto. * vm_insnhelper.c (rb_vm_opt_struct_aref, rb_vm_opt_struct_aset): direct accessors of Struct. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* struct: avoid all O(n) behavior on accessnormal2014-12-091-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This avoids O(n) on lookups with structs over 10 members. This also avoids O(n) behavior on all assignments on Struct members. Members 0..9 still use existing C methods to read in O(1) time Benchmark results: vm2_struct_big_aref_hi* 1.305 vm2_struct_big_aref_lo* 1.157 vm2_struct_big_aset* 3.306 vm2_struct_small_aref* 1.015 vm2_struct_small_aset* 3.273 Note: I chose use loading instructions from an array instead of writing directly to linked-lists in compile.c for ease-of-maintainability. We may move the method definitions to prelude.rb-like files in the future. I have also tested this patch with the following patch to disable the C ref_func methods and ensured the test suite and rubyspec works --- a/struct.c +++ b/struct.c @@ -209,7 +209,7 @@ setup_struct(VALUE nstr, VALUE members) ID id = SYM2ID(ptr_members[i]); VALUE off = LONG2NUM(i); - if (i < N_REF_FUNC) { + if (0 && i < N_REF_FUNC) { rb_define_method_id(nstr, id, ref_func[i], 0); } else { * iseq.c (rb_method_for_self_aref, rb_method_for_self_aset): new methods to generate bytecode for struct.c [Feature #10575] * struct.c (rb_struct_ref, rb_struct_set): remove (define_aref_method, define_aset_method): new functions (setup_struct): use new functions * test/ruby/test_struct.rb: add test for struct >10 members * benchmark/bm_vm2_struct_big_aref_hi.rb: new benchmark * benchmark/bm_vm2_struct_big_aref_lo.rb: ditto * benchmark/bm_vm2_struct_big_aset.rb: ditto * benchmark/bm_vm2_struct_small_aref.rb: ditto * benchmark/bm_vm2_struct_small_aset.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/lib/envutil.rb: Moved from test/ruby/.akr2014-11-131-1/+0
| | | | | | | | | | | | | | * test/lib/find_executable.rb: Ditto. * test/lib/memory_status.rb: Ditto. * test/lib/test/unit.rb: require envutil. * test/: Don't require envutil in test files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* struct.c: avoid pinning downnobu2014-03-281-0/+4
| | | | | | | | | | * struct.c (rb_struct_set, rb_struct_aref, rb_struct_aset): get rid of pinning down dynamic symbols by SYM2ID. * struct.c (rb_struct_aref_sym, rb_struct_aset_sym): use Symbol instead of ID. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: attrset from junk IDnobu2014-02-131-0/+4
| | | | | | | | * parse.y (IDSET_ATTRSET_FOR_INTERN): fix off-by-one bug. * parse.y (rb_enc_symname_type): junk ID succeeded by '=' is also attrset ID. [ruby-core:60668] [Bug #8756] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * struct.c (rb_struct_set): return assigned value from setter methodcharliesome2014-01-041-0/+6
| | | | | | | | rather than struct object. [Bug #9353] [ruby-core:59509] * test/ruby/test_struct.rb (test_setter_method_returns_value): add test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/ruby: better assertionsnobu2013-12-131-13/+13
| | | | | | * test/ruby: use better assertions instead of mere assert. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_struct.rb: use assert_samenobu2013-12-071-4/+6
| | | | | | | | | * test/ruby/test_struct.rb (test_question_mark_in_member): true value has no meanings itself. use assert_same instead. * test/ruby/test_struct.rb (test_bang_mark_in_member): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_struct.rb: use assert_predicatenobu2013-12-071-2/+2
| | | | | | | | | * test/ruby/test_struct.rb (test_question_mark_in_member): assert_true is a method in test-unit. use assert_predicate instead. * test/ruby/test_struct.rb (test_bang_mark_in_member): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_struct.rb: Add regression test for question marks andcharliesome2013-12-061-0/+12
| | | | | | bangs in struct members. [Closes GH-468] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* struct.c: fix warning messagenobu2013-10-271-43/+76
| | | | | | * struct.c (new_struct): fix warning message, class name and encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: non-local/const attrsetnobu2013-08-111-0/+8
| | | | | | | * parse.y (rb_enc_symname_type): allow ID_ATTRSET for ID_INSTANCE, ID_GLOBAL, ID_CLASS, ID_JUNK too. [Bug #8756] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: non-local/const attrsetnobu2013-08-101-0/+4
| | | | | | | | * parse.y (rb_id_attrset): allow other than ID_ATTRSET. * parse.y (intern_str): ditto. try stem ID for ID_INSTANCE, ID_GLOBAL, ID_CLASS, ID_JUNK too. [Bug #8756] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * safe.c (rb_set_safe_level, safe_setter): raise an ArgumentErrorshugo2013-06-121-24/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when $SAFE is set to 4. $SAFE=4 is now obsolete. [ruby-core:55222] [Feature #8468] * object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust): Kernel#untrusted?, untrust, and trust are now deprecated. Their behavior is same as tainted?, taint, and untaint, respectively. * include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED() and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(), respectively. * array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c, ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c, ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c, ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c, ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c, ext/socket/socket.c, ext/socket/udpsocket.c, ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c, ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c, load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c, safe.c, string.c, thread.c, transcode.c, variable.c, vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for $SAFE=4. * test/dl/test_dl2.rb, test/erb/test_erb.rb, test/readline/test_readline.rb, test/readline/test_readline_history.rb, test/ruby/test_alias.rb, test/ruby/test_array.rb, test/ruby/test_dir.rb, test/ruby/test_encoding.rb, test/ruby/test_env.rb, test/ruby/test_eval.rb, test/ruby/test_exception.rb, test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb, test/ruby/test_io.rb, test/ruby/test_method.rb, test/ruby/test_module.rb, test/ruby/test_object.rb, test/ruby/test_pack.rb, test/ruby/test_rand.rb, test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb, test/ruby/test_struct.rb, test/ruby/test_thread.rb, test/ruby/test_time.rb: remove tests for $SAFE=4. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * struct.c (make_struct): remove junk ID check to allow members whoglass2012-12-221-0/+7
| | | | | | | | have junk name like "foo\000". * test/ruby/test_struct.rb: Test for above. [Bug #7575] [ruby-dev:46750] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* struct.c: yield assoc in each_pairnobu2012-11-191-0/+5
| | | | | | | | * struct.c (rb_struct_each_pair): yield associated pairs so that an unsplat argument can get both, for consistency with Hash, OpenStruct, and etc. [ruby-dev:46533] [Bug #7382] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * hash.c, object.c, struct.c, lib/ostruct.rb: add to_h methods.nobu2012-04-241-0/+6
| | | | | | | [Feature #6276] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * error.c (rb_check_trusted): new function to check an object isnobu2011-07-171-0/+14
| | | | | | | | trusted. * struct.c (rb_struct_modify), time.c (time_modify): check by the above function to show proper class names. [Bug #5036] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_range.rb (TestRange#test_comparison_when_recursive):yugui2009-11-261-0/+30
| | | | | | | | | test for r25010. * test/ruby/test_struct.rb (TestStruct#test_comparison_when_recursive): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * class.c (rb_define_class_id_under, rb_define_module_id_under):nobu2009-08-121-0/+7
| | | | | | | | | | | | new functions to define a nested class/module with non-ascii name. * struct.c (make_struct): use name with encoding. * struct.c (inspect_struct): ditto. [ruby-core:24849] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_struct.rb (test_inspect): use assert_match.nobu2009-08-121-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bootstraptest/test_knownbug.rb: move solved tests.ko12008-05-191-0/+6
| | | | | | | | | | | * bootstraptest/test_eval.rb, test_literal.rb, test_syntax.rb, test_thread.rb: ditto. * test/ruby/test_m17n.rb, test_proc.rb, test_sprintf.rb, test_string.rb, test/ruby/test_struct.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bootstraptest/test_struct.rb: some test moved from test to shutmatz2008-03-131-1/+0
| | | | | | warning up. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_struct.rb: add tests to achieve over 90% testmame2008-01-231-0/+158
| | | | | | | | | coverage of struct.c. * test/ruby/test_sprintf.rb: ditto for sprintf.c. * test/ruby/test_math.rb: ditto for math.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test small structs.akr2006-02-051-0/+16
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * struct.c: accessing >10 member caused segmentation fault. [ruby-dev:26247]aamine2005-06-011-0/+12
| | | | | | | * test/ruby/test_struct.rb: test it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/*: should not depend on $KCODE.nahi2004-02-181-2/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/optparse.rb (OptionParser#order, #permute, #parse): allow annobu2003-09-051-11/+14
| | | | | | | | | | array as argument. * test/ruby/test_*.rb: moved invariants to left side in assert_equal, and use assert_nil, assert_raises and so on. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_*.rb: replace 'assert(a == b)' with assert_equal(a, b)'nahi2003-09-051-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby: tests for ruby itself.nahi2003-09-041-0/+23
* test/ruby/test_*.rb: split sample/test.rb into 28 test/unit testcases. some tests could not be translates... search '!!' mark to see it. * test/csv/test_csv.rb: should require 'csv', not '../lib/csv'. test runner should set load path correctly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e