diff options
Diffstat (limited to 'yamlesque/test/src/NegTest.scala')
-rw-r--r-- | yamlesque/test/src/NegTest.scala | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/yamlesque/test/src/NegTest.scala b/yamlesque/test/src/NegTest.scala new file mode 100644 index 0000000..627ef0d --- /dev/null +++ b/yamlesque/test/src/NegTest.scala @@ -0,0 +1,96 @@ +package yamlesque + +import utest._ + +object NegTest extends TestSuite { + def tests = Tests { + "key and string" - { + val e = intercept[Parser.ParseException] { + read("""|b: + |a + |""".stripMargin) + } + assert(e.message.contains("expected")) + } + "list and key" - { + val e = intercept[Parser.ParseException] { + read("""|- b: + |a: + |""".stripMargin) + } + assert(e.message.contains("expected")) + } + "list and string" - { + val e = intercept[Parser.ParseException] { + read("""|- + |a + |""".stripMargin) + } + assert(e.message.contains("expected")) + } + "list and key" - { + val e = intercept[Parser.ParseException] { + read("""|- + |a: + |""".stripMargin) + } + assert(e.message.contains("expected")) + } + "key alignment" - { + val e = intercept[Parser.ParseException] { + read("""|a: + | a: + | b: + |""".stripMargin) + } + assert(e.message.contains("aligned")) + } + "list alignment" - { + val e = intercept[Parser.ParseException] { + read("""|- + | - + | - + |""".stripMargin) + } + assert(e.message.contains("aligned")) + } + "verbatim end" - { + val e = intercept[Parser.ParseException] { + read("""|a: | + | foo + | b # b is parsed as a scalar + |""".stripMargin) + } + assert(e.message.contains("expected")) + } + "verbatim before last token" - { + val e = intercept[Parser.ParseException] { + read("""|a: + | a: | + | b + |""".stripMargin) + + } + assert(e.message.contains("expected")) + } + "verbatim before last token 2" - { + val e = intercept[Parser.ParseException] { + read("""|a: + | a: + | a: | + | b: + |""".stripMargin) + } + assert(e.message.contains("aligned")) + } + "verbatim followed by scalar" - { + val e = intercept[Parser.ParseException] { + read("""|| + | a + |a + |""".stripMargin) + } + assert(e.message.contains("expected")) + } + } +} |