From dbed49c2cecaf1e4412d895a59785f6dd589fd1c Mon Sep 17 00:00:00 2001 From: Darwin Corn Date: Tue, 13 Nov 2018 16:51:45 -0800 Subject: [PATCH] Add tests for nested lists Plus a half finished implementation. --- src/hcl/parser.py | 1 + tests/lex-fixtures/list_of_lists.hcl | 2 ++ tests/test_lexer.py | 10 ++++++++++ tests/test_parser.py | 4 ++++ 4 files changed, 17 insertions(+) create mode 100644 tests/lex-fixtures/list_of_lists.hcl diff --git a/src/hcl/parser.py b/src/hcl/parser.py index 50b41fd..c0d08f4 100644 --- a/src/hcl/parser.py +++ b/src/hcl/parser.py @@ -223,6 +223,7 @@ def p_listitem(self, p): ''' listitem : number | object + | list | STRING ''' if DEBUG: diff --git a/tests/lex-fixtures/list_of_lists.hcl b/tests/lex-fixtures/list_of_lists.hcl new file mode 100644 index 0000000..8af3458 --- /dev/null +++ b/tests/lex-fixtures/list_of_lists.hcl @@ -0,0 +1,2 @@ +foo = [["foo"], ["bar"]] + diff --git a/tests/test_lexer.py b/tests/test_lexer.py index 6242188..a9597e0 100644 --- a/tests/test_lexer.py +++ b/tests/test_lexer.py @@ -50,6 +50,16 @@ class Error: "COMMA", "RIGHTBRACKET", None, ], ), + ( + "list_of_lists.hcl", + [ + "IDENTIFIER", "EQUAL", "LEFTBRACKET", + "LEFTBRACKET", "STRING", "RIGHTBRACKET", + "COMMA", + "LEFTBRACKET", "STRING", "RIGHTBRACKET", + "RIGHTBRACKET", None, + ], + ), ( "list_of_maps.hcl", [ diff --git a/tests/test_parser.py b/tests/test_parser.py index 56e3b71..fd96262 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -24,6 +24,10 @@ "list_comma.hcl", False, ), + ( + "list_of_lists.hcl", + False, + ), ( "list_of_maps.hcl", False,