diff options
Diffstat (limited to 'basictest')
| -rwxr-xr-x | basictest/test.rb | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/basictest/test.rb b/basictest/test.rb index 25d52ca1ef..711e4f4ab3 100755 --- a/basictest/test.rb +++ b/basictest/test.rb @@ -35,7 +35,7 @@ class Progress # dircolors-like style colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {} begin - File.read(File.join(__dir__, "../test/colors")).scan(/(\w+)=([^:\n]*)/) do |n, c| + File.read(File.join(__dir__, "../tool/colors")).scan(/(\w+)=([^:\n]*)/) do |n, c| colors[n] ||= c end rescue @@ -879,7 +879,7 @@ $x.sort!{|a,b| b-a} # reverse sort test_ok($x == [7,5,3,2,1]) # split test -$x = "The Book of Mormon" +$x = +"The Book of Mormon" test_ok($x.split(//).reverse!.join == $x.reverse) test_ok($x.reverse == $x.reverse!) test_ok("1 byte string".split(//).reverse.join(":") == "g:n:i:r:t:s: :e:t:y:b: :1") @@ -984,13 +984,6 @@ test_ok($z == 0) test_check "iterator" -test_ok(!iterator?) - -def ttt - test_ok(iterator?) -end -ttt{} - # yield at top level test_ok(!defined?(yield)) @@ -1432,9 +1425,6 @@ marity_test(:test_ok) marity_test(:marity_test) marity_test(:p) -lambda(&method(:test_ok)).call(true) -lambda(&block_get{|a,n| test_ok(a,n)}).call(true, 2) - class ITER_TEST1 def a block_given? @@ -1653,7 +1643,7 @@ test_ok(/^(?:ab+)+/ =~ "ababb" && $& == "ababb") test_ok(/(\s+\d+){2}/ =~ " 1 2" && $& == " 1 2") test_ok(/(?:\s+\d+){2}/ =~ " 1 2" && $& == " 1 2") -$x = <<END; +$x = +<<END; ABCD ABCD END @@ -1692,12 +1682,12 @@ test_ok(?a == ?a) test_ok(?\C-a == "\1") test_ok(?\M-a == "\341") test_ok(?\M-\C-a == "\201") -test_ok("a".upcase![0] == ?A) -test_ok("A".downcase![0] == ?a) -test_ok("abc".tr!("a-z", "A-Z") == "ABC") -test_ok("aabbcccc".tr_s!("a-z", "A-Z") == "ABC") -test_ok("abcc".squeeze!("a-z") == "abc") -test_ok("abcd".delete!("bc") == "ad") +test_ok("a".dup.upcase![0] == ?A) +test_ok("A".dup.downcase![0] == ?a) +test_ok("abc".dup.tr!("a-z", "A-Z") == "ABC") +test_ok("aabbcccc".dup.tr_s!("a-z", "A-Z") == "ABC") +test_ok("abcc".dup.squeeze!("a-z") == "abc") +test_ok("abcd".dup.delete!("bc") == "ad") $x = "abcdef" $y = [ ?a, ?b, ?c, ?d, ?e, ?f ] @@ -1710,7 +1700,7 @@ $x.each_byte {|i| } test_ok(!$bad) -s = "a string" +s = +"a string" s[0..s.size]="another string" test_ok(s == "another string") @@ -1739,7 +1729,7 @@ a = nil test_ok(defined?(a)) test_ok(a == nil) -# multiple asignment +# multiple assignment a, b = 1, 2 test_ok(a == 1 && b == 2) @@ -1970,6 +1960,8 @@ test_ok(p1.call == 5) test_ok(i7 == nil) end +# WASI doesn't support spawning a new process for now. +unless /wasi/ =~ RUBY_PLATFORM test_check "system" test_ok(`echo foobar` == "foobar\n") test_ok(`./miniruby -e 'print "foobar"'` == 'foobar') @@ -2020,6 +2012,7 @@ test_ok(done) File.unlink script_tmp or `/bin/rm -f "#{script_tmp}"` File.unlink "#{script_tmp}.bak" or `/bin/rm -f "#{script_tmp}.bak"` +end # not /wasi/ =~ RUBY_PLATFORM test_check "const" TEST1 = 1 @@ -2147,7 +2140,7 @@ $_ = foobar test_ok($_ == foobar) class Gods - @@rule = "Uranus" # private to Gods + @@rule = "Uranus" def ruler0 @@rule end @@ -2170,7 +2163,7 @@ module Olympians end class Titans < Gods - @@rule = "Cronus" # do not affect @@rule in Gods + @@rule = "Cronus" # modifies @@rule in Gods include Olympians def ruler4 @@rule @@ -2185,7 +2178,14 @@ test_ok(Titans.ruler2 == "Cronus") atlas = Titans.new test_ok(atlas.ruler0 == "Cronus") test_ok(atlas.ruler3 == "Zeus") -test_ok(atlas.ruler4 == "Cronus") +begin + atlas.ruler4 +rescue RuntimeError => e + test_ok(e.message.include?("class variable @@rule of Olympians is overtaken by Gods")) +else + test_ok(false) +end +test_ok(atlas.ruler3 == "Zeus") test_check "trace" $x = 1234 |
