From e1a82987af8a394e6bcb7a36c9a298074472db19 Mon Sep 17 00:00:00 2001 From: dom96 Date: Mon, 31 Oct 2011 15:39:01 +0000 Subject: [PATCH] Fixed the tester. Some fixes and additions for the JS backend. --- compiler/ecmasgen.nim | 2 +- lib/pure/math.nim | 4 ++-- lib/system/ecmasys.nim | 3 ++- tests/tester.nim | 18 +++++++++--------- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/compiler/ecmasgen.nim b/compiler/ecmasgen.nim index d7af07e60c..3d9e99d445 100755 --- a/compiler/ecmasgen.nim +++ b/compiler/ecmasgen.nim @@ -1141,7 +1141,7 @@ proc genMagic(p: var TProc, n: PNode, r: var TCompRes) = [filen, line, mergeExpr(a)]) of mNew, mNewFinalize: genNew(p, n, r) of mSizeOf: r.res = toRope(getSize(n.sons[1].typ)) - of mChr: gen(p, n.sons[1], r) # nothing to do + of mChr, mArrToSeq: gen(p, n.sons[1], r) # nothing to do of mOrd: genOrd(p, n, r) of mLengthStr: unaryExpr(p, n, r, "", "($1.length-1)") of mLengthSeq, mLengthOpenArray, mLengthArray: diff --git a/lib/pure/math.nim b/lib/pure/math.nim index c44d786b14..972b013c3b 100755 --- a/lib/pure/math.nim +++ b/lib/pure/math.nim @@ -190,7 +190,7 @@ when not defined(ECMAScript): else: proc mathrandom(): float {.importc: "Math.random", nodecl.} proc floor*(x: float): float {.importc: "Math.floor", nodecl.} - proc random*(max: int): int = return floor(mathrandom() * max) + proc random*(max: int): int = return int(floor(mathrandom() * float(max))) proc randomize*() = nil proc sqrt*(x: float): float {.importc: "Math.sqrt", nodecl.} @@ -204,7 +204,7 @@ else: proc frexp*(x: float, exponent: var int): float = if x == 0.0: - exponent = 0.0 + exponent = 0 result = 0.0 elif x < 0.0: result = -frexp(-x, exponent) diff --git a/lib/system/ecmasys.nim b/lib/system/ecmasys.nim index e0d7db2ef6..9951811d18 100755 --- a/lib/system/ecmasys.nim +++ b/lib/system/ecmasys.nim @@ -7,7 +7,8 @@ # distribution, for details about the copyright. # -proc alert(s: cstring) {.importc, nodecl.} +proc alert*(s: cstring) {.importc, nodecl.} +proc log*(s: cstring) {.importc: "console.log", nodecl.} type PSafePoint = ptr TSafePoint diff --git a/tests/tester.nim b/tests/tester.nim index 5d596bc553..8d9df28246 100755 --- a/tests/tester.nim +++ b/tests/tester.nim @@ -288,25 +288,25 @@ proc runRodFiles(r: var TResults, options: string) = delNimCache() # test basic recompilation scheme: - test "hallo" - test "hallo" + test "hallo.nim" + test "hallo.nim" # test incremental type information: - test "hallo2" + test "hallo2.nim" delNimCache() # test type converters: - test "aconv" - test "bconv" + test "aconv.nim" + test "bconv.nim" delNimCache() # test G, A, B example from the documentation; test init sections: - test "deada" - test "deada2" + test "deada.nim" + test "deada2.nim" delNimCache() # test method generation: - test "bmethods" - test "bmethods2" + test "bmethods.nim" + test "bmethods2.nim" delNimCache()