Implement codegenDecl for js (#6851)
This commit is contained in:
parent
d27c0b2192
commit
1699d7c2a4
3 changed files with 54 additions and 11 deletions
11
tests/js/tcodegendeclproc.nim
Normal file
11
tests/js/tcodegendeclproc.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
discard """
|
||||
output: '''
|
||||
-1
|
||||
8
|
||||
'''
|
||||
ccodecheck: "'console.log(-1); function fac_' \\d+ '(n_' \\d+ ')'"
|
||||
"""
|
||||
proc fac(n: int): int {.codegenDecl: "console.log(-1); function $2($3)".} =
|
||||
return n
|
||||
|
||||
echo fac(8)
|
||||
10
tests/js/tcodegendeclvar.nim
Normal file
10
tests/js/tcodegendeclvar.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
discard """
|
||||
output: '''
|
||||
-1
|
||||
2
|
||||
'''
|
||||
ccodecheck: "'console.log(-1); var v_' \\d+ ' = [2]'"
|
||||
"""
|
||||
|
||||
var v {.codegenDecl: "console.log(-1); var $2".} = 2
|
||||
echo v
|
||||
Loading…
Add table
Add a link
Reference in a new issue