-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change expected-value matching to a valueEquals recursive template. (#…
…11560) For now this does not change any functionality: there is no change in the generated code. It just cleans up how nullable and optional are handled.
- Loading branch information
1 parent
71f87d0
commit 90e7847
Showing
4 changed files
with
28 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
examples/chip-tool/templates/partials/test_cluster_value_equals.zapt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{{#if isOptional}} | ||
VerifyOrReturn(CheckValuePresent("{{label}}", {{actual}})); | ||
{{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isOptional=false}} | ||
{{else if isNullable}} | ||
{{#if (isLiteralNull expected)}} | ||
VerifyOrReturn(CheckValueNull("{{label}}", {{actual}})); | ||
{{else}} | ||
VerifyOrReturn(CheckValueNonNull("{{label}}", {{actual}})); | ||
{{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isNullable=false}} | ||
{{/if}} | ||
{{else}} | ||
VerifyOrReturn(CheckValue | ||
{{~#if isList}}AsListLength("{{label}}", {{actual}}, {{expected.length}}) | ||
{{else if isArray}}AsList("{{label}}", {{actual}}{{#if expected.length}}, {{expected}}{{/if}}) | ||
{{else if (isString type)}}AsString("{{label}}", {{actual}}, "{{expected}}") | ||
{{else}}<{{chipType}}>("{{label}}", {{actual}}, {{expected}}{{asTypeLiteralSuffix type}}) | ||
{{/if}} | ||
); | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters