Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix-rendering-non…
Browse files Browse the repository at this point in the history
…-false-value-sections
  • Loading branch information
roblillack committed Jun 10, 2021
2 parents d22c883 + c5eea54 commit e25d805
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 141 deletions.
161 changes: 21 additions & 140 deletions spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,135 +9,24 @@ import (
"testing"
)

var enabledTests = map[string]map[string]bool{
"comments.json": map[string]bool{
"Inline": true,
"Multiline": true,
"Standalone": true,
"Indented Standalone": true,
"Standalone Line Endings": true,
"Standalone Without Previous Line": true,
"Standalone Without Newline": true,
"Multiline Standalone": true,
"Indented Multiline Standalone": true,
"Indented Inline": true,
"Surrounding Whitespace": true,
},
"delimiters.json": map[string]bool{
"Pair Behavior": true,
"Special Characters": true,
"Sections": true,
"Inverted Sections": true,
"Partial Inheritence": true,
"Post-Partial Behavior": true,
"Outlying Whitespace (Inline)": true,
"Standalone Tag": true,
"Indented Standalone Tag": true,
"Pair with Padding": true,
"Surrounding Whitespace": true,
"Standalone Line Endings": true,
"Standalone Without Previous Line": true,
"Standalone Without Newline": true,
},
"interpolation.json": map[string]bool{
"No Interpolation": true,
"Basic Interpolation": true,
var disabledTests = map[string]map[string]struct{}{
"interpolation.json": {
// disabled b/c Go uses """ in place of """
// both are valid escapings, and we validate the behavior in mustache_test.go
"HTML Escaping": false,
"Triple Mustache": true,
"Ampersand": true,
"Basic Integer Interpolation": true,
"Triple Mustache Integer Interpolation": true,
"Ampersand Integer Interpolation": true,
"Basic Decimal Interpolation": true,
"Triple Mustache Decimal Interpolation": true,
"Ampersand Decimal Interpolation": true,
"Basic Context Miss Interpolation": true,
"Triple Mustache Context Miss Interpolation": true,
"Ampersand Context Miss Interpolation": true,
"Dotted Names - Basic Interpolation": true,
"Dotted Names - Triple Mustache Interpolation": true,
"Dotted Names - Ampersand Interpolation": true,
"Dotted Names - Arbitrary Depth": true,
"Dotted Names - Broken Chains": true,
"Dotted Names - Broken Chain Resolution": true,
"Dotted Names - Initial Resolution": true,
"Interpolation - Surrounding Whitespace": true,
"Triple Mustache - Surrounding Whitespace": true,
"Ampersand - Surrounding Whitespace": true,
"Interpolation - Standalone": true,
"Triple Mustache - Standalone": true,
"Ampersand - Standalone": true,
"Interpolation With Padding": true,
"Triple Mustache With Padding": true,
"Ampersand With Padding": true,
},
"inverted.json": map[string]bool{
"Falsey": true,
"Truthy": true,
"Context": true,
"List": true,
"Empty List": true,
"Doubled": true,
"Nested (Falsey)": true,
"Nested (Truthy)": true,
"Context Misses": true,
"Dotted Names - Truthy": true,
"Dotted Names - Falsey": true,
"Internal Whitespace": true,
"Indented Inline Sections": true,
"Standalone Lines": true,
"Standalone Indented Lines": true,
"Padding": true,
"Dotted Names - Broken Chains": true,
"Surrounding Whitespace": true,
"Standalone Line Endings": true,
"Standalone Without Previous Line": true,
"Standalone Without Newline": true,
"HTML Escaping": struct{}{},
// Newly added spec tests which aren't currently passing:
"Basic Null Interpolation": struct{}{},
"Triple Mustache Null Interpolation": struct{}{},
"Ampersand Null Interpolation": struct{}{},
"Implicit Iterators - HTML Escaping": struct{}{},
},
"partials.json": map[string]bool{
"Basic Behavior": true,
"Failed Lookup": true,
"Context": true,
"Recursion": true,
"Surrounding Whitespace": true,
"Inline Indentation": true,
"Standalone Line Endings": true,
"Standalone Without Previous Line": true,
"Standalone Without Newline": true,
"Standalone Indentation": true,
"Padding Whitespace": true,
// To be fixed by https://github.com/cbroglie/mustache/pull/55
"sections.json": {
"Variable test": struct{}{},
"Deeply Nested Contexts": struct{}{},
},
"sections.json": map[string]bool{
"Truthy": true,
"Falsey": true,
"Context": true,
"Deeply Nested Contexts": true,
"List": true,
"Empty List": true,
"Doubled": true,
"Nested (Truthy)": true,
"Nested (Falsey)": true,
"Context Misses": true,
"Implicit Iterator - String": true,
"Implicit Iterator - Integer": true,
"Implicit Iterator - Decimal": true,
"Implicit Iterator - Array": true,
"Dotted Names - Truthy": true,
"Dotted Names - Falsey": true,
"Dotted Names - Broken Chains": true,
"Surrounding Whitespace": true,
"Internal Whitespace": true,
"Indented Inline Sections": true,
"Standalone Lines": true,
"Indented Standalone Lines": true,
"Standalone Line Endings": true,
"Standalone Without Previous Line": true,
"Standalone Without Newline": true,
"Padding": true,
},
"~lambdas.json": nil, // not implemented
"~lambdas.json": {}, // not implemented
"~inheritance.json": {}, // not implemented
}

type specTest struct {
Expand Down Expand Up @@ -170,14 +59,6 @@ func TestSpec(t *testing.T) {

for _, path := range paths {
_, file := filepath.Split(path)
enabled, ok := enabledTests[file]
if !ok {
t.Errorf("Unexpected file %s, consider adding to enabledFiles", file)
continue
}
if enabled == nil {
continue
}
b, err := ioutil.ReadFile(path)
if err != nil {
t.Fatal(err)
Expand All @@ -194,13 +75,13 @@ func TestSpec(t *testing.T) {
}

func runTest(t *testing.T, file string, test *specTest) {
enabled, ok := enabledTests[file][test.Name]
if !ok {
t.Errorf("[%s %s]: Unexpected test, add to enabledTests", file, test.Name)
}
if !enabled {
t.Logf("[%s %s]: Skipped", file, test.Name)
return
disabled, ok := disabledTests[file]
if ok {
// Can disable a single test or the entire file.
if _, ok := disabled[test.Name]; ok || len(disabled) == 0 {
t.Logf("[%s %s]: Skipped", file, test.Name)
return
}
}

var out string
Expand Down

0 comments on commit e25d805

Please sign in to comment.