From d7eed087745e967a05863f602d8495930a7babf3 Mon Sep 17 00:00:00 2001 From: Lukas Werling Date: Sat, 30 May 2015 22:17:12 +0200 Subject: [PATCH] Add some tests with invalid trailing commas --- test/language/list/trailing_comma.wren | 5 +++++ test/language/map/trailing_comma.wren | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/test/language/list/trailing_comma.wren b/test/language/list/trailing_comma.wren index a9995607..67fcdba7 100644 --- a/test/language/list/trailing_comma.wren +++ b/test/language/list/trailing_comma.wren @@ -5,3 +5,8 @@ var list = [ IO.print(list[0]) // expect: a IO.print(list[1]) // expect: b + +// Invalid syntax +IO.print(new Fiber { Meta.eval("[,]") }.try()) // expect: Could not compile source code. +IO.print(new Fiber { Meta.eval("[1,,]") }.try()) // expect: Could not compile source code. +IO.print(new Fiber { Meta.eval("[1,,2]") }.try()) // expect: Could not compile source code. diff --git a/test/language/map/trailing_comma.wren b/test/language/map/trailing_comma.wren index 7dd0a69f..6026d2c1 100644 --- a/test/language/map/trailing_comma.wren +++ b/test/language/map/trailing_comma.wren @@ -5,3 +5,9 @@ var map = { IO.print(map["a"]) // expect: 1 IO.print(map["b"]) // expect: 2 + +// Invalid syntax +// Parentheses are necessary to have these interpret as maps and not as blocks. +IO.print(new Fiber { Meta.eval("({,})") }.try()) // expect: Could not compile source code. +IO.print(new Fiber { Meta.eval("({1:1,,})") }.try()) // expect: Could not compile source code. +IO.print(new Fiber { Meta.eval("({1:1,,2:2})") }.try()) // expect: Could not compile source code.