Skip to content

Commit 151c18f

Browse files
committed
Added test case for basic type casting trait
1 parent 57b5b13 commit 151c18f

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

Diff for: tests/run.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def prepare(executable, dir, entry):
3030
folder = join(dir, entry.name)
3131
is_mod = exists(join(folder, "_.adept"))
3232

33-
cmd = [executable]
33+
cmd = [executable, "--infrastructure", "infrastructure"]
3434

3535
if is_mod:
3636
cmd.append(folder)

Diff for: tests/success/cast_trait/main.adept

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
pragma => {
3+
adept("3.0")
4+
use("std", import("std"))
5+
importNamespace("std")
6+
}
7+
8+
#[foreign]
9+
func printf(format ptr<char>, ...) int
10+
11+
func main {
12+
castTest(1234)::(myCastIntToDouble, myCastIntToLongLong)
13+
}
14+
15+
#[using std/Cast<int, double>]
16+
#[using std/Cast<int, longlong>]
17+
func castTest(x int) {
18+
printf(c"%d %f %lld\n", x, x.cast<double>(), x.cast<longlong>())
19+
}
20+
21+
impl std/Cast<int, double> myCastIntToDouble {
22+
func cast(from int) double {
23+
return from.double()
24+
}
25+
}
26+
27+
impl std/Cast<int, longlong> myCastIntToLongLong {
28+
func cast(from int) longlong {
29+
return from.longlong()
30+
}
31+
}

0 commit comments

Comments
 (0)