diff --git a/src/Cimpress.Cimbol/Cimpress.Cimbol.csproj b/src/Cimpress.Cimbol/Cimpress.Cimbol.csproj index 1cb4e62..a94d368 100644 --- a/src/Cimpress.Cimbol/Cimpress.Cimbol.csproj +++ b/src/Cimpress.Cimbol/Cimpress.Cimbol.csproj @@ -29,7 +29,6 @@ all - diff --git a/test/Cimpress.Cimbol.IntegrationTests/Compiler/Emit/DefaultEvaluationTests.cs b/test/Cimpress.Cimbol.IntegrationTests/Compiler/Emit/DefaultEvaluationTests.cs index fd3527a..a1b901c 100644 --- a/test/Cimpress.Cimbol.IntegrationTests/Compiler/Emit/DefaultEvaluationTests.cs +++ b/test/Cimpress.Cimbol.IntegrationTests/Compiler/Emit/DefaultEvaluationTests.cs @@ -198,6 +198,50 @@ public void Should_Default_When_IdentifierIsNull(CompilationProfile compilationP Assert.That(result.Modules["Main"].Value["Formula1"], Has.Property("Value").EqualTo(1)); } + + [Test] + [TestCase(CompilationProfile.Minimal)] + [TestCase(CompilationProfile.Trace)] + [TestCase(CompilationProfile.Verbose)] + public void Should_ReturnValue_When_MemberExistsAndContainsWhitespace(CompilationProfile compilationProfile) + { + var program = new Program(); + var module = program.AddModule("Main"); + + var objectValue = new ObjectValue(new Dictionary { { "member name", new NumberValue(5) } }); + var constant = program.AddConstant("something", objectValue); + + module.AddImport("something", constant); + module.AddFormula("Formula1", "default(something.'member name', 1)"); + + var executable = program.Compile(compilationProfile); + + var result = executable.Call().Result; + + Assert.That(result.Modules["Main"].Value["Formula1"], Has.Property("Value").EqualTo(5)); + } + + [Test] + [TestCase(CompilationProfile.Minimal)] + [TestCase(CompilationProfile.Trace)] + [TestCase(CompilationProfile.Verbose)] + public void Should_ReturnValue_When_IdentifierExistsAndContainsWhitespace(CompilationProfile compilationProfile) + { + var program = new Program(); + var module = program.AddModule("Main"); + + var objectValue = new ObjectValue(new Dictionary { { "member name", new NumberValue(5) } }); + var constant = program.AddConstant("something with spaces", objectValue); + + module.AddImport("something with spaces", constant); + module.AddFormula("Formula1", "default('something with spaces'.'member name', 1)"); + + var executable = program.Compile(compilationProfile); + + var result = executable.Call().Result; + + Assert.That(result.Modules["Main"].Value["Formula1"], Has.Property("Value").EqualTo(5)); + } private static ILocalValue MockNestedObject(string[] path, ILocalValue value) { diff --git a/test/Cimpress.Cimbol.IntegrationTests/Compiler/Emit/ExistsEvaluationTests.cs b/test/Cimpress.Cimbol.IntegrationTests/Compiler/Emit/ExistsEvaluationTests.cs index bbe2023..ff2ce2a 100644 --- a/test/Cimpress.Cimbol.IntegrationTests/Compiler/Emit/ExistsEvaluationTests.cs +++ b/test/Cimpress.Cimbol.IntegrationTests/Compiler/Emit/ExistsEvaluationTests.cs @@ -167,5 +167,47 @@ NumberValue Function() Assert.That(result.Modules["Main"].Value["Formula1"], Has.Property("Value").EqualTo(false)); } + + [Test] + [TestCase(CompilationProfile.Minimal)] + [TestCase(CompilationProfile.Trace)] + [TestCase(CompilationProfile.Verbose)] + public async Task Should_ReturnTrue_When_ObjectMemberNameContainsWhitespace(CompilationProfile compilationProfile) + { + var program = new Program(); + var objectValue = new ObjectValue(new Dictionary { { "member name", new StringValue("1") } }); + var constant = program.AddConstant("something", objectValue); + + var module = program.AddModule("Main"); + module.AddImport("something", constant); + module.AddFormula("Formula1", "exists(something.'member name')"); + + var executable = program.Compile(compilationProfile); + + var result = await executable.Call(); + + Assert.That(result.Modules["Main"].Value["Formula1"], Has.Property("Value").EqualTo(true)); + } + + [Test] + [TestCase(CompilationProfile.Minimal)] + [TestCase(CompilationProfile.Trace)] + [TestCase(CompilationProfile.Verbose)] + public async Task Should_ReturnTrue_When_ImportNameContainsWhitespace(CompilationProfile compilationProfile) + { + var program = new Program(); + var objectValue = new ObjectValue(new Dictionary { { "member name", new StringValue("1") } }); + var constant = program.AddConstant("something with spaces", objectValue); + + var module = program.AddModule("Main"); + module.AddImport("something with spaces", constant); + module.AddFormula("Formula1", "exists('something with spaces'.'member name')"); + + var executable = program.Compile(compilationProfile); + + var result = await executable.Call(); + + Assert.That(result.Modules["Main"].Value["Formula1"], Has.Property("Value").EqualTo(true)); + } } }