From holmberg at rubyforge.org Thu Aug 11 08:07:43 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Thu Aug 11 08:07:45 2005 Subject: [Rubytests-commit] rubicon/builtin TestSymbol.rb Message-ID: <200508111207.j7BC7hcR020848@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv20354 Modified Files: TestSymbol.rb Log Message: Added tests of the trivial method Symbol#to_sym. Index: TestSymbol.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestSymbol.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestSymbol.rb 15 Feb 2004 18:59:51 -0000 1.3 --- TestSymbol.rb 11 Aug 2005 12:07:41 -0000 1.4 *************** *** 46,49 **** --- 46,55 ---- end + def test_to_sym + assert_equal(:Fred, :Fred.to_sym) + assert_equal(:Barney, :Barney.to_sym) + assert_equal(:wilma, :wilma.to_sym) + end + def test_type assert_equal(Symbol, :Fred.class) From holmberg at rubyforge.org Thu Aug 11 08:42:20 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Thu Aug 11 08:42:21 2005 Subject: [Rubytests-commit] rubicon/builtin TestSymbol.rb Message-ID: <200508111242.j7BCgKcR024939@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv24335 Modified Files: TestSymbol.rb Log Message: Added tests of Symbol#inspect. String#intern is used to create symbols with different "content" ( e.g. with spaces, and special characters like " and \ ). Index: TestSymbol.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestSymbol.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TestSymbol.rb 11 Aug 2005 12:07:41 -0000 1.4 --- TestSymbol.rb 11 Aug 2005 12:42:18 -0000 1.5 *************** *** 33,36 **** --- 33,43 ---- end + def test_inspect + assert_equal(':hello', 'hello'.intern.inspect) + assert_equal(':"hello world"', 'hello world'.intern.inspect) + assert_equal(':"with \" char"', 'with " char'.intern.inspect) + assert_equal(':"with \\\\ \" chars"', 'with \ " chars'.intern.inspect) + end + def test_to_i assert_equal($f1.to_i,$f2.to_i) From holmberg at rubyforge.org Thu Aug 11 08:56:29 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Thu Aug 11 08:56:30 2005 Subject: [Rubytests-commit] rubicon/builtin TestSymbol.rb Message-ID: <200508111256.j7BCuTcR026549@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv26477 Modified Files: TestSymbol.rb Log Message: Add tests of Symbol#===. Index: TestSymbol.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestSymbol.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TestSymbol.rb 11 Aug 2005 12:42:18 -0000 1.5 --- TestSymbol.rb 11 Aug 2005 12:56:27 -0000 1.6 *************** *** 27,30 **** --- 27,41 ---- end + def test_VERY_EQUAL # '===' + assert_equal(true, :Fred === :Fred) + assert_equal(false, :Fred === :Barney) + assert_equal(true, :Barney === :Barney) + + # don't match any non-Symbol + assert_equal(false, :Barney === ":Barney") + assert_equal(false, :Barney === "Barney") + assert_equal(false, :Barney === Object.new) + end + def test_id2name assert_equal("Fred",:Fred.id2name) From holmberg at rubyforge.org Mon Aug 15 01:34:29 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Mon Aug 15 01:34:31 2005 Subject: [Rubytests-commit] rubicon/builtin TestSymbol.rb Message-ID: <200508150534.j7F5YTcR029898@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv28829 Modified Files: TestSymbol.rb Log Message: Added basic tests of Symbol.all_symbols. Index: TestSymbol.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestSymbol.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TestSymbol.rb 11 Aug 2005 12:56:27 -0000 1.6 --- TestSymbol.rb 15 Aug 2005 05:34:27 -0000 1.7 *************** *** 27,30 **** --- 27,51 ---- end + @@unique_symbol_count = 0 + + def gen_unique_symbol + @@unique_symbol_count += 1 + eval ":rubicon_unique_symbol_#{@@unique_symbol_count}" + end + + def test_s_all_symbols + assert_instance_of(Array, Symbol.all_symbols) + Symbol.all_symbols.each do |sym| + assert_instance_of(Symbol, sym) + end + assert_equal(Symbol.all_symbols, Symbol.all_symbols.uniq) + + symbols1 = Symbol.all_symbols + s1 = gen_unique_symbol + s2 = gen_unique_symbol + symbols2 = Symbol.all_symbols + assert_bag_equal([s1, s2], symbols2 - symbols1) + end + def test_VERY_EQUAL # '===' assert_equal(true, :Fred === :Fred) From drbrain at segment7.net Mon Aug 15 02:12:24 2005 From: drbrain at segment7.net (Eric Hodel) Date: Mon Aug 15 02:06:22 2005 Subject: [Rubytests-commit] rubicon/builtin TestSymbol.rb In-Reply-To: <200508150534.j7F5YTcR029898@rubyforge.org> References: <200508150534.j7F5YTcR029898@rubyforge.org> Message-ID: <8A8C1B6F-9139-4FFD-99BC-B62FD4D91E6E@segment7.net> On 14 Aug 2005, at 22:34, holmberg@rubyforge.org wrote: > Update of /var/cvs/rubytests/rubicon/builtin > In directory rubyforge.org:/tmp/cvs-serv28829 > > Modified Files: > TestSymbol.rb > Log Message: > Added basic tests of Symbol.all_symbols. > > > Index: TestSymbol.rb > =================================================================== > RCS file: /var/cvs/rubytests/rubicon/builtin/TestSymbol.rb,v > retrieving revision 1.6 > retrieving revision 1.7 > diff -C2 -d -r1.6 -r1.7 > *** TestSymbol.rb 11 Aug 2005 12:56:27 -0000 1.6 > --- TestSymbol.rb 15 Aug 2005 05:34:27 -0000 1.7 > *************** > *** 27,30 **** > --- 27,51 ---- > end > > + @@unique_symbol_count = 0 > + > + def gen_unique_symbol > + @@unique_symbol_count += 1 > + eval ":rubicon_unique_symbol_#{@@unique_symbol_count}" Why is eval used? :"rubicon_unique_symbol_#{@@unique_symbol_count}" > + end -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 From holmberg at iar.se Tue Aug 16 08:16:34 2005 From: holmberg at iar.se (Johan Holmberg) Date: Tue Aug 16 08:10:31 2005 Subject: [Rubytests-commit] rubicon/builtin TestSymbol.rb In-Reply-To: <8A8C1B6F-9139-4FFD-99BC-B62FD4D91E6E@segment7.net> References: <200508150534.j7F5YTcR029898@rubyforge.org> <8A8C1B6F-9139-4FFD-99BC-B62FD4D91E6E@segment7.net> Message-ID: <4301D922.9080709@iar.se> Eric Hodel wrote: > On 14 Aug 2005, at 22:34, holmberg@rubyforge.org wrote: > >> + >> + def gen_unique_symbol >> + @@unique_symbol_count += 1 >> + eval ":rubicon_unique_symbol_#{@@unique_symbol_count}" > > > Why is eval used? > > :"rubicon_unique_symbol_#{@@unique_symbol_count}" > Yes, eval seems unnecessary. I don't know what I was thinking ... But I think I'll use "intern" instead: "rubicon_unique_symbol_#{@@unique_symbol_count}".intern The "literal syntax" with a string after ":" is a bit new in Ruby, and I prefer to be conservative when coding Rubicon. On the other hand the "literal syntax" may need a testcase of its own. I'll look around in the code, and add a testcase if there isn't any such test yet. Thanks for pointing out the eval-misuse, /Johan Holmberg From holmberg at rubyforge.org Tue Aug 16 08:12:33 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Tue Aug 16 08:12:34 2005 Subject: [Rubytests-commit] rubicon/builtin TestSymbol.rb Message-ID: <200508161212.j7GCCXcR004079@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv3726 Modified Files: TestSymbol.rb Log Message: Remove unncessary use of "eval". Use String#intern instead to create the new unique symbols needed in the test. Index: TestSymbol.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestSymbol.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TestSymbol.rb 15 Aug 2005 05:34:27 -0000 1.7 --- TestSymbol.rb 16 Aug 2005 12:12:31 -0000 1.8 *************** *** 31,35 **** def gen_unique_symbol @@unique_symbol_count += 1 ! eval ":rubicon_unique_symbol_#{@@unique_symbol_count}" end --- 31,35 ---- def gen_unique_symbol @@unique_symbol_count += 1 ! "rubicon_unique_symbol_#{@@unique_symbol_count}".intern end From drbrain at segment7.net Tue Aug 16 13:23:14 2005 From: drbrain at segment7.net (Eric Hodel) Date: Tue Aug 16 13:17:01 2005 Subject: [Rubytests-commit] rubicon/builtin TestSymbol.rb In-Reply-To: <4301D922.9080709@iar.se> References: <200508150534.j7F5YTcR029898@rubyforge.org> <8A8C1B6F-9139-4FFD-99BC-B62FD4D91E6E@segment7.net> <4301D922.9080709@iar.se> Message-ID: <3B2F5346-CD10-41B2-8929-987E7A28BB14@segment7.net> On 16 Aug 2005, at 05:16, Johan Holmberg wrote: > Eric Hodel wrote: > >> On 14 Aug 2005, at 22:34, holmberg@rubyforge.org wrote: >> >>> + >>> + def gen_unique_symbol >>> + @@unique_symbol_count += 1 >>> + eval ":rubicon_unique_symbol_#{@@unique_symbol_count}" >>> >> Why is eval used? >> :"rubicon_unique_symbol_#{@@unique_symbol_count}" >> > > Yes, eval seems unnecessary. I don't know what I was thinking ... > > But I think I'll use "intern" instead: > > "rubicon_unique_symbol_#{@@unique_symbol_count}".intern > > The "literal syntax" with a string after ":" is a bit new in Ruby, > and I prefer to be conservative when coding Rubicon. You added this code to test Symbol.all_symbols, so that's not a valid reason. $ ./miniruby -ve 'p Symbol.all_symbols' ruby 1.6.8 (2003-10-15) [powerpc-darwin8.2.0] -e:1: undefined method `all_symbols' for Symbol:Class (NameError) -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 From holmberg at rubyforge.org Thu Aug 25 16:57:30 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Thu Aug 25 16:57:31 2005 Subject: [Rubytests-commit] rubicon/builtin TestString.rb Message-ID: <200508252057.j7PKvUcR013856@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv13682 Modified Files: TestString.rb Log Message: Restore the possibility to easily test "TestString.rb" alone, with a command like "ruby TestString.rb". Index: TestString.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestString.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TestString.rb 18 Jul 2005 16:21:08 -0000 1.7 --- TestString.rb 25 Aug 2005 20:57:28 -0000 1.8 *************** *** 1440,1442 **** end ! # Rubicon::handleTests(TestString) if $0 == __FILE__ --- 1440,1442 ---- end ! Rubicon::handleTests(TestString) if $0 == __FILE__ From holmberg at rubyforge.org Thu Aug 25 17:53:41 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Thu Aug 25 17:53:43 2005 Subject: [Rubytests-commit] rubicon/builtin TestString.rb Message-ID: <200508252153.j7PLrfcR021518@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv20646 Modified Files: TestString.rb Log Message: Added a test for String#scan with a regexp argument that may match an empty string. This has not been tested earlier. Also modified the S() utility method, so it now accepts either a String or *an array of Strings*. The array-case makes the test added to "test_scan" easier to read, and seems to be in line with the purpose of the S() method: to do the conversion String --> @cls, without cluttering the testcase code too much. Example of what the S() change leads to: before: [ S("foo"), S(""), S(""), S("bar"), ... ] after: S( ["foo", "", "", "bar",...] ) Index: TestString.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestString.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TestString.rb 25 Aug 2005 20:57:28 -0000 1.8 --- TestString.rb 25 Aug 2005 21:53:39 -0000 1.9 *************** *** 36,41 **** end ! def S(str) ! @cls.new(str) end --- 36,45 ---- end ! def S(str_or_array) ! if str_or_array.instance_of?(Array) ! str_or_array.map {|str| @cls.new(str) } ! else ! @cls.new(str_or_array) ! end end *************** *** 935,938 **** --- 939,946 ---- a.scan(/(...)/) { |w| res << w } assert_equal([[S("cru")], [S("el ")], [S("wor")]],res) + + # with a pattern that match empty string + assert_equal(S(["", "", "1", "", "", "22", "", "", "333", ""]), + S("aa1bb22cc333").scan(/\d*/)) end From holmberg at rubyforge.org Thu Aug 25 18:01:32 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Thu Aug 25 18:01:34 2005 Subject: [Rubytests-commit] rubicon/builtin TestString.rb Message-ID: <200508252201.j7PM1WcR024951@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv21766 Modified Files: TestString.rb Log Message: Added comments in the code explaining the use of the variable @cls and and the utility method S(). Short summary: it makes it possible to test other "stringlike" classes using the same test-code as now. This possibility has not been used yet, and will probably require some further reorganization of the code. Index: TestString.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestString.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TestString.rb 25 Aug 2005 21:53:39 -0000 1.9 --- TestString.rb 25 Aug 2005 22:01:30 -0000 1.10 *************** *** 3,6 **** --- 3,25 ---- require 'rubicon' + # + # The tests in this file are written in terms of "stringlike" objects + # instead of using the class "String" directly. The purpose of this is + # to make it possible to test other stringlike classes too (a simple + # example would be to test a subclass of "String", i.e. how the + # String-class behaves when sub-classed). + # + # This flexibility has not been used yet, but will soon ... + # + # It is implemented by having the member variable @cls initialized to + # the stringlike class we want to test. The S() utility method (used + # "everywhere" in this file) converts String objects to stringlike + # objects of the class @cls. + # + # This file will probably need to splitted again when another class + # is tested too. Something like "TestString.rb", "TestStringSubclass.rb" + # and "StringBase.rb". + # + # use of $= is deprecated after 1.7.1 def pre_1_7_1 *************** *** 36,39 **** --- 55,62 ---- end + # The "S" method converts String objects into objects of the + # stringlike class given in the variable @cls. The parameter to + # "S" may be either a single String, or an array of Strings. + # def S(str_or_array) if str_or_array.instance_of?(Array) From drbrain at segment7.net Thu Aug 25 18:14:56 2005 From: drbrain at segment7.net (Eric Hodel) Date: Thu Aug 25 18:08:24 2005 Subject: [Rubytests-commit] rubicon/builtin TestString.rb In-Reply-To: <200508252153.j7PLrfcR021518@rubyforge.org> References: <200508252153.j7PLrfcR021518@rubyforge.org> Message-ID: <8CEDAA0B-09A2-4E9B-8079-6D23BDEE6A6A@segment7.net> On 25 Aug 2005, at 14:53, holmberg@rubyforge.org wrote: > Update of /var/cvs/rubytests/rubicon/builtin > In directory rubyforge.org:/tmp/cvs-serv20646 > > Modified Files: > TestString.rb > Log Message: > Added a test for String#scan with a regexp argument that may match > an empty string. This has not been tested earlier. > > Also modified the S() utility method, so it now accepts either > a String or *an array of Strings*. The array-case makes the test > added to "test_scan" easier to read, and seems to be in line with > the purpose of the S() method: to do the conversion String --> @cls, > without cluttering the testcase code too much. > > Example of what the S() change leads to: > > before: [ S("foo"), S(""), S(""), S("bar"), ... ] > > after: S( ["foo", "", "", "bar",...] ) I don't understand why S() was modified for just one assertion in just one test. Feels like overkill. -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 From holmberg at rubyforge.org Thu Aug 25 19:24:26 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Thu Aug 25 19:24:29 2005 Subject: [Rubytests-commit] rubicon/builtin TestEnumerable.rb Message-ID: <200508252324.j7PNOQcR001625@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv1436 Modified Files: TestEnumerable.rb Log Message: Modified "generic_test_detect" to test the methods #detect and #find with the optional proc argument too. Index: TestEnumerable.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestEnumerable.rb,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** TestEnumerable.rb 4 Jul 2005 15:14:11 -0000 1.18 --- TestEnumerable.rb 25 Aug 2005 23:24:24 -0000 1.19 *************** *** 96,105 **** # that tests both methods ! assert_equal(nil, E().send(method) {|a| true }) ! assert_equal(nil, @a.send(method) {|a| false }) ! assert_equal(2, @a.send(method) {|a| a > 1 }) ! assert_equal(6, @a.send(method) {|a| a > 5 }) ! assert_equal(10, @a.send(method) {|a| a > 9 }) ! assert_equal(nil, @a.send(method) {|a| a > 10 }) end --- 96,128 ---- # that tests both methods ! # Test with and without a proc argument. With such an argument ! # the proc is called if no match is found, and the value returned ! # from the proc is returned instead of nil. ! fail_count = 0 ! fail_proc = lambda { fail_count += 1 ; "not found" } ! fail_proc_value = fail_proc.call ! ! for args, fail_value in [ ! [ [], nil ], ! [ [fail_proc], fail_proc_value ], ! ] ! ! assert_equal(fail_value, E().send(method, *args) {|a| true }) ! assert_equal(fail_value, @a.send(method, *args) {|a| false }) ! assert_equal(2, @a.send(method, *args) {|a| a > 1 }) ! assert_equal(6, @a.send(method, *args) {|a| a > 5 }) ! assert_equal(10, @a.send(method, *args) {|a| a > 9 }) ! assert_equal(fail_value, @a.send(method, *args) {|a| a > 10 }) ! end ! ! # Make sure that the "proc" is only called once, and only if no ! # match is found. ! fail_count = 0 ! assert_equal(fail_proc_value, @a.send(method, fail_proc) {|a| false }) ! assert_equal(1, fail_count) ! ! fail_count = 0 ! assert_equal(2, @a.send(method, fail_proc) {|a| true }) ! assert_equal(0, fail_count) end From holmberg at rubyforge.org Thu Aug 25 19:58:43 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Thu Aug 25 19:58:44 2005 Subject: [Rubytests-commit] rubicon/language TestAccessControl.rb TestEval.rb TestFloats.rb TestMethods.rb TestPredefinedVariables.rb Message-ID: <200508252358.j7PNwhcR004961@rubyforge.org> Update of /var/cvs/rubytests/rubicon/language In directory rubyforge.org:/tmp/cvs-serv4274/language Modified Files: TestAccessControl.rb TestEval.rb TestFloats.rb TestMethods.rb TestPredefinedVariables.rb Log Message: Changed all uses of "assert_raises" to use "assert_raise" instead. The documentation of Test::Unit says the following about "assert_raises": Alias of assert_raise. Will be deprecated in 1.9, and removed in 2.0. There were 80 calls to "assert_raises" and 86 to "assert_raise". Now we have 0 vs. 166. Index: TestPredefinedVariables.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/language/TestPredefinedVariables.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestPredefinedVariables.rb 15 Feb 2004 13:54:08 -0000 1.2 --- TestPredefinedVariables.rb 25 Aug 2005 23:58:41 -0000 1.3 *************** *** 8,12 **** def testVariables assert_instance_of(Fixnum, $$) ! assert_raises(NameError) { $$ = 1 } foobar = "foobar" --- 8,12 ---- def testVariables assert_instance_of(Fixnum, $$) ! assert_raise(NameError) { $$ = 1 } foobar = "foobar" Index: TestEval.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/language/TestEval.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestEval.rb 15 Feb 2004 13:58:12 -0000 1.2 --- TestEval.rb 25 Aug 2005 23:58:41 -0000 1.3 *************** *** 46,50 **** def testEvalNameError ! assert_raises(NameError) { eval("local1") } end --- 46,50 ---- def testEvalNameError ! assert_raise(NameError) { eval("local1") } end *************** *** 64,68 **** assert_equal(25, eval("EVTEST1", EvTest::BINDING)) # constant in module assert_equal(125, eval("evtest2", EvTest::BINDING)) # local var in module ! assert_raises(NameError) { eval("EVTEST1") } end --- 64,68 ---- assert_equal(25, eval("EVTEST1", EvTest::BINDING)) # constant in module assert_equal(125, eval("evtest2", EvTest::BINDING)) # local var in module ! assert_raise(NameError) { eval("EVTEST1") } end Index: TestFloats.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/language/TestFloats.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestFloats.rb 15 Feb 2004 13:58:12 -0000 1.2 --- TestFloats.rb 25 Aug 2005 23:58:41 -0000 1.3 *************** *** 42,46 **** "2.1E+", ] ! assert_raises(SyntaxError, "case #{malformed}") do eval malformed end --- 42,46 ---- "2.1E+", ] ! assert_raise(SyntaxError, "case #{malformed}") do eval malformed end Index: TestMethods.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/language/TestMethods.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestMethods.rb 15 Feb 2004 13:52:50 -0000 1.2 --- TestMethods.rb 25 Aug 2005 23:58:41 -0000 1.3 *************** *** 11,16 **** def testNotEnoughArguments ! assert_raises(ArgumentError) { aaa() } ! assert_raises(ArgumentError) { aaa } end --- 11,16 ---- def testNotEnoughArguments ! assert_raise(ArgumentError) { aaa() } ! assert_raise(ArgumentError) { aaa } end Index: TestAccessControl.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/language/TestAccessControl.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestAccessControl.rb 15 Feb 2004 13:58:12 -0000 1.2 --- TestAccessControl.rb 25 Aug 2005 23:58:41 -0000 1.3 *************** *** 100,105 **** # access via subclass c2 = C2.new ! assert_raises(ExpectedException) { c2.c1private } ! assert_raises(ExpectedException) { c2.c1protected } assert_equal(3, c2.c1public) assert_equal(1, c2.c2private) --- 100,105 ---- # access via subclass c2 = C2.new ! assert_raise(ExpectedException) { c2.c1private } ! assert_raise(ExpectedException) { c2.c1protected } assert_equal(3, c2.c1public) assert_equal(1, c2.c2private) *************** *** 109,113 **** # access via subclass with explicit 'self' c3 = C3.new ! assert_raises(ExpectedException) { c3.c3private } assert_equal(2, c3.c3protected) assert_equal(3, c3.c3public) --- 109,113 ---- # access via subclass with explicit 'self' c3 = C3.new ! assert_raise(ExpectedException) { c3.c3private } assert_equal(2, c3.c3protected) assert_equal(3, c3.c3public) *************** *** 118,123 **** def test_included_module c4 = C4.new ! assert_raises(ExpectedException) { c4.m1private } ! assert_raises(ExpectedException) { c4.m1protected } assert_equal(3, c4.m1public) end --- 118,123 ---- def test_included_module c4 = C4.new ! assert_raise(ExpectedException) { c4.m1private } ! assert_raise(ExpectedException) { c4.m1protected } assert_equal(3, c4.m1public) end *************** *** 130,136 **** assert_equal(3, M2.m2public) c5 = C5.new ! assert_raises(ExpectedException) { c5.m2private } ! assert_raises(ExpectedException) { c5.m2protected } ! assert_raises(ExpectedException) { c5.m2public } end end --- 130,136 ---- assert_equal(3, M2.m2public) c5 = C5.new ! assert_raise(ExpectedException) { c5.m2private } ! assert_raise(ExpectedException) { c5.m2protected } ! assert_raise(ExpectedException) { c5.m2public } end end From holmberg at rubyforge.org Thu Aug 25 19:58:43 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Thu Aug 25 19:58:45 2005 Subject: [Rubytests-commit] rubicon/builtin TestArray.rb TestDir.rb TestEnumerable.rb TestObject.rb TestString.rb TestTime.rb Message-ID: <200508252358.j7PNwhcR004954@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv4274/builtin Modified Files: TestArray.rb TestDir.rb TestEnumerable.rb TestObject.rb TestString.rb TestTime.rb Log Message: Changed all uses of "assert_raises" to use "assert_raise" instead. The documentation of Test::Unit says the following about "assert_raises": Alias of assert_raise. Will be deprecated in 1.9, and removed in 2.0. There were 80 calls to "assert_raises" and 86 to "assert_raise". Now we have 0 vs. 166. Index: TestTime.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestTime.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TestTime.rb 18 Jul 2005 16:34:44 -0000 1.12 --- TestTime.rb 25 Aug 2005 23:58:41 -0000 1.13 *************** *** 191,201 **** def test_class_gm ! assert_raises(ArgumentError) { Time.gm } assert_not_equal(Time.gm(2000), Time.local(2000)) assert_equal(Time.gm(2000), Time.gm(2000,1,1,0,0,0)) assert_equal(Time.gm(2000,nil,nil,nil,nil,nil), Time.gm(2000,1,1,0,0,0)) ! assert_raises(ArgumentError) { Time.gm(2000,0) } ! assert_raises(ArgumentError) { Time.gm(2000,13) } ! assert_raises(ArgumentError) { Time.gm(2000,1,1,24) } Time.gm(2000,1,1,23) @@months.each do |month, num| --- 191,201 ---- def test_class_gm ! assert_raise(ArgumentError) { Time.gm } assert_not_equal(Time.gm(2000), Time.local(2000)) assert_equal(Time.gm(2000), Time.gm(2000,1,1,0,0,0)) assert_equal(Time.gm(2000,nil,nil,nil,nil,nil), Time.gm(2000,1,1,0,0,0)) ! assert_raise(ArgumentError) { Time.gm(2000,0) } ! assert_raise(ArgumentError) { Time.gm(2000,13) } ! assert_raise(ArgumentError) { Time.gm(2000,1,1,24) } Time.gm(2000,1,1,23) @@months.each do |month, num| *************** *** 210,220 **** def test_class_local ! assert_raises(ArgumentError) { Time.local } assert_not_equal(Time.gm(2000), Time.local(2000)) assert_equal(Time.local(2000), Time.local(2000,1,1,0,0,0)) assert_equal(Time.local(2000,nil,nil,nil,nil,nil), Time.local(2000,1,1,0,0,0)) ! assert_raises(ArgumentError) { Time.local(2000,0) } ! assert_raises(ArgumentError) { Time.local(2000,13) } ! assert_raises(ArgumentError) { Time.local(2000,1,1,24) } Time.local(2000,1,1,23) @@months.each do |month, num| --- 210,220 ---- def test_class_local ! assert_raise(ArgumentError) { Time.local } assert_not_equal(Time.gm(2000), Time.local(2000)) assert_equal(Time.local(2000), Time.local(2000,1,1,0,0,0)) assert_equal(Time.local(2000,nil,nil,nil,nil,nil), Time.local(2000,1,1,0,0,0)) ! assert_raise(ArgumentError) { Time.local(2000,0) } ! assert_raise(ArgumentError) { Time.local(2000,13) } ! assert_raise(ArgumentError) { Time.local(2000,1,1,24) } Time.local(2000,1,1,23) @@months.each do |month, num| *************** *** 232,242 **** # Test insufficient arguments # ! assert_raises(ArgumentError) { Time.mktime } assert_not_equal(Time.gm(2000), Time.mktime(2000)) assert_equal(Time.mktime(2000), Time.mktime(2000,1,1,0,0,0)) assert_equal(Time.mktime(2000,nil,nil,nil,nil,nil), Time.mktime(2000,1,1,0,0,0)) ! assert_raises(ArgumentError) { Time.mktime(2000,0) } ! assert_raises(ArgumentError) { Time.mktime(2000,13) } ! assert_raises(ArgumentError) { Time.mktime(2000,1,1,24) } Time.mktime(2000,1,1,23) --- 232,242 ---- # Test insufficient arguments # ! assert_raise(ArgumentError) { Time.mktime } assert_not_equal(Time.gm(2000), Time.mktime(2000)) assert_equal(Time.mktime(2000), Time.mktime(2000,1,1,0,0,0)) assert_equal(Time.mktime(2000,nil,nil,nil,nil,nil), Time.mktime(2000,1,1,0,0,0)) ! assert_raise(ArgumentError) { Time.mktime(2000,0) } ! assert_raise(ArgumentError) { Time.mktime(2000,13) } ! assert_raise(ArgumentError) { Time.mktime(2000,1,1,24) } Time.mktime(2000,1,1,23) Index: TestObject.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestObject.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestObject.rb 22 Nov 2004 17:06:38 -0000 1.3 --- TestObject.rb 25 Aug 2005 23:58:41 -0000 1.4 *************** *** 17,22 **** @test_class.var1 = "d" assert_equal("d", @test_class.instance_variable_get(:@var1)) ! assert_raises(NameError) { @test_class.instance_variable_get("var1") } ! assert_raises(NameError) { @test_class.instance_variable_get(:var1) } assert_nil(@test_class.instance_variable_get(:@var2)) end --- 17,22 ---- @test_class.var1 = "d" assert_equal("d", @test_class.instance_variable_get(:@var1)) ! assert_raise(NameError) { @test_class.instance_variable_get("var1") } ! assert_raise(NameError) { @test_class.instance_variable_get(:var1) } assert_nil(@test_class.instance_variable_get(:@var2)) end *************** *** 27,32 **** assert_equal("b", @test_class.instance_variable_set(:@var1, "b")) assert_equal("b", @test_class.var1) ! assert_raises(NameError) { @test_class.instance_variable_set("var1", "x") } ! assert_raises(NameError) { @test_class.instance_variable_set(:var1, "x") } end end --- 27,32 ---- assert_equal("b", @test_class.instance_variable_set(:@var1, "b")) assert_equal("b", @test_class.var1) ! assert_raise(NameError) { @test_class.instance_variable_set("var1", "x") } ! assert_raise(NameError) { @test_class.instance_variable_set(:var1, "x") } end end Index: TestEnumerable.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestEnumerable.rb,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** TestEnumerable.rb 25 Aug 2005 23:24:24 -0000 1.19 --- TestEnumerable.rb 25 Aug 2005 23:58:41 -0000 1.20 *************** *** 226,230 **** # error cases assert_equal(nil, E().inject {|acc,x| 999 } ) ! e = assert_raises(TypeError) do E(4.2, "NO", 0).inject{|r, i| r*i} end --- 226,230 ---- # error cases assert_equal(nil, E().inject {|acc,x| 999 } ) ! e = assert_raise(TypeError) do E(4.2, "NO", 0).inject{|r, i| r*i} end *************** *** 259,268 **** # error cases assert_equal(nil, E().max) ! assert_raises(NoMethodError) { E(Object.new, Object.new).max } Version.less_than("1.8.3") do ! assert_raises(NoMethodError) { E(11,"22").max } end Version.greater_or_equal("1.8.3") do ! assert_raises(ArgumentError) { E(11,"22").max } end --- 259,268 ---- # error cases assert_equal(nil, E().max) ! assert_raise(NoMethodError) { E(Object.new, Object.new).max } Version.less_than("1.8.3") do ! assert_raise(NoMethodError) { E(11,"22").max } end Version.greater_or_equal("1.8.3") do ! assert_raise(ArgumentError) { E(11,"22").max } end *************** *** 309,318 **** # error cases assert_equal(nil, E().min) ! assert_raises(NoMethodError) { E(Object.new, Object.new).min } Version.less_than("1.8.3") do ! assert_raises(NoMethodError) { E(11,"22").min } end Version.greater_or_equal("1.8.3") do ! assert_raises(ArgumentError) { E(11,"22").min } end --- 309,318 ---- # error cases assert_equal(nil, E().min) ! assert_raise(NoMethodError) { E(Object.new, Object.new).min } Version.less_than("1.8.3") do ! assert_raise(NoMethodError) { E(11,"22").min } end Version.greater_or_equal("1.8.3") do ! assert_raise(ArgumentError) { E(11,"22").min } end Index: TestArray.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestArray.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestArray.rb 18 Jul 2005 16:24:38 -0000 1.3 --- TestArray.rb 25 Aug 2005 23:58:41 -0000 1.4 *************** *** 63,67 **** # error cases ! assert_raises(ArgumentError) { @cls.new(-10) } end --- 63,67 ---- # error cases ! assert_raise(ArgumentError) { @cls.new(-10) } end *************** *** 102,106 **** # error case ! assert_raises(TypeError) { @cls[ 1, 1, 3, 5 ] & Object.new } end --- 102,106 ---- # error case ! assert_raise(TypeError) { @cls[ 1, 1, 3, 5 ] & Object.new } end *************** *** 110,115 **** assert_equal(@cls[1, 2, 1, 2, 1, 2], @cls[1, 2]*3) assert_equal(@cls[], @cls[1, 2, 3] * 0) ! assert_raises(ArgumentError) { @cls[1, 2]*(-3) } ! assert_raises(TypeError) { @cls[1, 2]*(Object.new) } assert_equal('1-2-3-4-5', @cls[1, 2, 3, 4, 5] * '-') --- 110,115 ---- assert_equal(@cls[1, 2, 1, 2, 1, 2], @cls[1, 2]*3) assert_equal(@cls[], @cls[1, 2, 3] * 0) ! assert_raise(ArgumentError) { @cls[1, 2]*(-3) } ! assert_raise(TypeError) { @cls[1, 2]*(Object.new) } assert_equal('1-2-3-4-5', @cls[1, 2, 3, 4, 5] * '-') *************** *** 186,190 **** a = @cls[1,2,3] a.push(a) ! assert_raises(SystemStackError) { a <=> a } end --- 186,190 ---- a = @cls[1,2,3] a.push(a) ! assert_raise(SystemStackError) { a <=> a } end *************** *** 293,297 **** end ! assert_raises(TypeError) {a['cat']} end --- 293,297 ---- end ! assert_raise(TypeError) {a['cat']} end *************** *** 438,442 **** assert_equal(0, a.at(-100)) assert_equal(nil, a.at(-101)) ! assert_raises(TypeError) { a.at('cat') } end --- 438,442 ---- assert_equal(0, a.at(-100)) assert_equal(nil, a.at(-101)) ! assert_raise(TypeError) { a.at('cat') } end *************** *** 668,672 **** assert_equal('a', a.fetch(0)) assert_equal('c', a.fetch(2)) ! assert_raises(IndexError) { a.fetch(4) } assert_equal(8, a.fetch(4) {|k| k*2} ) assert_equal('default', a.fetch(4, 'default')) --- 668,672 ---- assert_equal('a', a.fetch(0)) assert_equal('c', a.fetch(2)) ! assert_raise(IndexError) { a.fetch(4) } assert_equal(8, a.fetch(4) {|k| k*2} ) assert_equal('default', a.fetch(4, 'default')) *************** *** 674,678 **** assert_equal('d', a.fetch(-1)) assert_equal('b', a.fetch(-3)) ! assert_raises(IndexError) { a.fetch(-5) } assert_equal(-10, a.fetch(-5) {|k| k*2} ) assert_equal('default', a.fetch(-5, 'default')) --- 674,678 ---- assert_equal('d', a.fetch(-1)) assert_equal('b', a.fetch(-3)) ! assert_raise(IndexError) { a.fetch(-5) } assert_equal(-10, a.fetch(-5) {|k| k*2} ) assert_equal('default', a.fetch(-5, 'default')) *************** *** 724,729 **** # error cases ! assert_raises(ArgumentError) { @cls[3,4,5].first(-1) } ! assert_raises(TypeError) { @cls[3,4,5].first(Object.new) } end --- 724,729 ---- # error cases ! assert_raise(ArgumentError) { @cls[3,4,5].first(-1) } ! assert_raise(TypeError) { @cls[3,4,5].first(Object.new) } end *************** *** 821,825 **** assert_equal(%w(a b x y z w c), x.insert(-2, 'y', 'z', 'w')) assert_equal(%w(a b x y z w c) + [nil, nil] + %w(Q), x.insert(9, 'Q')) ! assert_raises(IndexError) { x.insert(-12, 'Z') } end end --- 821,825 ---- assert_equal(%w(a b x y z w c), x.insert(-2, 'y', 'z', 'w')) assert_equal(%w(a b x y z w c) + [nil, nil] + %w(Q), x.insert(9, 'Q')) ! assert_raise(IndexError) { x.insert(-12, 'Z') } end end *************** *** 864,869 **** # error cases ! assert_raises(ArgumentError) { @cls[3,4,5].last(-1) } ! assert_raises(TypeError) { @cls[3,4,5].last(Object.new) } # misc --- 864,869 ---- # error cases ! assert_raise(ArgumentError) { @cls[3,4,5].last(-1) } ! assert_raise(TypeError) { @cls[3,4,5].last(Object.new) } # misc *************** *** 1151,1155 **** assert_equal(ary, ary.transpose.transpose) # the following happens in case of malformed data ! e = assert_raises(IndexError) { [%w(a b c), %w(d)].transpose } assert_match(/1 should be 3/, e.message) end --- 1151,1155 ---- assert_equal(ary, ary.transpose.transpose) # the following happens in case of malformed data ! e = assert_raise(IndexError) { [%w(a b c), %w(d)].transpose } assert_match(/1 should be 3/, e.message) end *************** *** 1193,1200 **** assert_equal(%w(b), %w(a b c d e).values_at(1.8)) # float as index assert_equal(%w(b c d), %w(a b c d e).values_at(1..3)) ! assert_raises(TypeError) { %w(a b c).values_at(nil) } ! assert_raises(TypeError) { %w(a b c).values_at("x") } ! assert_raises(TypeError) { %w(a b c).values_at([]) } ! assert_raises(TypeError) { %w(a b c).values_at(true) } end end --- 1193,1200 ---- assert_equal(%w(b), %w(a b c d e).values_at(1.8)) # float as index assert_equal(%w(b c d), %w(a b c d e).values_at(1..3)) ! assert_raise(TypeError) { %w(a b c).values_at(nil) } ! assert_raise(TypeError) { %w(a b c).values_at("x") } ! assert_raise(TypeError) { %w(a b c).values_at([]) } ! assert_raise(TypeError) { %w(a b c).values_at(true) } end end Index: TestDir.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestDir.rb,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** TestDir.rb 28 Jun 2005 16:44:55 -0000 1.21 --- TestDir.rb 25 Aug 2005 23:58:41 -0000 1.22 *************** *** 73,77 **** def test_s_chdir start = Dir.getwd ! assert_raises(Errno::ENOENT) { Dir.chdir "_wombat" } assert_equal(0, Dir.chdir("_test")) assert_equal(File.join(start, "_test"), Dir.getwd) --- 73,77 ---- def test_s_chdir start = Dir.getwd ! assert_raise(Errno::ENOENT) { Dir.chdir "_wombat" } assert_equal(0, Dir.chdir("_test")) assert_equal(File.join(start, "_test"), Dir.getwd) *************** *** 120,124 **** else # none of HOME and LOGDIR set ! assert_raises(ArgumentError) do Dir.chdir() do |dir_param| # not reached --- 120,124 ---- else # none of HOME and LOGDIR set ! assert_raise(ArgumentError) do Dir.chdir() do |dir_param| # not reached *************** *** 140,144 **** # chdir with block to non-existing dir ! assert_raises(Errno::ENOENT) do Dir.chdir("_wombat") do # never reached --- 140,144 ---- # chdir with block to non-existing dir ! assert_raise(Errno::ENOENT) do Dir.chdir("_wombat") do # never reached *************** *** 168,173 **** def test_s_entries ! assert_raises(Errno::ENOENT) { Dir.entries "_wombat" } ! assert_raises(Errno::ENOENT) { Dir.entries "_test/file*" } assert_bag_equal(@files, Dir.entries("_test")) assert_bag_equal(@files, Dir.entries("_test/.")) --- 168,173 ---- def test_s_entries ! assert_raise(Errno::ENOENT) { Dir.entries "_wombat" } ! assert_raise(Errno::ENOENT) { Dir.entries "_test/file*" } assert_bag_equal(@files, Dir.entries("_test")) assert_bag_equal(@files, Dir.entries("_test/.")) *************** *** 178,182 **** got = [] entry = nil ! assert_raises(Errno::ENOENT) { Dir.foreach("_wombat") {}} assert_nil(Dir.foreach("_test") { |f| got << f } ) assert_bag_equal(@files, got) --- 178,182 ---- got = [] entry = nil ! assert_raise(Errno::ENOENT) { Dir.foreach("_wombat") {}} assert_nil(Dir.foreach("_test") { |f| got << f } ) assert_bag_equal(@files, got) *************** *** 231,237 **** def test_s_new ! assert_raises(ArgumentError) { Dir.new } ! assert_raises(ArgumentError) { Dir.new("a", "b") } ! assert_raises(Errno::ENOENT) { Dir.new("_wombat") } assert_equal(Dir, Dir.new(".").class) --- 231,237 ---- def test_s_new ! assert_raise(ArgumentError) { Dir.new } ! assert_raise(ArgumentError) { Dir.new("a", "b") } ! assert_raise(Errno::ENOENT) { Dir.new("_wombat") } assert_equal(Dir, Dir.new(".").class) *************** *** 239,245 **** def test_s_open ! assert_raises(ArgumentError) { Dir.open } ! assert_raises(ArgumentError) { Dir.open("a", "b") } ! assert_raises(Errno::ENOENT) { Dir.open("_wombat") } assert_equal(Dir, Dir.open(".").class) --- 239,245 ---- def test_s_open ! assert_raise(ArgumentError) { Dir.open } ! assert_raise(ArgumentError) { Dir.open("a", "b") } ! assert_raise(Errno::ENOENT) { Dir.open("_wombat") } assert_equal(Dir, Dir.open(".").class) *************** *** 294,298 **** d.read assert_nil(d.close) ! assert_raises(IOError) { d.read } end --- 294,298 ---- d.read assert_nil(d.close) ! assert_raise(IOError) { d.read } end Index: TestString.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestString.rb,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TestString.rb 25 Aug 2005 22:01:30 -0000 1.10 --- TestString.rb 25 Aug 2005 23:58:41 -0000 1.11 *************** *** 116,120 **** s[-1]= S('B') assert_equal(S("AooBaB"), s) ! assert_raises(IndexError) { s[-7] = S("xyz") } assert_equal(S("AooBaB"), s) s[0] = S("ABC") --- 116,120 ---- s[-1]= S('B') assert_equal(S("AooBaB"), s) ! assert_raise(IndexError) { s[-7] = S("xyz") } assert_equal(S("AooBaB"), s) s[0] = S("ABC") *************** *** 734,742 **** assert_equal(S("ABCD"), S("AD").insert(1, S("BC"))) assert_equal(S("ADBC"), S("AD").insert(2, S("BC"))) ! assert_raises(IndexError) { S("AD").insert(3, S("BC")) } assert_equal(S("ADBC"), S("AD").insert(-1, S("BC"))) assert_equal(S("ABCD"), S("AD").insert(-2, S("BC"))) assert_equal(S("BCAD"), S("AD").insert(-3, S("BC"))) ! assert_raises(IndexError) { S("AD").insert(-4, S("BC")) } end end --- 734,742 ---- assert_equal(S("ABCD"), S("AD").insert(1, S("BC"))) assert_equal(S("ADBC"), S("AD").insert(2, S("BC"))) ! assert_raise(IndexError) { S("AD").insert(3, S("BC")) } assert_equal(S("ADBC"), S("AD").insert(-1, S("BC"))) assert_equal(S("ABCD"), S("AD").insert(-2, S("BC"))) assert_equal(S("BCAD"), S("AD").insert(-3, S("BC"))) ! assert_raise(IndexError) { S("AD").insert(-4, S("BC")) } end end *************** *** 1022,1026 **** assert_nil( a.slice!(6) ) else ! assert_raises(:IndexError) { a.slice!(6) } end assert_equal(S("FooBar"), a) --- 1022,1026 ---- assert_nil( a.slice!(6) ) else ! assert_raise(:IndexError) { a.slice!(6) } end assert_equal(S("FooBar"), a) *************** *** 1029,1033 **** assert_nil( a.slice!(-7) ) else ! assert_raises(:IndexError) { a.slice!(-7) } end assert_equal(S("FooBar"), a) --- 1029,1033 ---- assert_nil( a.slice!(-7) ) else ! assert_raise(:IndexError) { a.slice!(-7) } end assert_equal(S("FooBar"), a) *************** *** 1045,1049 **** assert_nil(a.slice!(7,2)) # Maybe should be six? else ! assert_raises(:IndexError) {a.slice!(7,2)} # Maybe should be six? end assert_equal(S("FooBar"), a) --- 1045,1049 ---- assert_nil(a.slice!(7,2)) # Maybe should be six? else ! assert_raise(:IndexError) {a.slice!(7,2)} # Maybe should be six? end assert_equal(S("FooBar"), a) *************** *** 1051,1055 **** assert_nil(a.slice!(-7,10)) else ! assert_raises(:IndexError) {a.slice!(-7,10)} end assert_equal(S("FooBar"), a) --- 1051,1055 ---- assert_nil(a.slice!(-7,10)) else ! assert_raise(:IndexError) {a.slice!(-7,10)} end assert_equal(S("FooBar"), a) *************** *** 1072,1076 **** end else ! assert_raises(:RangeError) {a.slice!(6..2)} end assert_equal(S("FooBar"), a) --- 1072,1076 ---- end else ! assert_raise(:RangeError) {a.slice!(6..2)} end assert_equal(S("FooBar"), a) *************** *** 1078,1082 **** assert_nil(a.slice!(-10..-7)) else ! assert_raises(:RangeError) {a.slice!(-10..-7)} end assert_equal(S("FooBar"), a) --- 1078,1082 ---- assert_nil(a.slice!(-10..-7)) else ! assert_raise(:RangeError) {a.slice!(-10..-7)} end assert_equal(S("FooBar"), a) *************** *** 1094,1098 **** assert_nil(a.slice!(/xyzzy/)) else ! assert_raises(:IndexError) {a.slice!(/xyzzy/)} end assert_equal(S("FooBar"), a) --- 1094,1098 ---- assert_nil(a.slice!(/xyzzy/)) else ! assert_raise(:IndexError) {a.slice!(/xyzzy/)} end assert_equal(S("FooBar"), a) *************** *** 1100,1104 **** assert_nil(a.slice!(/plugh/)) else ! assert_raises(:IndexError) {a.slice!(/plugh/)} end assert_equal(S("FooBar"), a) --- 1100,1104 ---- assert_nil(a.slice!(/plugh/)) else ! assert_raise(:IndexError) {a.slice!(/plugh/)} end assert_equal(S("FooBar"), a) From holmberg at rubyforge.org Fri Aug 26 11:13:41 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Fri Aug 26 11:13:43 2005 Subject: [Rubytests-commit] rubicon/builtin TestEnumerable.rb Message-ID: <200508261513.j7QFDfcR016743@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv16465 Modified Files: TestEnumerable.rb Log Message: Changed "test_zip" to also test "zip" with a block. Now we test both with and without a block using the same "test-vectors". Index: TestEnumerable.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestEnumerable.rb,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** TestEnumerable.rb 25 Aug 2005 23:58:41 -0000 1.20 --- TestEnumerable.rb 26 Aug 2005 15:13:39 -0000 1.21 *************** *** 383,405 **** Version.greater_or_equal("1.6.8") do def test_zip ! assert_equal([%w(a 1), %w(b 2), %w(c 3), %w(d 4)], ! E('a','b','c','d').zip(%w(1 2 3 4))) ! assert_equal([%w(a 1), %w(b 2)], E('a','b').zip(%w(1 2 3 4))) ! assert_equal([%w(a 1), %w(b 2), ['c', nil], ['d', nil]], ! E('a','b','c','d').zip(%w(1 2))) ! assert_equal([[1], [2]], E(1, 2).zip) ! assert_equal([["a\n"], ["b\n"], ["c"]], "a\nb\nc".zip) ! assert_equal([["a\n", 1], ["b\n", 2], ["c", 3]], ! "a\nb\nc".zip([1, 2, 3])) ! assert_equal([[1, nil], [2, nil]], E(1, 2).zip([])) Version.greater_or_equal("1.9.0") do ! assert_equal([[1, nil], [2, nil]], E(1, 2).zip(nil)) ! assert_equal([[1, 4], [2, 5], [3, 6]], E(1, 2, 3).zip(4..6)) ! assert_equal([[1, nil], [2, nil]], E(1, 2).zip('')) ! assert_equal([[1, 'ab'], [2, nil]], E(1, 2).zip('ab')) ! assert_equal([[1, "a\n"], [2, "b\n"], [3, "c"], [4, nil]], ! E(1, 2, 3, 4).zip("a\nb\nc")) ! assert_equal([[1, ['a', 5]], [2, nil]], E(1, 2).zip({'a'=>5})) end end --- 383,419 ---- Version.greater_or_equal("1.6.8") do + + # Helper method to "test_zip". + # Here we test "zip" with and without a block, using + # the "test-vectors" specified in "test_zip". + # + def zip_tests(expected, object, *args) + assert_equal(expected, object.zip(*args)) + + acc = [] + res = object.zip(*args) {|x| acc << x } + assert_equal(nil, res) + assert_equal(expected, acc) + end + def test_zip ! zip_tests([%w(a 1), %w(b 2), %w(c 3), %w(d 4)], ! E('a','b','c','d'), %w(1 2 3 4)) ! zip_tests([%w(a 1), %w(b 2)], E('a','b'), %w(1 2 3 4)) ! zip_tests([%w(a 1), %w(b 2), ['c', nil], ['d', nil]], ! E('a','b','c','d'), %w(1 2)) ! zip_tests([[1], [2]], E(1, 2)) ! zip_tests([["a\n"], ["b\n"], ["c"]], "a\nb\nc") ! zip_tests([["a\n", 1], ["b\n", 2], ["c", 3]], ! "a\nb\nc", [1, 2, 3]) ! zip_tests([[1, nil], [2, nil]], E(1, 2), []) Version.greater_or_equal("1.9.0") do ! zip_tests([[1, nil], [2, nil]], E(1, 2), nil) ! zip_tests([[1, 4], [2, 5], [3, 6]], E(1, 2, 3), 4..6) ! zip_tests([[1, nil], [2, nil]], E(1, 2), '') ! zip_tests([[1, 'ab'], [2, nil]], E(1, 2), 'ab') ! zip_tests([[1, "a\n"], [2, "b\n"], [3, "c"], [4, nil]], ! E(1, 2, 3, 4), "a\nb\nc") ! zip_tests([[1, ['a', 5]], [2, nil]], E(1, 2), {'a'=>5}) end end From holmberg at rubyforge.org Fri Aug 26 11:42:13 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Fri Aug 26 11:42:14 2005 Subject: [Rubytests-commit] rubicon/builtin TestEnumerable.rb Message-ID: <200508261542.j7QFgDcR019329@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv17690 Modified Files: TestEnumerable.rb Log Message: Changed tests for exceptions in "test_min" and "test_max" to accept both NoMethodError and ArgumentError. Earlier the tests tried to accept only one of these exceptions, choosing which depending on the version of Ruby. But the tests were wrong for at least 1.8.1. Index: TestEnumerable.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestEnumerable.rb,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** TestEnumerable.rb 26 Aug 2005 15:13:39 -0000 1.21 --- TestEnumerable.rb 26 Aug 2005 15:42:11 -0000 1.22 *************** *** 260,269 **** assert_equal(nil, E().max) assert_raise(NoMethodError) { E(Object.new, Object.new).max } ! Version.less_than("1.8.3") do ! assert_raise(NoMethodError) { E(11,"22").max } ! end ! Version.greater_or_equal("1.8.3") do ! assert_raise(ArgumentError) { E(11,"22").max } ! end # with a block --- 260,264 ---- assert_equal(nil, E().max) assert_raise(NoMethodError) { E(Object.new, Object.new).max } ! assert_raise(NoMethodError, ArgumentError) { E(11,"22").max } # with a block *************** *** 310,319 **** assert_equal(nil, E().min) assert_raise(NoMethodError) { E(Object.new, Object.new).min } ! Version.less_than("1.8.3") do ! assert_raise(NoMethodError) { E(11,"22").min } ! end ! Version.greater_or_equal("1.8.3") do ! assert_raise(ArgumentError) { E(11,"22").min } ! end # with a block --- 305,309 ---- assert_equal(nil, E().min) assert_raise(NoMethodError) { E(Object.new, Object.new).min } ! assert_raise(NoMethodError, ArgumentError) { E(11,"22").min } # with a block From holmberg at rubyforge.org Tue Aug 30 18:04:53 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Tue Aug 30 18:04:55 2005 Subject: [Rubytests-commit] rubicon rubicon.rb Message-ID: <200508302204.j7UM4rcR004099@rubyforge.org> Update of /var/cvs/rubytests/rubicon In directory rubyforge.org:/tmp/cvs-serv3949 Modified Files: rubicon.rb Log Message: Changed the "Version" class. The primary motivation for the change was to be able to use "Version" in more complex expressions than a simple compare, e.g.: if Version <= "1.8.0" || some_other_condition assert(...) else assert(...) end Previously the Version class was never instantiated, but still had some unused instance methods (e.g. "initialize" and <=>). The methods used in the testcase files were the class methods (e.g. Version.greater_than). Now the class Version has been renamed LanguageVersion, and *is* instantiated once. That instance is assigned to the global constant Version. This makes the old code in all testcases work like before. It also makes it possible to use <, >, <= and >= like in the example above. The methods like "greater_than" now call <=> (indirectly via the Comparable mixin), so the logic for comparing versions is more centralized (but note LanguageVersion#in that still uses Range: it should be changed too). Index: rubicon.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/rubicon.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** rubicon.rb 8 Jun 2005 02:26:20 -0000 1.7 --- rubicon.rb 30 Aug 2005 22:04:51 -0000 1.8 *************** *** 152,171 **** # Use in the code with stuff like: # ! # Version.greater_than("1.6.2) do # assert(...) # end # ! class Version include Comparable ! # RUBY_VERSION is introduced with 1.9.x ! # VERSION was used until 1.9.x ! VERSION = defined?(RUBY_VERSION) ? RUBY_VERSION : VERSION ! ! def initialize(version) ! @version = version end def <=>(other) @version <=> other --- 152,181 ---- # Use in the code with stuff like: # ! # Version.greater_than("1.6.2") do # assert(...) # end # + # or like + # + # if Version <= "1.8.0" + # assert(...) + # end + # ! class LanguageVersion include Comparable ! def initialize ! # RUBY_VERSION is introduced with 1.9.x ! # VERSION was used until 1.9.x ! @version = defined?(RUBY_VERSION) ? RUBY_VERSION : VERSION end + # This method defines how to compare versions, and should be the only + # place where such a comparison is made. Other methods, like + # LanguageVersion.greater_than, use this method at a lower level. + # + # The argument is a string (not another LanguageVersion object). + # def <=>(other) @version <=> other *************** *** 174,203 **** # Specify a range of versions, and run a test block if the current version # falls within that range. ! def Version.in(range) ! if(range.include?(VERSION)) then yield end end ! def Version.greater_than(version) ! if(VERSION > version) then yield end end ! def Version.greater_or_equal(version) ! if(VERSION >= version) then yield end end ! def Version.less_than(version) ! if(VERSION < version) then yield end end ! def Version.less_or_equal(version) ! if(VERSION <= version) then yield end --- 184,220 ---- # Specify a range of versions, and run a test block if the current version # falls within that range. ! # ! def in(range) ! # TODO: eliminate dependency on Range#include?. If the version ! # comparison becomes more complicated than a simple lexicographical ! # comparison, we need to take care of this ourselves. Then we ! # should use LanguageVersion#<=> here too, so we have *one* point ! # where this is defined. ! # ! if range.include?(@version) yield end end ! def greater_than(version) ! if self > version yield end end ! def greater_or_equal(version) ! if self >= version yield end end ! def less_than(version) ! if self < version yield end end ! def less_or_equal(version) ! if self <= version yield end *************** *** 205,206 **** --- 222,226 ---- end + + Version = LanguageVersion.new + From holmberg at rubyforge.org Tue Aug 30 18:15:36 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Tue Aug 30 18:15:36 2005 Subject: [Rubytests-commit] rubicon/builtin TestRange.rb Message-ID: <200508302215.j7UMFacR005625@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv4971 Modified Files: TestRange.rb Log Message: Range#include? and Range#member? were *not* alises in older versions of Ruby ( <= 1.8.1 ). Changed the tests to take care of this fact (restoring code that was lost in an earlier commit). Index: TestRange.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestRange.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TestRange.rb 26 May 2005 22:19:51 -0000 1.8 --- TestRange.rb 30 Aug 2005 22:15:34 -0000 1.9 *************** *** 94,103 **** # as continuous range ! assert_equal([4.5, 5.5, 6.5], xs.select {|x| r47.send(method, x) }) ! assert_equal([4.5, 5.5, 6.5], xs.select {|x| rx47.send(method, x) }) ! ! assert_equal(["akkk","alll"], xss.select {|i| r_akam.send(method, i) }) ! assert_equal(["akkk","alll"], xss.select {|i| rx_akam.send(method, i) }) # non-comparable argument assert_equal(false, Range.new(5, 10) === Object.new) --- 94,111 ---- # as continuous range ! if method == :member? && Version <= "1.8.1" ! assert_equal([], xs.select {|x| r47.send(method, x) }) ! assert_equal([], xs.select {|x| rx47.send(method, x) }) ! ! assert_equal([], xss.select {|i| r_akam.send(method, i) }) ! assert_equal([], xss.select {|i| rx_akam.send(method, i) }) ! else ! assert_equal([4.5, 5.5, 6.5], xs.select {|x| r47.send(method, x) }) ! assert_equal([4.5, 5.5, 6.5], xs.select {|x| rx47.send(method, x) }) + assert_equal(["akkk","alll"], xss.select {|i| r_akam.send(method, i) }) + assert_equal(["akkk","alll"], xss.select {|i| rx_akam.send(method, i) }) + end + # non-comparable argument assert_equal(false, Range.new(5, 10) === Object.new) From holmberg at rubyforge.org Tue Aug 30 18:24:55 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Tue Aug 30 18:24:56 2005 Subject: [Rubytests-commit] rubicon/builtin TestRange.rb Message-ID: <200508302224.j7UMOtcR006905@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv6084 Modified Files: TestRange.rb Log Message: The test method "test_each" earlier used Time objects as examples of objects with a "succ" method. But Time in earlier version of Ruby (at least 1.8.0) didn't have any "succ" method. Changed the code to use a special helper class "SuccDefiner" designed specially for this situation, instead of the previous usage of Time. Index: TestRange.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestRange.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TestRange.rb 30 Aug 2005 22:15:34 -0000 1.9 --- TestRange.rb 30 Aug 2005 22:24:53 -0000 1.10 *************** *** 4,7 **** --- 4,29 ---- class TestRange < Rubicon::TestCase + # a simple class with a 'succ' method + # + class SuccDefiner + + include Comparable + + attr_reader :n + + def initialize(n) + @n = n + end + + def succ + SuccDefiner.new(@n + 1) + end + + def <=>(other) + @n <=> other.n + end + + end + ############################################################ # Test Utilities: *************** *** 150,156 **** util_each("A", "J", true, 9) ! # TODO: test something that has a .succ, but is neither int nor string ! t1 = Time.at(1) ! t10 = Time.at(10) util_each(t1, t10, false, 10) util_each(t1, t10, true, 9) --- 172,178 ---- util_each("A", "J", true, 9) ! # test something that has a .succ, but is neither int nor string ! t1 = SuccDefiner.new(1) ! t10 = SuccDefiner.new(10) util_each(t1, t10, false, 10) util_each(t1, t10, true, 9) From holmberg at rubyforge.org Tue Aug 30 18:45:19 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Tue Aug 30 18:45:21 2005 Subject: [Rubytests-commit] rubicon/builtin TestString.rb Message-ID: <200508302245.j7UMjJcR009902@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv9555 Modified Files: TestString.rb Log Message: Before 1.8.2 the methods ljust, rjust and center behaved slightly different. If given an empty string as padding, they used " " instead. In 1.8.2 an exception is thrown instead. The tests have been updated to reflect this change. Index: TestString.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestString.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TestString.rb 25 Aug 2005 23:58:41 -0000 1.11 --- TestString.rb 30 Aug 2005 22:45:17 -0000 1.12 *************** *** 389,393 **** # zero width padding ! assert_raise(ArgumentError) { S("hi").center(11, "") } end --- 389,398 ---- # zero width padding ! Version.greater_or_equal("1.8.2") do ! assert_raise(ArgumentError) { S("hi").center(11, "") } ! end ! Version.less_than("1.8.2") do ! assert_equal(S(" hi "), S("hi").center(11, "")) ! end end *************** *** 768,772 **** # zero width padding ! assert_raise(ArgumentError) { S("hello").ljust(11, "") } end --- 773,782 ---- # zero width padding ! Version.greater_or_equal("1.8.2") do ! assert_raise(ArgumentError) { S("hello").ljust(11, "") } ! end ! Version.less_than("1.8.2") do ! assert_equal(S("hi "), S("hi").ljust(11, "")) ! end end *************** *** 925,929 **** # zero width padding ! assert_raise(ArgumentError) { S("hi").rjust(11, "") } end --- 935,944 ---- # zero width padding ! Version.greater_or_equal("1.8.2") do ! assert_raise(ArgumentError) { S("hi").rjust(11, "") } ! end ! Version.less_than("1.8.2") do ! assert_equal(S(" hi"), S("hi").rjust(11, "")) ! end end From holmberg at rubyforge.org Wed Aug 31 16:57:26 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Wed Aug 31 16:57:28 2005 Subject: [Rubytests-commit] rubicon/builtin TestString.rb Message-ID: <200508312057.j7VKvQcR031515@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv31441 Modified Files: TestString.rb Log Message: Modified the tests of String#intern and String#to_sym: - String#to_sym was introduced *after* 1.6.8 - String#intern and String#to_sym are aliases, so the tests of both of them were moved to a new helper-method "generic_test_intern". "test_intern" and "test_to_sym" call that method with the method name as argument. - avoid using the new syntax for Symbol literals. It didn't exist in early versions of Ruby. Equivalent tests can be done by other means: verifying that the type is Symbol, and that applying the #to_s method gives the right string. After these changes the "test_intern" and "test_to_sym" test methods work at least with version 1.6.8, 1.8.0, 1.8.1 and 1.8.2. Index: TestString.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestString.rb,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TestString.rb 30 Aug 2005 22:45:17 -0000 1.12 --- TestString.rb 31 Aug 2005 20:57:24 -0000 1.13 *************** *** 747,757 **** end ! def test_intern ! assert_equal(:koala, S("koala").intern) ! assert(:koala != S("Koala").intern) # error cases ! assert_raise(ArgumentError) { S("").intern } ! assert_raise(ArgumentError) { S("with\0null\0inside").intern } end --- 747,778 ---- end ! def generic_test_intern(method) ! assert_equal(:koala, S("koala").send(method)) ! assert(:koala != S("Koala").send(method)) ! ! # Verify that different types of strings are allowed, ! # and do it without using the new literal syntax ! # for symbols (i.e. :"with spaces"). ! # ! for str in ["identifier", "with spaces", "9with_digits", "9and spaces"] ! sym = S(str).send(method) ! assert_instance_of(Symbol, sym) ! assert_equal(str, sym.to_s) ! end # error cases ! if Version > "1.6.8" ! assert_raise(ArgumentError) { S("").send(method) } ! else ! # empty Symbols were allowed in 1.6.8 ! sym = S("").send(method) ! assert_instance_of(Symbol, sym) ! assert_equal("", sym.to_s) ! end ! assert_raise(ArgumentError) { S("with\0null\0inside").send(method) } ! end ! ! def test_intern ! generic_test_intern(:intern) end *************** *** 1398,1407 **** end ! Version.greater_or_equal("1.6.8") do def test_to_sym ! assert_equal(:alpha, S("alpha").to_sym) ! assert_equal(:alp_ha, S("alp_ha").to_sym) ! assert_equal(:"9alpha", S("9alpha").to_sym) ! assert_equal(:"9al pha", S("9al pha").to_sym) end end --- 1419,1425 ---- end ! Version.greater_than("1.6.8") do def test_to_sym ! generic_test_intern(:to_sym) end end From holmberg at rubyforge.org Wed Aug 31 17:21:16 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Wed Aug 31 17:21:18 2005 Subject: [Rubytests-commit] rubicon/builtin TestSymbol.rb Message-ID: <200508312121.j7VLLGcR003851@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv3778 Modified Files: TestSymbol.rb Log Message: Changes to make the tests pass with different Ruby versions: - Symbol.all_symbols was added after 1.6.8 - Symbol#to_sym was also added after 1.6.8 - Symbol#inspect changed after 1.6.8 with the introduction of the new type of Symbol literals like :"foo bar". With the current changes, the file passes using at least version 1.6.8, 1.8.0, 1.8.1 and 1.8.2. Index: TestSymbol.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestSymbol.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TestSymbol.rb 16 Aug 2005 12:12:31 -0000 1.8 --- TestSymbol.rb 31 Aug 2005 21:21:14 -0000 1.9 *************** *** 34,49 **** end ! def test_s_all_symbols ! assert_instance_of(Array, Symbol.all_symbols) ! Symbol.all_symbols.each do |sym| ! assert_instance_of(Symbol, sym) ! end ! assert_equal(Symbol.all_symbols, Symbol.all_symbols.uniq) ! symbols1 = Symbol.all_symbols ! s1 = gen_unique_symbol ! s2 = gen_unique_symbol ! symbols2 = Symbol.all_symbols ! assert_bag_equal([s1, s2], symbols2 - symbols1) end --- 34,51 ---- end ! Version.greater_than("1.6.8") do ! def test_s_all_symbols ! assert_instance_of(Array, Symbol.all_symbols) ! Symbol.all_symbols.each do |sym| ! assert_instance_of(Symbol, sym) ! end ! assert_equal(Symbol.all_symbols, Symbol.all_symbols.uniq) ! symbols1 = Symbol.all_symbols ! s1 = gen_unique_symbol ! s2 = gen_unique_symbol ! symbols2 = Symbol.all_symbols ! assert_bag_equal([s1, s2], symbols2 - symbols1) ! end end *************** *** 67,73 **** def test_inspect assert_equal(':hello', 'hello'.intern.inspect) ! assert_equal(':"hello world"', 'hello world'.intern.inspect) ! assert_equal(':"with \" char"', 'with " char'.intern.inspect) ! assert_equal(':"with \\\\ \" chars"', 'with \ " chars'.intern.inspect) end --- 69,83 ---- def test_inspect assert_equal(':hello', 'hello'.intern.inspect) ! if Version > "1.6.8" ! assert_equal(':"hello world"', 'hello world'.intern.inspect) ! assert_equal(':"with \" char"', 'with " char'.intern.inspect) ! assert_equal(':"with \\\\ \" chars"', 'with \ " chars'.intern.inspect) ! else ! # before the :"foobar" syntax existed the following was probably ! # as good as anything else ... ! assert_equal(':hello world', 'hello world'.intern.inspect) ! assert_equal(':with " char', 'with " char'.intern.inspect) ! assert_equal(':with \ " chars', 'with \ " chars'.intern.inspect) ! end end *************** *** 85,92 **** end ! def test_to_sym ! assert_equal(:Fred, :Fred.to_sym) ! assert_equal(:Barney, :Barney.to_sym) ! assert_equal(:wilma, :wilma.to_sym) end --- 95,104 ---- end ! Version.greater_than("1.6.8") do ! def test_to_sym ! assert_equal(:Fred, :Fred.to_sym) ! assert_equal(:Barney, :Barney.to_sym) ! assert_equal(:wilma, :wilma.to_sym) ! end end