test/grammar_test.rb in toml-rb-0.3.4 vs test/grammar_test.rb in toml-rb-0.3.5
- old
+ new
@@ -144,15 +144,20 @@
match = Document.parse('[ ["hey", "TOML"], [2,4] ]', root: :array)
assert_equal([%w(hey TOML), [2, 4]], match.value)
match = Document.parse('[ { one = 1 }, { two = 2, three = 3} ]',
- root: :inline_table_array).value
-
+ root: :inline_table_array)
assert_equal([{ 'one' => 1 }, { 'two' => 2, 'three' => 3 }], match.value)
end
+ def test_empty_array
+ # test that [] is parsed as array and not as inline table array
+ match = Document.parse("a = []", root: :keyvalue).value
+ assert_equal [], match.value
+ end
+
def test_multiline_array
multiline_array = "[ \"hey\",\n \"ho\",\n\t \"lets\", \"go\",\n ]"
match = Document.parse(multiline_array, root: :array)
assert_equal(%w(hey ho lets go), match.value)
@@ -162,14 +167,14 @@
multiline_array = "[\n# comment\n#, more comments\n4]"
match = Document.parse(multiline_array, root: :array)
assert_equal([4], match.value)
- multiline_array = "[\n 1,\n # 2,\n 3,\n]"
+ multiline_array = "[\n 1,\n # 2,\n 3 ,\n]"
match = Document.parse(multiline_array, root: :array)
assert_equal([1, 3], match.value)
- multiline_array = "[\n 1, # useless comment\n # 2,\n 3 #other comment\n]"
+ multiline_array = "[\n 1 , # useless comment\n # 2,\n 3 #other comment\n]"
match = Document.parse(multiline_array, root: :array)
assert_equal([1, 3], match.value)
end
def test_datetime