test/grammar_test.rb in toml-rb-0.3.6 vs test/grammar_test.rb in toml-rb-0.3.7
- old
+ new
@@ -1,9 +1,9 @@
# encoding: utf-8
require_relative 'helper'
-class GrammarTest < Test::Unit::TestCase
+class GrammarTest < Minitest::Test
def test_comment
match = TOML::Document.parse(' # A comment', root: :comment)
assert_equal(nil, match.value)
end
@@ -28,13 +28,17 @@
match = TOML::Document.parse('["owner.emancu"]', root: :keygroup)
assert_equal(%w(owner.emancu),
match.value.instance_variable_get('@nested_keys'))
- match = TOML::Document.parse('[ owner . emancu ]', root: :keygroup)
- assert_equal(%w(owner emancu),
+ match = TOML::Document.parse('["first key"."second key"]', root: :keygroup)
+ assert_equal(['first key', 'second key'],
match.value.instance_variable_get('@nested_keys'))
+
+ assert_raises Citrus::ParseError do
+ TOML::Document.parse('[ owner . emancu ]', root: :keygroup)
+ end
end
def test_keyvalue
indentation_alternatives_for('key = "value"') do |str|
match = TOML::Document.parse(str, root: :keyvalue)
@@ -62,10 +66,17 @@
match = TOML::Document.parse(to_parse, root: :multiline_string)
assert_equal "One Two", match.value
end
+ def test_empty_multiline_string
+ to_parse = '""""""'
+
+ match = TOML::Document.parse(to_parse, root: :multiline_string)
+ assert_equal '', match.value
+ end
+
def test_special_characters
match = TOML::Document.parse('"\0 \" \t \n \r"', root: :string)
assert_equal("\0 \" \t \n \r", match.value)
match = TOML::Document.parse('"C:\\Documents\\virus.exe"', root: :string)
@@ -144,10 +155,10 @@
match = TOML::Document.parse('[ ["hey", "TOML"], [2,4] ]', root: :array)
assert_equal([%w(hey TOML), [2, 4]], match.value)
match = TOML::Document.parse('[ { one = 1 }, { two = 2, three = 3} ]',
- root: :inline_table_array)
+ 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