From 4fc40e4841fbcd52b412b27b2d00a7d26b6976a2 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Tue, 5 Jan 2010 23:29:43 -0500 Subject: [PATCH] adding the 'in' operator --- lib/coffee_script/grammar.y | 1 + test/fixtures/execution/test_array_comprehension.coffee | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/coffee_script/grammar.y b/lib/coffee_script/grammar.y index aa0a7caa..885e7562 100644 --- a/lib/coffee_script/grammar.y +++ b/lib/coffee_script/grammar.y @@ -183,6 +183,7 @@ rule | Expression '&&=' Expression { result = OpNode.new(val[1], val[0], val[2]) } | Expression INSTANCEOF Expression { result = OpNode.new(val[1], val[0], val[2]) } + | Expression IN Expression { result = OpNode.new(val[1], val[0], val[2]) } ; Existence: diff --git a/test/fixtures/execution/test_array_comprehension.coffee b/test/fixtures/execution/test_array_comprehension.coffee index 27d04871..5fdfe1df 100644 --- a/test/fixtures/execution/test_array_comprehension.coffee +++ b/test/fixtures/execution/test_array_comprehension.coffee @@ -19,3 +19,7 @@ evens: for num in [1, 2, 3, 4, 5, 6] when num % 2 is 0 print(evens.join(', ') is '4, 6, 8') +# Make sure that the "in" operator still works. + +print(2 in evens) +