Permalink
Browse files

parse whitespace only code (including newlines) correctly and eval it…

… to nil
  • Loading branch information...
1 parent 867edcc commit bec9b939dfdec71ef79c3f0c6ee1fd6285bc1325 @bakkdoor committed Dec 1, 2012
Showing with 11 additions and 1 deletion.
  1. +1 −0 boot/rbx-compiler/parser/parser.y
  2. +1 −0 lib/parser/ext/parser.y
  3. +9 −1 tests/string.fy
@@ -152,6 +152,7 @@ extern char *yytext;
%%
programm: /*empty*/
+ | nls
| expression_list {
rb_funcall(self, rb_intern("body="), 1, $1);
}
View
@@ -161,6 +161,7 @@ extern char *yytext;
%%
programm: /*empty*/
+ | nls
| expression_list {
rb_funcall(self, rb_intern("body:"), 1, $1);
}
View
@@ -89,14 +89,22 @@ FancySpec describe: String with: {
"hello world" at: 5 . blank? is: true
}
- it: "is evaluated as fancy code and returns the correct value" when: {
+ it: "is evaluated as fancy code and returns the correct value" with: 'eval when: {
x = "'foo" eval
x is: 'foo
"3 + 4" eval is: 7
"'foo to_s uppercase" eval is: "FOO"
"33.33" eval is: 33.33
}
+ it: "parses empty code with newlines correctly" with: 'eval when: {
+ "" eval is: nil
+ "\n" eval is: nil
+ "\n\n" eval is: nil
+ "\n \n \n" eval is: nil
+ " \n " eval is: nil
+ }
+
it: "returns itself times n" with: '* when: {
"foo" * 2 is: "foofoo"
"f" ++ ("o" * 2) ++ "bar" is: "foobar"

0 comments on commit bec9b93

Please sign in to comment.