From d2250a0bbb5538c0d826fcb1a0ba87b3f033cbb7 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Tue, 11 Oct 2016 11:40:48 -0700 Subject: [PATCH 1/2] Include the topic in some common parser errors --- src/parser.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parser.coffee b/src/parser.coffee index 9c919f7..6ad15d4 100644 --- a/src/parser.coffee +++ b/src/parser.coffee @@ -160,7 +160,7 @@ class Parser # Separate the command from the data if line.length < 2 - @warn "Weird single-character line '#{line}' found.", filename, lineno + @warn "Weird single-character line '#{line}' found (in topic #{topic})", filename, lineno continue cmd = line.substring 0, 1 line = utils.strip(line.substring(1)) @@ -182,7 +182,7 @@ class Parser #{filename} line #{lineno} near #{cmd} #{line}" else @warn "Syntax error: #{syntaxError} at #{filename} line #{lineno} - near #{cmd} #{line}" + near #{cmd} #{line} (in topic #{topic})" # Reset the %Previous state if this is a new +Trigger. if cmd is "+" @@ -455,7 +455,7 @@ class Parser curTrig.redirect = utils.strip line else - @warn "Unknown command '#{cmd}'", filename, lineno + @warn "Unknown command '#{cmd}' (in topic #{topic})", filename, lineno return ast From 23374227d2075e94e74cf8e255db47f6457f3ae9 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Tue, 11 Oct 2016 11:46:51 -0700 Subject: [PATCH 2/2] Fix unit tests for including topics in errors --- test/test-triggers.coffee | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/test-triggers.coffee b/test/test-triggers.coffee index 19da873..36a4860 100644 --- a/test/test-triggers.coffee +++ b/test/test-triggers.coffee @@ -158,9 +158,9 @@ exports.test_weighted_triggers = (test) -> exports.test_empty_piped_arrays = (test) -> errors = [] expected_errors = [ - 'Syntax error: Piped arrays can\'t begin or end with a | at stream() line 1 near ! array hello = hi|hey|sup|yo|' - 'Syntax error: Piped arrays can\'t begin or end with a | at stream() line 2 near ! array something = |something|some thing' - 'Syntax error: Piped arrays can\'t include blank entries at stream() line 3 near ! array nothing = nothing||not a thing' + 'Syntax error: Piped arrays can\'t begin or end with a | at stream() line 1 near ! array hello = hi|hey|sup|yo| (in topic random)' + 'Syntax error: Piped arrays can\'t begin or end with a | at stream() line 2 near ! array something = |something|some thing (in topic random)' + 'Syntax error: Piped arrays can\'t include blank entries at stream() line 3 near ! array nothing = nothing||not a thing (in topic random)' ] console.error = (text)-> @@ -191,9 +191,9 @@ exports.test_empty_piped_arrays = (test) -> exports.test_empty_piped_alternations = (test) -> errors = [] expected_errors = [ - 'Syntax error: Piped alternations can\'t begin or end with a | at stream() line 1 near + [*] (hi|hey|sup|yo|) [*]' - 'Syntax error: Piped alternations can\'t begin or end with a | at stream() line 4 near + [*] (|good|great|nice) [*]' - 'Syntax error: Piped alternations can\'t include blank entries at stream() line 7 near + [*] (mild|warm||hot) [*]' + 'Syntax error: Piped alternations can\'t begin or end with a | at stream() line 1 near + [*] (hi|hey|sup|yo|) [*] (in topic random)' + 'Syntax error: Piped alternations can\'t begin or end with a | at stream() line 4 near + [*] (|good|great|nice) [*] (in topic random)' + 'Syntax error: Piped alternations can\'t include blank entries at stream() line 7 near + [*] (mild|warm||hot) [*] (in topic random)' ] console.error = (text)-> @@ -230,9 +230,9 @@ exports.test_empty_piped_alternations = (test) -> exports.test_empty_piped_optionals = (test) -> errors = [] expected_errors = [ - 'Syntax error: Piped optionals can\'t begin or end with a | at stream() line 1 near + bot [*] [hi|hey|sup|yo|] [*] to me' - 'Syntax error: Piped optionals can\'t begin or end with a | at stream() line 4 near + dog [*] [|good|great|nice] [*] to me' - 'Syntax error: Piped optionals can\'t include blank entries at stream() line 7 near + cat [*] [mild|warm||hot] [*] to me' + 'Syntax error: Piped optionals can\'t begin or end with a | at stream() line 1 near + bot [*] [hi|hey|sup|yo|] [*] to me (in topic random)' + 'Syntax error: Piped optionals can\'t begin or end with a | at stream() line 4 near + dog [*] [|good|great|nice] [*] to me (in topic random)' + 'Syntax error: Piped optionals can\'t include blank entries at stream() line 7 near + cat [*] [mild|warm||hot] [*] to me (in topic random)' ] console.error = (text)-> @@ -267,7 +267,7 @@ exports.test_empty_piped_optionals = (test) -> exports.test_empty_piped_missing_arrays = (test) -> - # Test case where an array reference is missing, and check that + # Test case where an array reference is missing, and check that # compiled regexp does not render as accidental wildcard of `||` bot = new TestCase(test, """ ! array test1 = hi|hey|sup|yo