From 2c7f338b2172051641a1ae1cf6f978e45083181d Mon Sep 17 00:00:00 2001 From: George Lemon Date: Sat, 20 Apr 2024 12:15:59 +0300 Subject: [PATCH] add more tests | fix debugEcho Signed-off-by: George Lemon --- src/tim/engine/ast.nim | 5 +++-- tests/test1.nim | 31 ++++++++++++++++++++++++++++++- tim.nimble | 2 +- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/tim/engine/ast.nim b/src/tim/engine/ast.nim index fb59071..d8bdba3 100755 --- a/src/tim/engine/ast.nim +++ b/src/tim/engine/ast.nim @@ -488,8 +488,9 @@ proc `$`*(x: Ast): string = else: toJson(x) -proc debugEcho*(node: Node) = - echo pretty(toJson(node), 2) +when not defined release: + proc debugEcho*(node: Node) = + echo pretty(toJson(node), 2) # # AST Generators diff --git a/tests/test1.nim b/tests/test1.nim index 720a9b1..c866205 100644 --- a/tests/test1.nim +++ b/tests/test1.nim @@ -21,6 +21,35 @@ test "check layout": check meta[1].attrs.hasKey("name") check meta[1].attrs.hasKey("content") + let title = html.findAll("title").toSeq check title.len == 1 - check title[0].innerText == "Tim Engine is Awesome!" \ No newline at end of file + check title[0].innerText == "Tim Engine is Awesome!" + +import std/sequtils +import ../src/tim/engine/[logging, parser, compilers/html] + +proc toHtml(id, code: string): (Parser, HtmlCompiler) = + result[0] = parseSnippet(id, code) + result[1] = newCompiler(result[0].getAst, false) + +test "language test var": + const code = """ +var a = 123 +h1: $a +var b = {} + """ + let x = toHtml("test_var", code) + check x[0].hasErrors == false + check x[1].hasErrors == false + +test "language test const": + const code = """ +const x = 123 +h1: $x +$x = 321 + """ + let x = toHtml("test_var", code) + check x[0].hasErrors == false + check x[1].hasErrors == true + # echo x[1].logger.errors.toSeq() diff --git a/tim.nimble b/tim.nimble index 391d60c..f43b417 100755 --- a/tim.nimble +++ b/tim.nimble @@ -3,7 +3,7 @@ version = "0.1.2" author = "OpenPeeps" description = "A super fast template engine for cool kids!" -license = "MIT" +license = "LGPLv3" srcDir = "src" skipDirs = @["example", "editors", "bindings"] installExt = @["nim"]