From holmberg at rubyforge.org Mon Jul 4 11:14:13 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Mon Jul 4 11:14:15 2005 Subject: [Rubytests-commit] rubicon/builtin TestEnumerable.rb Message-ID: <200507041514.j64FEDcR022663@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv22530 Modified Files: TestEnumerable.rb Log Message: An error case for Enumerable#min and Enumerable#max gives an exception. The excpetion type has changed from NoMethodError to ArgumentError, but the change occurs already in 1.8.3, not in 1.9.0 as assumed before. Index: TestEnumerable.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestEnumerable.rb,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** TestEnumerable.rb 12 Jun 2004 16:49:41 -0000 1.17 --- TestEnumerable.rb 4 Jul 2005 15:14:11 -0000 1.18 *************** *** 237,244 **** assert_equal(nil, E().max) assert_raises(NoMethodError) { E(Object.new, Object.new).max } ! Version.less_than("1.9.0") do assert_raises(NoMethodError) { E(11,"22").max } end ! Version.greater_or_equal("1.9.0") do assert_raises(ArgumentError) { E(11,"22").max } end --- 237,244 ---- 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 *************** *** 287,294 **** assert_equal(nil, E().min) assert_raises(NoMethodError) { E(Object.new, Object.new).min } ! Version.less_than("1.9.0") do assert_raises(NoMethodError) { E(11,"22").min } end ! Version.greater_or_equal("1.9.0") do assert_raises(ArgumentError) { E(11,"22").min } end --- 287,294 ---- 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 From holmberg at rubyforge.org Thu Jul 7 12:49:38 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Thu Jul 7 12:49:40 2005 Subject: [Rubytests-commit] rubicon/builtin TestTime.rb Message-ID: <200507071649.j67GnccR019161@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv18955 Modified Files: TestTime.rb Log Message: Added more tests of the different possible arguments to "Time.at": one/two arguments, integer/float arguments, Time argument. Use Time#tv_sec and Time#tv_usec to verify what kind of Time object we get. Index: TestTime.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestTime.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TestTime.rb 18 May 2005 08:46:45 -0000 1.9 --- TestTime.rb 7 Jul 2005 16:49:36 -0000 1.10 *************** *** 149,152 **** --- 149,183 ---- assert_equal(@loc, Time.at(@loc)) assert_in_delta(Time.at(sec,1_000_000).to_f, Time.at(sec).to_f, 1.0) + + # no arguments ==> error + assert_raise(ArgumentError) do + Time.at + end + + # one integer argument ==> seconds + t = Time.at(1_234_567) + assert_equal(1_234_567, t.tv_sec) + assert_equal( 0, t.tv_usec) + + # two integer arguments ==> seconds & microseconds + t = Time.at(1_234_567, 888_999) + assert_equal(1_234_567, t.tv_sec) + assert_equal( 888_999, t.tv_usec) + + # float argument ==> second & rounded microseconds + t = Time.at(1_234_567.5) + assert_equal(1_234_567, t.tv_sec) + assert_equal( 500_000, t.tv_usec) + + # float + integer arguments ==> rounded seconds & microseconds + t = Time.at(1_234_567.5, 300_000) + assert_equal(1_234_567, t.tv_sec) + assert_equal( 300_000, t.tv_usec) + + # Time argument + t1 = Time.at(1_234_567, 888_999) + t2 = Time.at(t1) + assert_equal(1_234_567, t2.tv_sec) + assert_equal( 888_999, t2.tv_usec) end From holmberg at rubyforge.org Fri Jul 8 11:15:46 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Fri Jul 8 11:15:47 2005 Subject: [Rubytests-commit] rubicon/builtin TestTime.rb Message-ID: <200507081515.j68FFkcR022585@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv22122 Modified Files: TestTime.rb Log Message: Added more tests of Time#+ and Time#- with the different types of arguments possible: integer and floating point for Time#+, and integer, floating point and Time for Time#-. Index: TestTime.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestTime.rb,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TestTime.rb 7 Jul 2005 16:49:36 -0000 1.10 --- TestTime.rb 8 Jul 2005 15:15:44 -0000 1.11 *************** *** 465,468 **** --- 465,486 ---- assert_equal(Time.gm(*x.result) - Time.gm(*x.orig), x.amt) end + + # integer argument + t1 = Time.at(1_234_567, 500_000) + t2 = t1 - 567 + assert_equal( 1_234_000, t2.tv_sec) + assert_equal( 500_000, t2.tv_usec) + + # float argument with fractional part + t1 = Time.at(1_234_567, 500_000) + t2 = t1 - 566.75 + assert_equal( 1_234_000, t2.tv_sec) + assert_equal( 750_000, t2.tv_usec) + + # Time argument + t1 = Time.at(1_234_000, 750_000) + t2 = Time.at(1_234_567, 500_000) + diff = t2 - t1 + assert_equal( 566.75, diff) end *************** *** 480,483 **** --- 498,513 ---- assert_equal(Time.gm(*x.orig) + x.amt, Time.gm(*x.result)) end + + # integer argument + t1 = Time.at(1_234_567, 500_000) + t2 = t1 + 433 + assert_equal( 1_235_000, t2.tv_sec) + assert_equal( 500_000, t2.tv_usec) + + # float argument with fractional part + t1 = Time.at(1_234_567, 500_000) + t2 = t1 + 433.25 + assert_equal( 1_235_000, t2.tv_sec) + assert_equal( 750_000, t2.tv_usec) end From drbrain at segment7.net Fri Jul 8 13:23:00 2005 From: drbrain at segment7.net (Eric Hodel) Date: Fri Jul 8 13:17:58 2005 Subject: [Rubytests-commit] rubicon/builtin TestTime.rb In-Reply-To: <200507081515.j68FFkcR022585@rubyforge.org> References: <200507081515.j68FFkcR022585@rubyforge.org> Message-ID: <16CC4363-2159-493B-9923-A28E86192568@segment7.net> On 08 Jul 2005, at 08:15, holmberg@rubyforge.org wrote: > + t1 = Time.at(1_234_567, 500_000) > + t1 = Time.at(1_234_567, 500_000) > + t2 = Time.at(1_234_567, 500_000) > + t1 = Time.at(1_234_567, 500_000) > + t1 = Time.at(1_234_567, 500_000) Why is this duplicated so much? -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 From holmberg at rubyforge.org Mon Jul 18 11:44:08 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Mon Jul 18 11:44:09 2005 Subject: [Rubytests-commit] rubicon/builtin TestFileTest.rb Message-ID: <200507181544.j6IFi8cR016290@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv16233/builtin Modified Files: TestFileTest.rb Log Message: Set setuid bit with a File.chmod call, and avoid relying on File.open. This works better on MacOS, and is ok on other platforms too. Index: TestFileTest.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestFileTest.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestFileTest.rb 8 Jun 2005 02:26:45 -0000 1.3 --- TestFileTest.rb 18 Jul 2005 15:44:06 -0000 1.4 *************** *** 56,60 **** fileu = "_test/_fileu" ! File.open(fileu, File::CREAT, 04644) { } end --- 56,61 ---- fileu = "_test/_fileu" ! File.open(fileu, File::CREAT, 0644) { } ! File.chmod(04644, fileu) # set-uid bit end From holmberg at rubyforge.org Mon Jul 18 11:49:41 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Mon Jul 18 11:49:42 2005 Subject: [Rubytests-commit] rubicon/builtin TestString.rb Message-ID: <200507181549.j6IFnfcR016639@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv16546/builtin Modified Files: TestString.rb Log Message: Added more tests of String#=~, verifying that "str =~ obj" is the same as "obj =~ str" when "obj" is not a Regexp. Index: TestString.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestString.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestString.rb 8 Jun 2005 02:27:06 -0000 1.2 --- TestString.rb 18 Jul 2005 15:49:39 -0000 1.3 *************** *** 204,211 **** --- 204,232 ---- end + # Helper class to test String#=~. + # + class MatchDefiner + def initialize(result) + @result = result + end + + def =~(other) + [other, @result] + end + end + def test_MATCH # '=~' + # "str =~ regexp" same as "regexp =~ str" assert_equal(10, S("FeeFieFoo-Fum") =~ /Fum$/) assert_equal(nil, S("FeeFieFoo-Fum") =~ /FUM$/) + # "str =~ obj" calls "obj =~ str" + assert_equal(["aaa", 123], "aaa" =~ MatchDefiner.new(123)) + assert_equal(["bbb", :foo], "bbb" =~ MatchDefiner.new(:foo)) + assert_equal(["ccc", nil], "ccc" =~ MatchDefiner.new(nil)) + + # default Object#=~ method. + assert_equal(false, "a string" =~ Object.new) + pre_1_7_1 do $= = true From holmberg at rubyforge.org Mon Jul 18 12:12:12 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Mon Jul 18 12:12:13 2005 Subject: [Rubytests-commit] rubicon/builtin TestString.rb Message-ID: <200507181612.j6IGCCcR020357@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv20340/builtin Modified Files: TestString.rb Log Message: Added more tests of String#ljust, String#rjust and String#center, testing the optional second "padding" argument. Index: TestString.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestString.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestString.rb 18 Jul 2005 15:49:39 -0000 1.3 --- TestString.rb 18 Jul 2005 16:12:10 -0000 1.4 *************** *** 355,358 **** --- 355,366 ---- assert_equal(S("hello"), S("hello").center(4)) assert_equal(S(" hello "), S("hello").center(11)) + + # with explicit padding + assert_equal(S("1111hi11111"), S("hi").center(11, "1")) + assert_equal(S("1212hi12121"), S("hi").center(11, "12")) + assert_equal(S("1234hi12341"), S("hi").center(11, "1234")) + + # zero width padding + assert_raise(ArgumentError) { S("hi").center(11, "") } end *************** *** 719,722 **** --- 727,738 ---- assert_equal(S("hello"), S("hello").ljust(4)) assert_equal(S("hello "), S("hello").ljust(11)) + + # with explicit padding + assert_equal(S("hi111111111"), S("hi").ljust(11, "1")) + assert_equal(S("hi121212121"), S("hi").ljust(11, "12")) + assert_equal(S("hi123412341"), S("hi").ljust(11, "1234")) + + # zero width padding + assert_raise(ArgumentError) { S("hello").ljust(11, "") } end *************** *** 868,871 **** --- 884,895 ---- assert_equal(S("hello"), S("hello").rjust(4)) assert_equal(S(" hello"), S("hello").rjust(11)) + + # with explicit padding + assert_equal(S("111111111hi"), S("hi").rjust(11, "1")) + assert_equal(S("121212121hi"), S("hi").rjust(11, "12")) + assert_equal(S("123412341hi"), S("hi").rjust(11, "1234")) + + # zero width padding + assert_raise(ArgumentError) { S("hi").rjust(11, "") } end From holmberg at rubyforge.org Mon Jul 18 12:16:10 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Mon Jul 18 12:16:10 2005 Subject: [Rubytests-commit] rubicon/builtin TestString.rb Message-ID: <200507181616.j6IGGAcR020570@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv20508/builtin Modified Files: TestString.rb Log Message: Added more tests of String#sum. The previous tests didn't "cover" all paths through the code of the method in C-Ruby. Index: TestString.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestString.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TestString.rb 18 Jul 2005 16:12:10 -0000 1.4 --- TestString.rb 18 Jul 2005 16:16:07 -0000 1.5 *************** *** 1276,1283 **** --- 1276,1306 ---- n = S("\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001") assert_equal(15, n.sum) + assert_equal(15, n.sum(32)) n += S("\001") assert_equal(16, n.sum(17)) + assert_equal(16, n.sum(32)) n[0] = 2 assert(15 != n.sum) + + # basic test of all reasonable "bit sizes" + str = S("\xFF" * 257) + 2.upto(32) do |bits| + assert_equal(65535 % (2**bits), str.sum(bits)) + end + + # with 16 bits the result is modulo 65536 + assert_equal( 255, S("\xFF").sum) + assert_equal( 510, S("\xFF\xFF").sum) + assert_equal(65535, S("\xFF" * 257).sum) + assert_equal( 254, S("\xFF" * 258).sum) + + # with 32 bits the result is modulo 2**32 + assert_equal( 255, S("\xFF").sum(32)) + assert_equal( 510, S("\xFF\xFF").sum(32)) + assert_equal(65535, S("\xFF" * 257).sum(32)) + assert_equal(65790, S("\xFF" * 258).sum(32)) + # the following case takes 16MB and takes a long time to compute, + # so it is commented out. + #assert_equal( 254, S("\xFF" * (257 * 65537 + 1)).sum(32)) end From holmberg at rubyforge.org Mon Jul 18 12:18:40 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Mon Jul 18 12:18:42 2005 Subject: [Rubytests-commit] rubicon/builtin TestString.rb Message-ID: <200507181618.j6IGIecR020694@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv20670/builtin Modified Files: TestString.rb Log Message: Added testing of errors cases for String#intern. The string may *not* be empty or contain \0 characters. Index: TestString.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestString.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TestString.rb 18 Jul 2005 16:16:07 -0000 1.5 --- TestString.rb 18 Jul 2005 16:18:38 -0000 1.6 *************** *** 715,718 **** --- 715,722 ---- 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 From holmberg at rubyforge.org Mon Jul 18 12:21:10 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Mon Jul 18 12:21:12 2005 Subject: [Rubytests-commit] rubicon/builtin TestString.rb Message-ID: <200507181621.j6IGLAcR020859@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv20810/builtin Modified Files: TestString.rb Log Message: Added test of an error case for String#crypt: the "salt" argument should be at least 2 characters. Index: TestString.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestString.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TestString.rb 18 Jul 2005 16:18:38 -0000 1.6 --- TestString.rb 18 Jul 2005 16:21:08 -0000 1.7 *************** *** 480,483 **** --- 480,486 ---- assert_equal(S('aaGUC/JkO9/Sc'), S("mypassword").crypt(S("aa"))) assert(S('aaGUC/JkO9/Sc') != S("mypassword").crypt(S("ab"))) + + # "salt" should be at least 2 characters + assert_raise(ArgumentError) { S("mypassword").crypt("a")} end From holmberg at rubyforge.org Mon Jul 18 12:24:40 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Mon Jul 18 12:24:42 2005 Subject: [Rubytests-commit] rubicon/builtin TestArray.rb Message-ID: <200507181624.j6IGOecR021102@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv21074/builtin Modified Files: TestArray.rb Log Message: Added more tests to Array#fill, testing with a block, with negative index and with fill range outside original array. Index: TestArray.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestArray.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestArray.rb 8 Jun 2005 02:26:33 -0000 1.2 --- TestArray.rb 18 Jul 2005 16:24:38 -0000 1.3 *************** *** 697,700 **** --- 697,710 ---- assert_equal(@cls[99, 2], @cls[1, 2].fill(99, 0, 1)) assert_equal(@cls[99, 2], @cls[1, 2].fill(99, 0..0)) + + # fill outside of original array + assert_equal(@cls[1, 2, nil, nil, 88, 88, 88], @cls[1,2].fill(88, 4..6)) + + # negative index counts from end + assert_equal(@cls[1,2,77,77,77,77,77], @cls[1,2,3,4].fill(77, -2, 5)) + + # with a block providing values + arr = @cls[1,2].fill(4..6) {|i| 100 + i } + assert_equal(@cls[1, 2, nil, nil, 104, 105, 106], arr) end From holmberg at rubyforge.org Mon Jul 18 12:34:46 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Mon Jul 18 12:34:46 2005 Subject: [Rubytests-commit] rubicon/builtin TestTime.rb Message-ID: <200507181634.j6IGYkcR021802@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv21684/builtin Modified Files: TestTime.rb Log Message: More tests of Time#<=> to improve the code coverage of the tests: test that the microseconds matter, and that a non-Time argument gives nil. Index: TestTime.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestTime.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TestTime.rb 8 Jul 2005 15:15:44 -0000 1.11 --- TestTime.rb 18 Jul 2005 16:34:44 -0000 1.12 *************** *** 532,535 **** --- 532,548 ---- end end + + # microsecond diffs + assert_equal( 1, Time.at(10_000, 500_000) <=> Time.at(10_000, 499_999)) + assert_equal( 0, Time.at(10_000, 500_000) <=> Time.at(10_000, 500_000)) + assert_equal(-1, Time.at(10_000, 500_000) <=> Time.at(10_000, 500_001)) + + # second diff & microsecond diffs + assert_equal(-1, Time.at(10_000, 500_000) <=> Time.at(10_001, 499_999)) + assert_equal(-1, Time.at(10_000, 500_000) <=> Time.at(10_001, 500_000)) + assert_equal(-1, Time.at(10_000, 500_000) <=> Time.at(10_001, 500_001)) + + # non-Time object gives nil + assert_nil(Time.at(10_000) <=> Object.new) end From holmberg at rubyforge.org Thu Jul 21 03:03:47 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Thu Jul 21 03:03:49 2005 Subject: [Rubytests-commit] rubicon/builtin TestFile.rb Message-ID: <200507210703.j6L73lcR012941@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv12727/builtin Modified Files: TestFile.rb Log Message: Added test methods for File.fnmatch and File.fnmatch?. Most of the assertions are taken from the examples in the RDOC comments in the C-Ruby source, but also added tests for [...] and FNM_CASEFOLD and some other refinements. Index: TestFile.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestFile.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TestFile.rb 8 Jun 2005 02:26:38 -0000 1.7 --- TestFile.rb 21 Jul 2005 07:03:45 -0000 1.8 *************** *** 185,188 **** --- 185,254 ---- end + def generic_test_s_fnmatch(method) + assert_equal(true, File.send(method, 'cat', 'cat')) + assert_equal(false, File.send(method, 'cat', 'category')) + assert_equal(false, File.send(method, 'c{at,ub}s', 'cats')) + assert_equal(false, File.send(method, 'c{at,ub}s', 'cubs')) + assert_equal(false, File.send(method, 'c{at,ub}s', 'cat')) + + assert_equal(true, File.send(method, 'c?t', 'cat')) + assert_equal(false, File.send(method, 'c\?t', 'cat')) + assert_equal(false, File.send(method, 'c??t', 'cat')) + assert_equal(true, File.send(method, 'c*', 'cats')) + assert_equal(true, File.send(method, '*s', 'cats')) + assert_equal(false, File.send(method, '*x*', 'cats')) + + assert_equal(false, File.send(method, 'c/**/x', 'c/a/b/c/t')) + assert_equal(true, File.send(method, 'c/**/t', 'c/a/b/c/t')) + assert_equal(true, File.send(method, 'c/*/t', 'c/a/b/c/t')) + assert_equal(false, File.send(method, 'c/*/t', 'c/a/b/c/t', + File::FNM_PATHNAME)) + + assert_equal(true, File.send(method, 'c*t', 'cat')) + assert_equal(true, File.send(method, 'c\at', 'cat')) + assert_equal(false, File.send(method, 'c\at', 'cat', File::FNM_NOESCAPE)) + assert_equal(true, File.send(method, 'a?b', 'a/b')) + assert_equal(false, File.send(method, 'a?b', 'a/b', File::FNM_PATHNAME)) + + assert_equal(false, File.send(method, '*', '.profile')) + assert_equal(true, File.send(method, '*', '.profile', File::FNM_DOTMATCH)) + assert_equal(true, File.send(method, '*', 'dave/.profile')) + assert_equal(true, File.send(method, '*', 'dave/.profile', + File::FNM_DOTMATCH)) + assert_equal(false, File.send(method, '*', 'dave/.profile', + File::FNM_PATHNAME)) + assert_equal(false, File.send(method, '*/*', 'dave/.profile', + File::FNM_PATHNAME)) + strict = File::FNM_PATHNAME | File::FNM_DOTMATCH + assert_equal(true, File.send(method, '*/*', 'dave/.profile', strict)) + + assert_equal(false, File.send(method, 'cat', 'CAt')) + assert_equal(true, File.send(method, 'cat', 'CAt', File::FNM_CASEFOLD)) + + assert_equal(true, File.send(method, 'c[au]t', 'cat')) + assert_equal(true, File.send(method, 'c[au]t', 'cut')) + assert_equal(false, File.send(method, 'c[au]t', 'cot')) + + assert_equal(false, File.send(method, 'c[^au]t', 'cat')) + assert_equal(false, File.send(method, 'c[^au]t', 'cut')) + assert_equal(true, File.send(method, 'c[^au]t', 'cot')) + + for ch in "a".."z" + inside = ch >= "h" && ch <= "p" || ch == "x" + str = "c#{ch}t" + comment = "matching #{str.inspect}" + assert_equal(inside, File.send(method, 'c[h-px]t', str), comment) + assert_equal(!inside, File.send(method, 'c[^h-px]t', str), comment) + end + end + + def test_s_fnmatch + generic_test_s_fnmatch(:fnmatch) + end + + def test_s_fnmatch? + generic_test_s_fnmatch(:fnmatch?) + end + def test_s_ftype Dir.chdir("_test") From holmberg at rubyforge.org Thu Jul 21 03:07:35 2005 From: holmberg at rubyforge.org (holmberg@rubyforge.org) Date: Thu Jul 21 03:07:35 2005 Subject: [Rubytests-commit] rubicon/builtin TestFile.rb Message-ID: <200507210707.j6L77ZcR013517@rubyforge.org> Update of /var/cvs/rubytests/rubicon/builtin In directory rubyforge.org:/tmp/cvs-serv13462/builtin Modified Files: TestFile.rb Log Message: Added test method for File.extname. Index: TestFile.rb =================================================================== RCS file: /var/cvs/rubytests/rubicon/builtin/TestFile.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TestFile.rb 21 Jul 2005 07:03:45 -0000 1.8 --- TestFile.rb 21 Jul 2005 07:07:32 -0000 1.9 *************** *** 185,188 **** --- 185,202 ---- end + def test_extname + assert_equal(".c", File.extname("alpha.c")) + assert_equal("", File.extname("beta")) + assert_equal("", File.extname(".gamma")) + assert_equal(".", File.extname("delta.")) + + assert_equal(".c", File.extname("some/dir/alpha.c")) + assert_equal("", File.extname("some/dir/beta")) + assert_equal("", File.extname("some/dir/.gamma")) + assert_equal(".", File.extname("some/dir/delta.")) + + assert_equal(".e", File.extname("a.b.c.d.e")) + end + def generic_test_s_fnmatch(method) assert_equal(true, File.send(method, 'cat', 'cat'))