Add partial use of comments

This commit is contained in:
PedroEdiaz
2025-06-19 22:01:03 -06:00
parent 0f76ad666a
commit 7124aeb94e
2 changed files with 10 additions and 4 deletions

View File

@@ -76,6 +76,7 @@ mustache_reader :: proc(r: ^strings.Reader, data: any, section_key: string = ""
strings.write_string(&ret, section(r, data, skey[1:], true) ) strings.write_string(&ret, section(r, data, skey[1:], true) )
case '&': case '&':
strings.write_string(&ret, fmt.tprintf("%v",decode(data, skey[1:])) ) strings.write_string(&ret, fmt.tprintf("%v",decode(data, skey[1:])) )
case '!':
case: case:
dec := decode(data, skey) dec := decode(data, skey)

View File

@@ -25,12 +25,14 @@ test_struct :: struct {
@(test) @(test)
spec_test :: proc(t: ^testing.T){ spec_test :: proc(t: ^testing.T){
test_files := []string { test_files := []string {
"./spec/specs/delimiters.json",
"./spec/specs/sections.json", "./spec/specs/sections.json",
"./spec/specs/interpolation.json", "./spec/specs/interpolation.json",
//"./spec/specs/inverted.json", "./spec/specs/inverted.json",
//"./spec/specs/partials.json", "./spec/specs/comments.json",
//"./spec/specs/comments.json", /*
"./spec/specs/partials.json",
"./spec/specs/delimiters.json",
*/
} }
for i in test_files { for i in test_files {
@@ -45,13 +47,16 @@ spec_test :: proc(t: ^testing.T){
json.unmarshal(data, &test, allocator=context.temp_allocator) json.unmarshal(data, &test, allocator=context.temp_allocator)
failed := 0
for j in test.tests { for j in test.tests {
ret := mustache(j.template, j.data) ret := mustache(j.template, j.data)
defer delete(ret) defer delete(ret)
if ret!=j.expected { if ret!=j.expected {
log.warnf( "[%s:%s]: %s", i, j.name, j.desc ) log.warnf( "[%s:%s]: %s", i, j.name, j.desc )
failed += 1
} }
} }
log.infof( "[%s] Passed: (%d/%d)", i, len(test.tests)-failed, len(test.tests) )
} }
} }