Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some failures against latest specs #10

Closed
pietroppeter opened this issue May 6, 2021 · 4 comments
Closed

some failures against latest specs #10

pietroppeter opened this issue May 6, 2021 · 4 comments

Comments

@pietroppeter
Copy link
Sponsor Contributor

I made a document that shows the output of nim-mustache against the specs and I used the latest specs. Here is the document which shows some failures: https://pietroppeter.github.io/nblog/drafts/mustache_specs.html

The failures are due to changes in the latest releases (v1.2.0 of 9 days ago and v1.2.1 of 4 days ago) that introduced additional tests for existing features.

Here are the name of failing tests:

  • from interpolation.json:
    • Dotted Names - Context Precedence
    • Implicit Iterators - Basic Interpolation
    • Implicit Iterators - HTML Escaping
    • Implicit Iterators - Triple Mustache
    • Implicit Iterators - Ampersand
    • Implicit Iterators - Basic Integer Interpolation
  • from sections.json:
    • Variable test
    • Deeply Nested Contexts

The tests with names starting with Implicit Iterators are failures in the sense that the spec uses a data json that is not an object. The Context of nim-mustache must have as values field a table. Probably a fix would require to change the type of values to be a Value itself (and rename it to value)?

For the other 3 failing tests I report here for convenience the data with expected output and output from nim-mustache.

❌ Dotted Names - Context Precedence

Dotted names should be resolved against former resolutions.

Template:

{{#a}}{{b.c}}{{/a}}

Data:

{"a":{"b":{}},"b":{"c":"ERROR"}}

Expected:

Output:

ERROR

❌ Variable test

Non-false sections have their value at the top of context, accessible as {{.}} or through the parent context. This gives a simple way to display content conditionally if a variable exists.

Template:

"{{#foo}}{{.}} is {{foo}}{{/foo}}"

Data:

{"foo":"bar"}

Expected:

"bar is bar"

Output:

" is bar"

❌ Deeply Nested Contexts

All elements on the context stack should be accessible.

Template:

{{#a}}
{{one}}
{{#b}}
{{one}}{{two}}{{one}}
{{#c}}
{{one}}{{two}}{{three}}{{two}}{{one}}
{{#d}}
{{one}}{{two}}{{three}}{{four}}{{three}}{{two}}{{one}}
{{#five}}
{{one}}{{two}}{{three}}{{four}}{{five}}{{four}}{{three}}{{two}}{{one}}
{{one}}{{two}}{{three}}{{four}}{{.}}6{{.}}{{four}}{{three}}{{two}}{{one}}
{{one}}{{two}}{{three}}{{four}}{{five}}{{four}}{{three}}{{two}}{{one}}
{{/five}}
{{one}}{{two}}{{three}}{{four}}{{three}}{{two}}{{one}}
{{/d}}
{{one}}{{two}}{{three}}{{two}}{{one}}
{{/c}}
{{one}}{{two}}{{one}}
{{/b}}
{{one}}
{{/a}}

Data:

{"a":{"one":1},"b":{"two":2},"c":{"three":3,"d":{"four":4,"five":5}}}

Expected:

1
121
12321
1234321
123454321
12345654321
123454321
1234321
12321
121
1

Output:

1
121
12321
1234321
123454321
123464321
123454321
1234321
12321
121
1
@soasme soasme pinned this issue May 7, 2021
@soasme
Copy link
Owner

soasme commented May 7, 2021

Thanks for the reporting. I'll spend some time reading the new spec and see how to adapt to it.

@soasme
Copy link
Owner

soasme commented May 8, 2021

@pietroppeter I have released v0.4.0, which should fix all the failed test cases reported in this issue. Please let me know if it solves your problem.

@pietroppeter
Copy link
Sponsor Contributor Author

Great job! I will run again and let you know!

@pietroppeter
Copy link
Sponsor Contributor Author

I can confirm all tests are green now: https://pietroppeter.github.io/nblog/drafts/mustache_specs.html

@soasme soasme unpinned this issue May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants