-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dce0fdf
commit e7fecbf
Showing
2 changed files
with
132 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,123 @@ | ||
let isDone1: boolean = false; | ||
const isDone2: boolean = false; | ||
var isDone3: boolean = false; | ||
let val1: any = null; | ||
const val2: any = null; | ||
var val3: any = null; | ||
console.log(isDone1); | ||
console.log(isDone2); | ||
console.log(isDone3); | ||
console.log(val1); | ||
console.log(val2); | ||
console.log(val3); | ||
|
||
|
||
// | ||
// Note that this is supposed to run from command line. | ||
// Do not use anything besides pause, control.runInBackground, console.log | ||
// | ||
|
||
// pause(2000) | ||
type uint8 number; | ||
type int8 number; | ||
type uint16 number; | ||
type int16 number; | ||
|
||
namespace control { | ||
function runInBackground(f: ()=>void): void { | ||
thread(f); | ||
} | ||
|
||
function dmesg(s: string): void { | ||
} | ||
} | ||
|
||
function pause(t: number) { | ||
sleep(t); | ||
} | ||
|
||
function msg(s: string): void { | ||
console.log(s) | ||
control.dmesg(s) | ||
//pause(50); | ||
} | ||
|
||
msg("start!") | ||
|
||
function assert(cond: boolean, m?: string) { | ||
if (!cond) { | ||
msg("assertion failed: ") | ||
if (m) { | ||
msg(m) | ||
} | ||
|
||
throw m; | ||
} | ||
} | ||
|
||
// | ||
// start tests | ||
// | ||
|
||
let glb1: number; | ||
let s2: string; | ||
let x: number; | ||
let action: Action; | ||
let tot: string; | ||
let lazyAcc: number; | ||
let sum: number; | ||
let u8: uint8 | ||
let i8: int8 | ||
let u16: uint16 | ||
let i16: int16 | ||
|
||
let xyz = 12; | ||
|
||
|
||
let hasFloat = true | ||
if ((1 / 10) == 0) { | ||
hasFloat = false | ||
} | ||
|
||
class Testrec { | ||
str: string; | ||
num: number; | ||
_bool: boolean; | ||
str2: string; | ||
} | ||
|
||
function clean() { | ||
glb1 = 0 | ||
s2 = "" | ||
x = 0 | ||
action = null | ||
tot = "" | ||
lazyAcc = 0 | ||
sum = 0 | ||
} | ||
function eqOp() { | ||
msg("eqOp") | ||
let x = 12 | ||
assert((x += 10) == 22, "Y0") | ||
assert(x == 22, "Y1") | ||
x /= 2 | ||
assert(x == 11, "Y2") | ||
|
||
let s = ("fo" + 1) | ||
let t = ("ba" + 2) | ||
s += t | ||
assert(s == "fo1b" + "a2", "fb") | ||
} | ||
|
||
function eqOpString() { | ||
msg("eqOpStr") | ||
let x = "fo" | ||
assert((x += "ba") == "foba", "SY0") | ||
assert(x == "foba", "SY1") | ||
} | ||
|
||
eqOp() | ||
eqOpString() | ||
|
||
function eq<A, B>(a: A, b: B) { return a == b as any as A } | ||
|
||
function eqG() { | ||
assert(eq("2", 2), "2") | ||
assert(eq(2, "2"), "2'") | ||
assert(!eq("null", null), "=1") | ||
assert(!eq(null, "null"), "=2") | ||
assert(!eq("2", 3), "=3") | ||
} | ||
|
||
eqG() | ||
clean() | ||
msg("test OK!") | ||