Skip to content

Commit 551d6fa

Browse files
rodion-mcompyle-bot[bot]sebastienrosCopilot
authored
Detect undefined variables (#844)
* #64: Ensure variables completeness with `StrictVariables` option * #64: Replace strict variable buffering with UndefinedValue sentinel * Refactor to use Nil * Update documentation * Update variable name * Update Fluid/Values/ObjectValueBase.cs Co-authored-by: Copilot <[email protected]> * Update Fluid.Tests/StrictVariableTests.cs Co-authored-by: Copilot <[email protected]> * Re-introduce UndefinedValue * Fix build --------- Co-authored-by: compyle-bot[bot] <238113443+compyle-bot[bot]@users.noreply.github.com> Co-authored-by: Sebastien Ros <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 5194ce8 commit 551d6fa

16 files changed

+1194
-500
lines changed

Fluid.Tests/FromStatementTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Hello world!
6262
await fromStatement.WriteToAsync(sw, HtmlEncoder.Default, context);
6363

6464
Assert.IsType<FunctionValue>(context.GetValue("hello_world"));
65-
Assert.IsType<NilValue>(context.GetValue("hello"));
65+
Assert.IsType<UndefinedValue>(context.GetValue("hello"));
6666
}
6767

6868
[Fact]

Fluid.Tests/MiscFiltersTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ public async Task JsonShouldWriteNullIfDictionaryNotReturnFluidIndexable()
720720
options.MemberAccessStrategy.Register(model.GetType());
721721
var input = FluidValue.Create(model, options);
722722
var result = await MiscFilters.Json(input, new FilterArguments(), new TemplateContext(options));
723-
Assert.Equal("{\"Id\":1,\"WithoutIndexable\":{\"Type\":5,\"Value\":{}},\"Bool\":true}", result.ToStringValue());
723+
Assert.Equal("{\"Id\":1,\"WithoutIndexable\":{\"Type\":6,\"Value\":{}},\"Bool\":true}", result.ToStringValue());
724724
}
725725

726726
[Fact]
@@ -910,7 +910,7 @@ public async Task HmacSha1(string key, string value, string expected)
910910
{
911911
// Arrange
912912
FluidValue input = value is null
913-
? NilValue.Empty
913+
? EmptyValue.Instance
914914
: new StringValue(value);
915915
var arguments = new FilterArguments(FluidValue.Create(key, TemplateOptions.Default));
916916
var context = new TemplateContext();
@@ -932,7 +932,7 @@ public async Task HmacSha256(string key, string value, string expected)
932932
{
933933
// Arrange
934934
FluidValue input = value is null
935-
? NilValue.Empty
935+
? EmptyValue.Instance
936936
: new StringValue(value);
937937
var arguments = new FilterArguments(FluidValue.Create(key, TemplateOptions.Default));
938938
var context = new TemplateContext();

0 commit comments

Comments
 (0)