不在ruby测试/单位断言中

Rom*_*om1 2 ruby

这不符合我的预期:

class FooTest < Test::Unit::TestCase
   def test_foo
      assert(not true)
   end
end
Run Code Online (Sandbox Code Playgroud)

我期待测试失败,而不是我得到:

SyntaxError: ./test.rb:10: syntax error, unexpected kNOT
assert(not true)
Run Code Online (Sandbox Code Playgroud)

解释吗?

Jör*_*tag 7

为什么你得到一个语法错误的原因是,好,因为它是一个语法错误:and,or并且not在参数列表是不允许的.

在ruby-talk邮件列表上对此进行了长时间的讨论,其中详细解释了为什么会这样,但我的解释基本上是"我们无法弄清楚如何进行yacc并切换到更好的解析器生成器工作太多了,所以我们决定把它变成非法的".