Skip to content

Commit

Permalink
Committing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmith-hs committed Oct 10, 2023
1 parent c9a1165 commit fbdaf83
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ public Object doEvaluate(
interpreter
);
if (!result.getResult().isFullyResolved()) {
if (
result
.getSpeculativeBindings()
.keySet()
.stream()
.anyMatch(key -> localContextScope.getScope().containsKey(key))
) {
throw new DeferredValueException("e");
}
result =
eagerEvaluateInDeferredExecutionMode(
() -> getEvaluationResultDirectly(argMap, kwargMap, varArgs, interpreter),
Expand Down Expand Up @@ -294,7 +303,7 @@ private String getSetTagForAliasedVariables(String fullName) {
.getCombinedScope()
.entrySet()
.stream()
.filter(entry -> entry.getValue() instanceof DeferredValue)
// .filter(entry -> entry.getValue() instanceof DeferredValue)
.map(Entry::getKey)
.collect(Collectors.toMap(Function.identity(), name -> aliasName + name));
return EagerReconstructionUtils.buildSetTag(
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/com/hubspot/jinjava/EagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1499,4 +1499,11 @@ public void itAllowsVariableSharingAliasName() {
"allows-variable-sharing-alias-name"
);
}

@Test
public void itAllowsModificationInAliasedMacro() {
expectedTemplateInterpreter.assertExpectedOutput(
"allows-modification-in-aliased-macro"
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% import 'eager/settings.jinja' as shared %}

{% if deferred %}
{{ shared.load_settings() }}
{% endif %}
{{ shared.settings }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% import 'eager/settings.jinja' as shared %}

{% if deferred %}
{{ shared.load_settings() }}
{% endif %}
{{ shared.settings }}
5 changes: 5 additions & 0 deletions src/test/resources/tags/macrotag/eager/settings.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% set settings = {} %}

{% macro load_settings() %}
{% do settings.put('foo', 'bar') %}
{% endmacro %}

0 comments on commit fbdaf83

Please sign in to comment.