From 9b0b3e4216dc8ecd9fd98922b981599edfec717f Mon Sep 17 00:00:00 2001 From: b3b00 Date: Fri, 1 Nov 2024 11:01:38 +0200 Subject: [PATCH] unit test #495 --- tests/ParserTests/Issue495/Issue495Parser.cs | 13 +++++++------ tests/ParserTests/Issue495/Issue495Tests.cs | 7 ++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/ParserTests/Issue495/Issue495Parser.cs b/tests/ParserTests/Issue495/Issue495Parser.cs index ed267f88..5c5e3acc 100644 --- a/tests/ParserTests/Issue495/Issue495Parser.cs +++ b/tests/ParserTests/Issue495/Issue495Parser.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using sly.lexer; using sly.parser.generator; @@ -13,21 +14,21 @@ public Issue495Parser() } [Production("STRING: StartQuote StringValue* EndQuote")] - public object stringValue(Token open, List> values, Token close) + public string stringValue(Token open, List> values, Token close) { - return null; + return string.Join(", ", values.Select(x => x.Value.ToString())); } [Production("statement : Identifier Assign STRING End")] - public object Statement(Token id, Token assign, object value, + public string Statement(Token id, Token assign, string value, Token end) { - return null; + return $"{id.Value}{assign.Value}{value}"; } [Production("program: statement*")] - public object Program(List statements) + public string Program(List statements) { - return null; + return string.Join("\n", statements); } } \ No newline at end of file diff --git a/tests/ParserTests/Issue495/Issue495Tests.cs b/tests/ParserTests/Issue495/Issue495Tests.cs index 3f234c72..3b4ab789 100644 --- a/tests/ParserTests/Issue495/Issue495Tests.cs +++ b/tests/ParserTests/Issue495/Issue495Tests.cs @@ -7,13 +7,13 @@ namespace ParserTests.Issue495; public class Issue495Tests { - public Parser _parser { get; set; } + public Parser _parser { get; set; } - public Parser GetParser() + public Parser GetParser() { if (_parser == null) { - ParserBuilder builder = new ParserBuilder("en"); + ParserBuilder builder = new ParserBuilder("en"); var build = builder.BuildParser(new Issue495Parser(), ParserType.EBNF_LL_RECURSIVE_DESCENT, "program"); Check.That(build).IsOk(); _parser = build.Result; @@ -29,6 +29,7 @@ public void TestIssue495() Check.That(parser).IsNotNull(); var parsed = parser.Parse("test = \"3 3\";"); Check.That(parsed).IsOkParsing(); + Check.That(parsed.Result).IsEqualTo("test=3 3"); } } \ No newline at end of file