mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 19:34:27 -05:00
adding and fixing test for empty strings
This commit is contained in:
2
test/fixtures/execution/test_splices.coffee
vendored
2
test/fixtures/execution/test_splices.coffee
vendored
@@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
array: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
array: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||||
|
|
||||||
array[5..10]: [0, 0, 0]
|
array[5..10]: [0, 0, 0]
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ class LexerTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_lexing_an_empty_string
|
def test_lexing_an_empty_string
|
||||||
assert @lex.tokenize("") == [["\n", "\n"]]
|
assert @lex.tokenize("") == []
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_lexing_basic_assignment
|
def test_lexing_basic_assignment
|
||||||
code = "a: 'one'\nb: [1, 2]"
|
code = "a: 'one'\nb: [1, 2]"
|
||||||
assert @lex.tokenize(code) == [[:IDENTIFIER, "a"], [:ASSIGN, ":"],
|
assert @lex.tokenize(code) == [[:IDENTIFIER, "a"], [:ASSIGN, ":"],
|
||||||
[:STRING, "'one'"], ["\n", "\n"], [:IDENTIFIER, "b"], [:ASSIGN, ":"],
|
[:STRING, "'one'"], ["\n", "\n"], [:IDENTIFIER, "b"], [:ASSIGN, ":"],
|
||||||
["[", "["], [:NUMBER, "1"], [",", ","], [:NUMBER, "2"], ["]", "]"],
|
["[", "["], [:NUMBER, "1"], [",", ","], [:NUMBER, "2"], ["]", "]"],
|
||||||
["\n", "\n"]]
|
["\n", "\n"]]
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ class LexerTest < Test::Unit::TestCase
|
|||||||
def test_lexing_function_definition
|
def test_lexing_function_definition
|
||||||
code = "x, y => x * y"
|
code = "x, y => x * y"
|
||||||
assert @lex.tokenize(code) == [[:PARAM, "x"], [",", ","], [:PARAM, "y"],
|
assert @lex.tokenize(code) == [[:PARAM, "x"], [",", ","], [:PARAM, "y"],
|
||||||
["=>", "=>"], [:INDENT, 2], [:IDENTIFIER, "x"], ["*", "*"],
|
["=>", "=>"], [:INDENT, 2], [:IDENTIFIER, "x"], ["*", "*"],
|
||||||
[:IDENTIFIER, "y"], [:OUTDENT, 2], ["\n", "\n"]]
|
[:IDENTIFIER, "y"], [:OUTDENT, 2], ["\n", "\n"]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user