1 require 'yarvtest/yarvtest'
4 class TestSYNTAX < YarvTestBase
7 ae %q(if true then 1 ; end)
8 ae %q(if false then 1 ; end)
9 ae %q(if true then 1 ; else; 2; end)
10 ae %q(if false then 1 ; else; 2; end)
11 ae %q(if true then ; elsif true then ; 1 ; end)
12 ae %q(if false then ; elsif true then ; 1 ; end)
14 ae %q(unless true then 1 ; end)
15 ae %q(unless false then 1 ; end)
16 ae %q(unless true then 1 ; else; 2; end)
17 ae %q(unless false then 1 ; else; 2; end)
70 ae %q(1 && 2 && 3 && 4)
71 ae %q(1 && nil && 3 && 4)
72 ae %q(1 && 2 && 3 && nil)
73 ae %q(1 && 2 && 3 && false)
75 ae %q(1 and 2 and 3 and 4)
76 ae %q(1 and nil and 3 and 4)
77 ae %q(1 and 2 and 3 and nil)
78 ae %q(1 and 2 and 3 and false)
85 ae %q(1 || 2 || 3 || 4)
86 ae %q(1 || false || 3 || 4)
87 ae %q(nil || 2 || 3 || 4)
88 ae %q(false || 2 || 3 || 4)
89 ae %q(nil || false || nil || false)
91 ae %q(1 or 2 or 3 or 4)
92 ae %q(1 or false or 3 or 4)
93 ae %q(nil or 2 or 3 or 4)
94 ae %q(false or 2 or 3 or 4)
95 ae %q(nil or false or nil or false)
376 if ib % 10 == 0 .. true
385 if ib % 10 == 0 ... true
393 unless ''.respond_to? :lines
415 if (t = l[/^Type: (.*)/, 1])..(/^\f/ =~ l)
422 def test_defined_vars
424 defined?(nil) + defined?(self) +
425 defined?(true) + defined?(false)
429 # defined?(a) # yarv returns "in block" in eval context
453 defined?(C_definedtest)
457 defined?(C_definedtest)
459 remove_const :C_definedtest
463 defined?(::C_definedtest)
467 defined?(::C_definedtest)
469 remove_const :C_definedtest
473 defined?(C_definedtestA::C_definedtestB::C_definedtestC)
481 defined?(C_definedtestA::C_definedtestB::C_definedtestC)
483 remove_const :C_definedtestA
487 def test_defined_method
507 [defined?(m1()), defined?(self.m1), defined?(C.new.m1),
508 defined?(m2()), defined?(self.m2), defined?(C.new.m2),
509 defined?(m3()), defined?(self.m3), defined?(C.new.m3)]
520 C.new.test + [defined?(C.new.m3)]
523 $ans = [defined?($1), defined?($2), defined?($3), defined?($4)]
525 $ans + [defined?($1), defined?($2), defined?($3), defined?($4)]
532 def make_perm ary, num
536 base = make_perm(ary, num-1)
548 conds = make_perm(['fv', 'tv'], 3)
549 bangs = make_perm(['', '!'], 3)
550 exprs = make_perm(['and', 'or'], 3)
551 ['if', 'unless'].each{|syn|
555 yield(syn, cs, bs, es)
566 each_test{|syn, conds, bangs, exprs|
568 bang1, bang2, bang3 = bangs
571 #{syn} #{bang1}#{c1} #{e1} #{bang2}#{c2} #{e2} #{bang3}#{c3}
579 each_test{|syn, conds, bangs, exprs|
581 bang1, bang2, bang3 = bangs
584 #{syn} #{bang1}#{c1} #{e1} #{bang2}#{c2} #{e2} #{bang3}#{c3}