Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #16 from lateau/lateau

Patch for issue #6
  • Loading branch information...
commit f48c28b77678bbf2828c8413f33a8d93a5dd4155 2 parents 3f1ad53 + b1af3d9
@leto leto authored
Showing with 85 additions and 10 deletions.
  1. +4 −1 src/parser/grammar.pg
  2. +81 −9 t/01-stmts.t
View
5 src/parser/grammar.pg
@@ -61,7 +61,10 @@ rule alias {
}
token stmt {
- <basic_stmt> <.ws> <stmt_mod>*
+ [
+ | '(' \s*\n* <basic_stmt> <.ws> <stmt_mod>* \s*\n* ')' # NOTE: this change is not allows '(- 1)'
+ | <basic_stmt> <.ws> <stmt_mod>*
+ ]
{*}
}
View
90 t/01-stmts.t
@@ -1,6 +1,6 @@
# If this is to test the basic statements then we can't really use Test.rb
# Although of course Test.rb itself contains all the statements tested
-puts "1..12"
+puts "1..30"
if 1 then
puts "ok 1"
@@ -55,22 +55,94 @@ else
puts "not ok 8 # an empty string '' should evaluate to true - Issue 28"
end
-# test parrentheses ()
-if (1)
+# the statements enclosed by parentheses '()'
+(if 1
puts "ok 9"
+end)
+
+( if 1
+ puts "ok 10"
+end )
+
+(
+ if 1
+ puts "ok 11"
+ end
+)
+
+if (1)
+ puts "ok 12"
else
- puts "not ok 9"
+ puts "not ok 13"
end
if (-1)
- puts "ok 10"
+ puts "ok 14"
else
- puts "not ok 10"
+ puts "not ok 14"
end
-(-1.0)
-puts "ok 11"
+# the literals(objects) enclosed by parentheses '()'
+(1)
+puts "ok 15"
(-1)
-puts "ok 12"
+puts "ok 16"
+
+# failed
+#(- 1)
+puts "not ok 17"
+
+# failed
+(
+-
+1
+)
+puts "ok 18"
+
+# failed
+(
+-
+ 1
+)
+puts "ok 19"
+
+# failed
+( - 1 )
+puts "ok 20"
+(1.0)
+puts "ok 21"
+
+([])
+puts "ok 22"
+
+# failed
+(%W(a b c))
+puts "ok 23"
+
+({})
+puts "ok 24"
+
+# failed
+(//)
+puts "ok 25"
+
+("")
+puts "ok 26"
+
+# failed
+(%Q())
+puts "ok 27"
+
+(true)
+puts "ok 28"
+
+(false)
+puts "ok 29"
+
+(true)
+puts "ok 30"
+
+(-1.0)
+puts "ok 31"
Please sign in to comment.
Something went wrong with that request. Please try again.