Permalink
Browse files

test/ruby/test_syntax.rb: tests for keyword not

* test/ruby/test_syntax.rb (TestSyntax#test_keyword_not): tests for
  keyword not.
  • Loading branch information...
1 parent dfdf256 commit eb8b6973df01618ca9b1881e6b94e947eb8b32fd @nobu committed May 20, 2012
Showing with 16 additions and 0 deletions.
  1. +7 −0 test/ruby/envutil.rb
  2. +9 −0 test/ruby/test_syntax.rb
View
7 test/ruby/envutil.rb
@@ -190,6 +190,13 @@ def assert_warning(*args)
assert_warn(*args) {$VERBOSE = false; yield}
end
+ def assert_quiet(*args)
+ stderr = EnvUtil.verbose_warning { yield }
+ message = ' "' + message + '"' if message
+ msg = proc {"warning message #{stderr.inspect} is not expected#{message}"}
+ assert(stderr.empty?, msg)
+ end
+
def assert_no_memory_leak(args, prepare, code, message=nil, limit: 1.5)
token = "\e[7;1m#{$$.to_s}:#{Time.now.strftime('%s.%L')}:#{rand(0x10000).to_s(16)}:\e[m"
token_dump = token.dump
View
9 test/ruby/test_syntax.rb
@@ -181,6 +181,15 @@ def test_reserved_method_no_args
assert_valid_syntax("def self; :foo; end", __FILE__, bug6403)
end
+ def test_keyword_not
+ assert_quiet do
+ ['false || not(true)', 'not(true)', 'not (true)', 'not[]', 'not []'].each do |code|
+ assert_valid_syntax(code, __FILE__, verbose: true)
+ assert_valid_syntax("p(#{code})", __FILE__, verbose: true)
+ end
+ end
+ end
+
private
def not_label(x) @result = x; @not_label ||= nil end

0 comments on commit eb8b697

Please sign in to comment.