From 76a2031c37021a4dbf2ae43dadad689f57f91c28 Mon Sep 17 00:00:00 2001 From: Alexander Ivanov Date: Thu, 18 May 2017 12:58:43 +0300 Subject: [PATCH 1/9] Support submit and input event in the vdom --- src/vdom.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/vdom.nim b/src/vdom.nim index 1dc389e..af0c98a 100644 --- a/src/vdom.nim +++ b/src/vdom.nim @@ -73,6 +73,9 @@ type ondragstart, ## The user starts dragging an element or text selection. ondrop, ## An element is dropped on a valid drop target. + onsubmit, ## A form is submitted + oninput, ## An input value changes + onkeyupenter, ## vdom extension: an input field received the ENTER key press onkeyuplater ## vdom extension: a key was pressed and some time ## passed (useful for on-the-fly text completions) From dc5ba1f6461d90439eafb19b4fb5d173690f5482 Mon Sep 17 00:00:00 2001 From: Pavel Nuzhdin Date: Fri, 9 Jun 2017 15:44:16 +0700 Subject: [PATCH 2/9] Added stopPropagation event method --- src/kdom.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/src/kdom.nim b/src/kdom.nim index f2dabcf..349f02d 100644 --- a/src/kdom.nim +++ b/src/kdom.nim @@ -520,6 +520,7 @@ proc setAttribute*(s: Style, attr, value: cstring, caseSensitive=false) # Event "methods" proc preventDefault*(ev: Event) +proc stopPropagation*(ev: Event) # TouchEvent "methods" proc identifiedTouch*(list: TouchList): Touch From d5596c8ff50af6002ac24b26a63b0b451627ca6a Mon Sep 17 00:00:00 2001 From: Fabian Keller Date: Fri, 19 May 2017 20:15:07 +0200 Subject: [PATCH 3/9] added post render callback --- src/karax.nim | 8 +++++++- src/kdom.nim | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/karax.nim b/src/karax.nim index f8929e1..cc52e2f 100644 --- a/src/karax.nim +++ b/src/karax.nim @@ -117,6 +117,7 @@ proc same(n: VNode, e: Node): bool = var dorender: proc (): VNode {.closure.} currentTree: VNode + postRenderCallback: proc () proc replaceById(id: cstring; newTree: Node) = let x = document.getElementById(id) @@ -279,6 +280,10 @@ proc dodraw() = updateDirtyElements(nil, olddom, newtree) someDirty = false currentTree = newtree + + if not postRenderCallback.isNil: + postRenderCallback() + # now that it's part of the DOM, give it the focus: if toFocus != nil: toFocus.focus() @@ -299,9 +304,10 @@ proc redraw*() = proc init(ev: Event) = reqFrame(dodraw) -proc setRenderer*(renderer: proc (): VNode) = +proc setRenderer*(renderer: proc (): VNode, clientPostRenderCallback: proc () = nil) = dorender = renderer window.onload = init + postRenderCallback = clientPostRenderCallback proc addEventHandler*(n: VNode; k: EventKind; action: EventHandler) = ## Implements the foundation of Karax's event management. diff --git a/src/kdom.nim b/src/kdom.nim index 349f02d..0adb1dd 100644 --- a/src/kdom.nim +++ b/src/kdom.nim @@ -273,6 +273,7 @@ type textDecoration*: cstring textIndent*: cstring textTransform*: cstring + transform*: cstring top*: cstring verticalAlign*: cstring visibility*: cstring @@ -567,7 +568,7 @@ proc getElementsByClass*(n: Node; name: cstring): seq[Node] {. type BoundingRect* {.importc.} = object - top*, bottom*, left*, right*: int + top*, bottom*, left*, right*, x*, y*, width*, height*: float proc getBoundingClientRect*(e: Node): BoundingRect {. importcpp: "getBoundingClientRect", nodecl.} @@ -579,8 +580,8 @@ proc clientWidth*(): int {. proc inViewport*(el: Node): bool = let rect = el.getBoundingClientRect() result = rect.top >= 0 and rect.left >= 0 and - rect.bottom <= clientHeight() and - rect.right <= clientWidth() + rect.bottom <= clientHeight().float and + rect.right <= clientWidth().float proc scrollTop*(e: Node): int {.importcpp: "#.scrollTop", nodecl.} proc offsetHeight*(e: Node): int {.importcpp: "#.offsetHeight", nodecl.} From 08538f7f2675814436c60de3316323c7991692ef Mon Sep 17 00:00:00 2001 From: Araq Date: Fri, 16 Jun 2017 16:45:06 +0200 Subject: [PATCH 4/9] move parseInt to jstrutils.nim to avoid conflicts; introduce travis testing --- .travis.yml | 18 ++++++++++++++++++ src/jstrutils.nim | 1 + src/kdom.nim | 3 --- tests/tester.nim | 15 +++++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 .travis.yml create mode 100644 tests/tester.nim diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0c60bd2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +sudo: false +language: c +os: linux +install: + - git clone https://github.com/nim-lang/nim + - cd nim + - git clone --depth 1 https://github.com/nim-lang/csources.git + - cd csources + - sh build.sh + - cd ../ + - bin/nim c koch + - ./koch boot -d:release + - cd .. +before_script: + - set -e + - export PATH=$(pwd)/nim/bin:$(pwd):$PATH +script: + - nim c -r tests/tester.nim diff --git a/src/jstrutils.nim b/src/jstrutils.nim index 0be4076..a16473d 100644 --- a/src/jstrutils.nim +++ b/src/jstrutils.nim @@ -23,3 +23,4 @@ proc isInt*(s: cstring): bool {.asmNoStackFrame.} = """ proc parseInt*(s: cstring): int {.importcpp: "parseInt(#, 10)", nodecl.} +proc parseFloat*(s: cstring): BiggestFloat {.importc, nodecl.} diff --git a/src/kdom.nim b/src/kdom.nim index 0adb1dd..f933b87 100644 --- a/src/kdom.nim +++ b/src/kdom.nim @@ -547,9 +547,6 @@ proc decodeURIComponent*(uri: cstring): cstring {.importc, nodecl.} proc encodeURIComponent*(uri: cstring): cstring {.importc, nodecl.} proc isFinite*(x: BiggestFloat): bool {.importc, nodecl.} proc isNaN*(x: BiggestFloat): bool {.importc, nodecl.} -proc parseFloat*(s: cstring): BiggestFloat {.importc, nodecl.} -proc parseInt*(s: cstring): int {.importc, nodecl.} -proc parseInt*(s: cstring, radix: int):int {.importc, nodecl.} proc id*(n: Node): cstring {.importcpp: "#.id", nodecl.} diff --git a/tests/tester.nim b/tests/tester.nim new file mode 100644 index 0000000..5dc7426 --- /dev/null +++ b/tests/tester.nim @@ -0,0 +1,15 @@ +# For now we only test that the things still compile. + +import os + +proc exec(cmd: string) = + if os.execShellCmd(cmd) != 0: + quit "command failed " & cmd + +proc main = + exec("nim js tests/diffDomTests.nim") + exec("nim js examples/todoapp/todoapp.nim") + exec("nim js examples/scrollapp/scrollapp.nim") + exec("nim js examples/mediaplayer/playerapp.nim") + +main() From b3fba429ad89ee45419e9c3555bdbd53a9c53ba7 Mon Sep 17 00:00:00 2001 From: Araq Date: Fri, 16 Jun 2017 18:02:35 +0200 Subject: [PATCH 5/9] introduce KaraxInstance; 100% backwards compatible --- src/karax.nim | 121 ++++++++++++++++++++++++++--------------------- src/karaxdsl.nim | 4 +- 2 files changed, 70 insertions(+), 55 deletions(-) diff --git a/src/karax.nim b/src/karax.nim index cc52e2f..d9f5773 100644 --- a/src/karax.nim +++ b/src/karax.nim @@ -14,12 +14,26 @@ proc key*(e: Node): VKey = else: result = -1 proc `key=`*(e: Node; x: VKey) {.importcpp: "#.karaxKey = #", nodecl.} -var - toFocus: Node - toFocusV: VNode +type + KaraxInstance* = ref object ## underlying karax instance. Usually you don't have + ## know about this. + rootId: cstring not nil + renderer: proc (): VNode {.closure.} + currentTree: VNode + postRenderCallback: proc () + toFocus: Node + toFocusV: VNode -proc setFocus*(n: VNode) = - toFocusV = n +var + kxi*: KaraxInstance ## The current Karax instance. This is always used + ## as the default. **Note**: Within the karax DSL + ## always a symbol of the name *kxi* is assumed, so + ## if you have a local karax instance to use instead + ## in your 'buildHtml' statement, it needs to be named + ## 'kxi'. + +proc setFocus*(n: VNode; kxi: KaraxInstance = kxi) = + kxi.toFocusV = n # ----------------- event wrapping --------------------------------------- @@ -68,13 +82,13 @@ proc wrapEvent(d: Node; n: VNode; k: EventKind; action: EventHandler) = template detach(n: VNode) = n.dom = nil template attach(n: Vnode) = n.dom = result -proc vnodeToDom(n: VNode): Node = +proc vnodeToDom(n: VNode; kxi: KaraxInstance): Node = if n.kind == VNodeKind.text: result = document.createTextNode(n.text) attach n elif n.kind == VNodeKind.vthunk: let x = callThunk(vcomponents[n.text], n) - result = vnodeToDom(x) + result = vnodeToDom(x, kxi) #n.key = result.key attach n return result @@ -87,7 +101,7 @@ proc vnodeToDom(n: VNode): Node = result = document.createElement(toTag[n.kind]) attach n for k in n: - appendChild(result, vnodeToDom(k)) + appendChild(result, vnodeToDom(k, kxi)) # text is mapped to 'value': if n.text != nil: result.value = n.text @@ -102,8 +116,8 @@ proc vnodeToDom(n: VNode): Node = result.setAttr(k, v) for e, h in items(n.events): wrapEvent(result, n, e, h) - if n == toFocusV and toFocus.isNil: - toFocus = result + if n == kxi.toFocusV and kxi.toFocus.isNil: + kxi.toFocus = result if not n.style.isNil: applyStyle(result, n.style) proc same(n: VNode, e: Node): bool = @@ -114,11 +128,6 @@ proc same(n: VNode, e: Node): bool = for i in 0 ..< n.len: if not same(n[i], e[i]): return false -var - dorender: proc (): VNode {.closure.} - currentTree: VNode - postRenderCallback: proc () - proc replaceById(id: cstring; newTree: Node) = let x = document.getElementById(id) x.parentNode.replaceChild(newTree, x) @@ -155,18 +164,19 @@ proc eq(a, b: VNode; deep: bool): EqResult = # Do not test event listeners here! return result -proc updateDirtyElements(parent, current: Node, newNode: VNode) = +proc updateDirtyElements(parent, current: Node, newNode: VNode, + kxi: KaraxInstance) = if newNode.key >= 0 and isDirty(newNode.key): unmarkDirty(newNode.key) - let n = vnodeToDom(newNode) + let n = vnodeToDom(newNode, kxi) if parent == nil: - replaceById("ROOT", n) + replaceById(kxi.rootId, n) else: parent.replaceChild(n, current) elif newNode.kind != VNodeKind.text and newNode.kind != VNodeKind.vthunk and newNode.kind != VNodeKind.dthunk: for i in 0..newNode.len-1: - updateDirtyElements(current, current[i], newNode[i]) + updateDirtyElements(current, current[i], newNode[i], kxi) # leave early if we know there cannot be anything left to do: #if dirtyCount <= 0: return @@ -187,13 +197,14 @@ proc updateDom(newNode, oldNode: VNode) = for i in 0 ..< newNode.len: updateDom(newNode[i], oldNode[i]) -proc updateElement(parent, current: Node, newNode, oldNode: VNode) = +proc updateElement(parent, current: Node, newNode, oldNode: VNode; + kxi: KaraxInstance) = let res = eq(newNode, oldNode, deep=false) if res == different: detach(oldNode) - let n = vnodeToDom(newNode) + let n = vnodeToDom(newNode, kxi) if parent == nil: - replaceById("ROOT", n) + replaceById(kxi.rootId, n) else: parent.replaceChild(n, current) else: @@ -207,7 +218,7 @@ proc updateElement(parent, current: Node, newNode, oldNode: VNode) = assert oldNode.kind == newNode.kind when defined(simpleDiff): for i in 0..min(newLength, oldLength)-1: - updateElement(current, current[i], newNode[i], oldNode[i]) + updateElement(current, current[i], newNode[i], oldNode[i], kxi) if newLength > oldLength: for i in oldLength..newLength-1: current.appendChild(vnodeToDom(newNode[i])) @@ -243,14 +254,14 @@ proc updateElement(parent, current: Node, newNode, oldNode: VNode) = var pos = min(oldPos, newPos) + 1 for i in commonPrefix..pos-1: - updateElement(current, current.childNodes[i], newNode[i], oldNode[i]) + updateElement(current, current.childNodes[i], newNode[i], oldNode[i], kxi) var nextChildPos = oldPos + 1 while pos <= newPos: if nextChildPos == oldLength: - current.appendChild(vnodeToDom(newNode[pos])) + current.appendChild(vnodeToDom(newNode[pos], kxi)) else: - current.insertBefore(vnodeToDom(newNode[pos]), current.childNodes[nextChildPos]) + current.insertBefore(vnodeToDom(newNode[pos], kxi), current.childNodes[nextChildPos]) # added new Node, so old state of VDOM have one more Node inc oldLength inc pos @@ -263,53 +274,57 @@ proc updateElement(parent, current: Node, newNode, oldNode: VNode) = when false: var drawTimeout: Timeout -proc dodraw() = - if dorender.isNil: return - let newtree = dorender() - newtree.id = "ROOT" - toFocus = nil - if currentTree == nil: - currentTree = newtree - let asdom = vnodeToDom currentTree - replaceById("ROOT", asdom) +proc dodraw(kxi: KaraxInstance) = + if kxi.renderer.isNil: return + let newtree = kxi.renderer() + newtree.id = kxi.rootId + kxi.toFocus = nil + if kxi.currentTree == nil: + kxi.currentTree = newtree + let asdom = vnodeToDom(kxi.currentTree, kxi) + replaceById(kxi.rootId, asdom) else: - let olddom = document.getElementById("ROOT") - updateElement(nil, olddom, newtree, currentTree) + let olddom = document.getElementById(kxi.rootId) + updateElement(nil, olddom, newtree, kxi.currentTree, kxi) #assert same(newtree, document.getElementById("ROOT")) if someDirty: - updateDirtyElements(nil, olddom, newtree) + updateDirtyElements(nil, olddom, newtree, kxi) someDirty = false - currentTree = newtree + kxi.currentTree = newtree - if not postRenderCallback.isNil: - postRenderCallback() + if not kxi.postRenderCallback.isNil: + kxi.postRenderCallback() # now that it's part of the DOM, give it the focus: - if toFocus != nil: - toFocus.focus() + if kxi.toFocus != nil: + kxi.toFocus.focus() proc reqFrame(callback: proc()) {.importc: "window.requestAnimationFrame".} -proc redraw*() = +proc redraw*(kxi: KaraxInstance = kxi) = # we buffer redraw requests: when false: if drawTimeout != nil: clearTimeout(drawTimeout) drawTimeout = setTimeout(dodraw, 30) elif true: - reqFrame(dodraw) + reqFrame(proc () = kxi.dodraw) else: dodraw() proc init(ev: Event) = - reqFrame(dodraw) + reqFrame(proc () = kxi.dodraw) -proc setRenderer*(renderer: proc (): VNode, clientPostRenderCallback: proc () = nil) = - dorender = renderer +proc setRenderer*(renderer: proc (): VNode, root: cstring = "ROOT", + clientPostRenderCallback: proc () = nil): KaraxInstance {.discardable.} = + ## Setup Karax. Usually the return value can be ignored. + result = KaraxInstance(rootId: root, renderer: renderer, + postRenderCallback: clientPostRenderCallback) + kxi = result window.onload = init - postRenderCallback = clientPostRenderCallback -proc addEventHandler*(n: VNode; k: EventKind; action: EventHandler) = +proc addEventHandler*(n: VNode; k: EventKind; action: EventHandler; + kxi: KaraxInstance = kxi) = ## Implements the foundation of Karax's event management. ## Karax DSL transforms ``tag(onEvent = handler)`` to ## ``tempNode.addEventHandler(tagNode, EventKind.onEvent, wrapper)`` @@ -317,7 +332,7 @@ proc addEventHandler*(n: VNode; k: EventKind; action: EventHandler) = ## a ``redraw``. proc wrapper(ev: Event; n: VNode) = action(ev, n) - redraw() + redraw(kxi) addEventListener(n, k, wrapper) proc setOnHashChange*(action: proc (hashPart: cstring)) = @@ -346,10 +361,10 @@ proc setupErrorHandler*() = proc prepend(parent, kid: Element) = parent.insertBefore(kid, parent.firstChild) -proc loadScript*(jsfilename: cstring) = +proc loadScript*(jsfilename: cstring; kxi: KaraxInstance = kxi) = let body = getElementById("body") let s = document.createElement("script") s.setAttr "type", "text/javascript" s.setAttr "src", jsfilename body.prepend(s) - redraw() + redraw(kxi) diff --git a/src/karaxdsl.nim b/src/karaxdsl.nim index 190545c..a3558c8 100644 --- a/src/karaxdsl.nim +++ b/src/karaxdsl.nim @@ -76,7 +76,7 @@ proc tcall2(n, tmpContext: NimNode): NimNode = let key = getName x[0] if key.startsWith("on"): result.add newCall(bindSym"addEventHandler", - tmp, newDotExpr(bindSym"EventKind", x[0]), x[1]) + tmp, newDotExpr(bindSym"EventKind", x[0]), x[1], ident("kxi")) elif key in SpecialAttrs: result.add newDotAsgn(tmp, key, x[1]) else: @@ -84,7 +84,7 @@ proc tcall2(n, tmpContext: NimNode): NimNode = elif ck != ComponentKind.Tag: call.add x elif eqIdent(x, "setFocus"): - result.add newCall(x, tmp) + result.add newCall(x, tmp, ident"kxi") else: result.add tcall2(x, tmp) if tmpContext == nil: From 28c4f4b76a0cf66618a70a9a4e9f6d9f220040a6 Mon Sep 17 00:00:00 2001 From: Araq Date: Fri, 16 Jun 2017 22:57:32 +0200 Subject: [PATCH 6/9] update kajax.nim to use the 'kxi' context too --- src/kajax.nim | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/kajax.nim b/src/kajax.nim index be230f0..414b9d2 100644 --- a/src/kajax.nim +++ b/src/kajax.nim @@ -7,10 +7,11 @@ import karax proc ajax(meth, url: cstring; headers: openarray[(cstring, cstring)]; data: cstring; - cont: proc (httpStatus: int; response: cstring)) = + cont: proc (httpStatus: int; response: cstring); + kxi: KaraxInstance = kxi) = proc contWrapper(httpStatus: int; response: cstring) = cont(httpStatus, response) - redraw() + redraw(kxi) type HttpRequest {.importc.} = ref object @@ -39,12 +40,14 @@ proc ajax(meth, url: cstring; headers: openarray[(cstring, cstring)]; proc ajaxPost*(url: cstring; headers: openarray[(cstring, cstring)]; data: cstring; - cont: proc (httpStatus: int, response: cstring)) = - ajax("POST", url, headers, data, cont) + cont: proc (httpStatus: int, response: cstring); + kxi: KaraxInstance = kxi) = + ajax("POST", url, headers, data, cont, kxi) proc ajaxGet*(url: cstring; headers: openarray[(cstring, cstring)]; - cont: proc (httpStatus: int, response: cstring)) = - ajax("GET", url, headers, nil, cont) + cont: proc (httpStatus: int, response: cstring); + kxi: KaraxInstance = kxi) = + ajax("GET", url, headers, nil, cont, kxi) proc toJson*[T](data: T): cstring {.importc: "JSON.stringify".} proc fromJson*[T](blob: cstring): T {.importc: "JSON.parse".} From 7b246d0d40612e230cd53bbbb535428711aff585 Mon Sep 17 00:00:00 2001 From: Fabian Keller Date: Sat, 17 Jun 2017 16:57:36 +0200 Subject: [PATCH 7/9] added travis link --- readme.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.rst b/readme.rst index 4aafac8..13e670a 100644 --- a/readme.rst +++ b/readme.rst @@ -1,4 +1,4 @@ -Karax -- Single page applications in Nim +Karax – Single page applications in Nim [![Build Status](https://travis-ci.org/pragmagic/karax.svg?branch=master)](https://travis-ci.org/pragmagic/karax) ======================================== Karax is a framework for developing single page applications in Nim. From 972fcb0950a275e06f3fab0b054d264cc386fdbd Mon Sep 17 00:00:00 2001 From: Fabian Keller Date: Sat, 17 Jun 2017 17:05:37 +0200 Subject: [PATCH 8/9] proper rst solution --- readme.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/readme.rst b/readme.rst index 13e670a..3fac7ad 100644 --- a/readme.rst +++ b/readme.rst @@ -1,5 +1,5 @@ -Karax – Single page applications in Nim [![Build Status](https://travis-ci.org/pragmagic/karax.svg?branch=master)](https://travis-ci.org/pragmagic/karax) -======================================== +Karax – Single page applications in Nim |travis| +================================================ Karax is a framework for developing single page applications in Nim. It's still in heavy development, so keep in mind that the API is subject @@ -33,3 +33,6 @@ Goals - Leverage Nim's macro system to produce a framework that allows for the development of applications that are boilerplate free. - Keep it small, keep it fast, keep it flexible. + +.. |travis| image:: https://travis-ci.org/pragmagic/karax.svg?branch=master + :target: https://travis-ci.org/pragmagic/karax From b189b24a4f6f3afb5856db9634a55cbf6ca86375 Mon Sep 17 00:00:00 2001 From: Fabian Keller Date: Sun, 18 Jun 2017 00:01:27 +0200 Subject: [PATCH 9/9] fixes #25 (#26) --- .gitignore | 1 + src/karaxdsl.nim | 10 ++++++++-- tests/compiler_tests.nim | 18 ++++++++++++++++++ tests/{diffDomTests.nims => nim.cfg} | 0 tests/tester.nim | 1 + 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/compiler_tests.nim rename tests/{diffDomTests.nims => nim.cfg} (100%) diff --git a/.gitignore b/.gitignore index 67d9b34..42b07a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ nimcache/ +/tests/tester \ No newline at end of file diff --git a/src/karaxdsl.nim b/src/karaxdsl.nim index a3558c8..e3e8290 100644 --- a/src/karaxdsl.nim +++ b/src/karaxdsl.nim @@ -47,12 +47,18 @@ proc tcall2(n, tmpContext: NimNode): NimNode = assert n.len == result.len if L > 0: result[L-1] = tcall2(result[L-1], tmpContext) - of nnkStmtList, nnkStmtListExpr, nnkWhenStmt, nnkIfStmt, nnkCaseStmt, - nnkTryStmt, nnkFinally: + of nnkStmtList, nnkStmtListExpr, nnkWhenStmt, nnkIfStmt, nnkTryStmt, + nnkFinally: # recurse for every child: result = copyNimNode(n) for x in n: result.add tcall2(x, tmpContext) + of nnkCaseStmt: + # recurse for children, but don't add call for case ident + result = copyNimNode(n) + result.add n[0] + for i in 1 ..< n.len: + result.add tcall2(n[i], tmpContext) of nnkVarSection, nnkLetSection, nnkConstSection: result = n of nnkCallKinds: diff --git a/tests/compiler_tests.nim b/tests/compiler_tests.nim new file mode 100644 index 0000000..4352cab --- /dev/null +++ b/tests/compiler_tests.nim @@ -0,0 +1,18 @@ +include karaxprelude + +block: + type + TestEnum {.pure.} = enum + ValA, ValB + + var e = TestEnum.ValA + + proc renderDom(): VNode {.used.} = + result = buildHtml(): + tdiv(): + case e + of TestEnum.ValA: + tdiv: text "A" + of TestEnum.ValB: + tdiv: text "B" + diff --git a/tests/diffDomTests.nims b/tests/nim.cfg similarity index 100% rename from tests/diffDomTests.nims rename to tests/nim.cfg diff --git a/tests/tester.nim b/tests/tester.nim index 5dc7426..482cad3 100644 --- a/tests/tester.nim +++ b/tests/tester.nim @@ -8,6 +8,7 @@ proc exec(cmd: string) = proc main = exec("nim js tests/diffDomTests.nim") + exec("nim js tests/compiler_tests.nim") exec("nim js examples/todoapp/todoapp.nim") exec("nim js examples/scrollapp/scrollapp.nim") exec("nim js examples/mediaplayer/playerapp.nim")