Skip to content

Commit

Permalink
adding and fixing test for empty strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Jan 12, 2010
1 parent 27f7ef0 commit c19647a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions test/fixtures/execution/test_splices.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


array: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

array[5..10]: [0, 0, 0]
Expand Down
10 changes: 5 additions & 5 deletions test/unit/test_lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ def setup
end

def test_lexing_an_empty_string
assert @lex.tokenize("") == [["\n", "\n"]]
assert @lex.tokenize("") == []
end

def test_lexing_basic_assignment
code = "a: 'one'\nb: [1, 2]"
assert @lex.tokenize(code) == [[:IDENTIFIER, "a"], [:ASSIGN, ":"],
[:STRING, "'one'"], ["\n", "\n"], [:IDENTIFIER, "b"], [:ASSIGN, ":"],
["[", "["], [:NUMBER, "1"], [",", ","], [:NUMBER, "2"], ["]", "]"],
assert @lex.tokenize(code) == [[:IDENTIFIER, "a"], [:ASSIGN, ":"],
[:STRING, "'one'"], ["\n", "\n"], [:IDENTIFIER, "b"], [:ASSIGN, ":"],
["[", "["], [:NUMBER, "1"], [",", ","], [:NUMBER, "2"], ["]", "]"],
["\n", "\n"]]
end

Expand All @@ -27,7 +27,7 @@ def test_lexing_object_literal
def test_lexing_function_definition
code = "x, y => x * y"
assert @lex.tokenize(code) == [[:PARAM, "x"], [",", ","], [:PARAM, "y"],
["=>", "=>"], [:INDENT, 2], [:IDENTIFIER, "x"], ["*", "*"],
["=>", "=>"], [:INDENT, 2], [:IDENTIFIER, "x"], ["*", "*"],
[:IDENTIFIER, "y"], [:OUTDENT, 2], ["\n", "\n"]]
end

Expand Down

0 comments on commit c19647a

Please sign in to comment.