forked from AssemblyScript/assemblyscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathif.ts
More file actions
38 lines (32 loc) · 626 Bytes
/
if.ts
File metadata and controls
38 lines (32 loc) · 626 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
export function ifThenElse(n: i32): bool {
if (n)
return true;
else
return false;
}
assert(ifThenElse(0) == false);
assert(ifThenElse(1) == true);
export function ifThen(n: i32): bool {
if (n)
return true;
return false;
}
assert(ifThen(0) == false);
assert(ifThen(1) == true);
export function ifThenElseBlock(n: i32): bool {
if (n) {
; // nop
return true;
} else {
; // nop
return false;
}
}
assert(ifThenElseBlock(0) == false);
assert(ifThenElseBlock(1) == true);
export function ifAlwaysReturns(n: i32): bool {
if (n)
return true;
else
throw new Error("error");
}