-
Notifications
You must be signed in to change notification settings - Fork 7
/
test_runtime.d
169 lines (138 loc) · 3.14 KB
/
test_runtime.d
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// ldc2 -i=. --d-version=CarelessAlocation -i=std -Iarsd-webassembly/ -L-allow-undefined -ofserver/omg.wasm -mtriple=wasm32-unknown-unknown-wasm arsd-webassembly/core/arsd/aa arsd-webassembly/core/arsd/objectutils arsd-webassembly/core/internal/utf arsd-webassembly/core/arsd/utf_decoding hello arsd-webassembly/object.d
import arsd.webassembly;
import std.stdio;
alias thisModule = __traits(parent, {});
class A {
int _b = 200;
int a() { return 123; }
}
interface C {
void test();
}
interface D {
void check();
}
class B : A, C
{
int val;
override int a() { return 455 + val; }
void test()
{
rawlog(a());
int[] a;
a~= 1;
}
}
void rawlog(Args...)(Args a, string file = __FILE__, size_t line = __LINE__)
{
writeln(a, " at "~ file~ ":", line);
}
struct Tester
{
int b = 50;
string a = "hello";
}
void main()
{
float[] f = new float[4];
assert(f[0] is float.init);
f~= 5.5; //Append
f~= [3, 4];
int[] inlineConcatTest = [1, 2] ~ [3, 4];
auto dg = delegate()
{
writeln(inlineConcatTest[0], f[1]);
};
dg();
B b = new B;
b.val = 5;
A a = b;
a.a();
C c = b;
c.test();
assert(cast(D)c is null);
Tester[] t = new Tester[10];
assert(t[0] == Tester.init);
assert(t.length == 10);
switch("hello")
{
case "test":
writeln("broken");
break;
case "hello":
writeln("Working switch string");
break;
default: writeln("What happenned here?");
}
string strTest = "test"[0..$];
assert(strTest == "test");
Tester* structObj = new Tester(50_000, "Inline Allocation");
writeln(structObj is null, structObj.a, structObj.b);
int[string] hello = ["hello": 500];
assert(("hello" in hello) !is null, "No key hello yet...");
assert(hello["hello"] == 500, "Not 500");
hello["hello"] = 1200;
assert(hello["hello"] == 1200, "Reassign didn't work");
hello["h2o"] = 250;
assert(hello["h2o"] == 250, "New member");
int[] appendTest;
appendTest~= 50;
appendTest~= 500;
appendTest~= 5000;
foreach(v; appendTest)
writeln(v);
string strConcatTest;
strConcatTest~= "Hello";
strConcatTest~= "World";
writeln(strConcatTest);
int[] intConcatTest = cast(int[2])[1, 2];
intConcatTest~= 50;
string decInput = "a";
decInput~= "こんいちは";
foreach(dchar ch; "こんいちは")
{
decInput~= ch;
writeln(ch);
}
writeln(decInput);
int[] arrCastTest = [int.max];
foreach(v; cast(ubyte[])arrCastTest)
writeln(v);
enum Type
{
int_,
string_,
}
struct TestWithPtr
{
int* a;
Type t = Type.string_;
}
TestWithPtr[] _;
_~= TestWithPtr(new int(50), Type.int_);
_ = _[0..$-1];
_~= TestWithPtr(new int(100), Type.string_);
_~= TestWithPtr(new int(150), Type.string_);
_~= TestWithPtr(new int(200), Type.int_);
foreach(v; _)
writeln(*v.a);
char[] sup;
string rev;
// string test = null;
for(int i = 'a'; i <= 'z'; i++)
{
sup~= cast(char)i;
rev~= ('z' - cast(char)i) + 'a';
}
writeln((typeid(sup)).toString);
static foreach(mem; __traits(allMembers, std.stdio))
writeln(mem);
float[][] matrixTest = new float[][](8, 8);
foreach(array; matrixTest)
foreach(value; array)
writeln(value);
// foreach(array; matrixTest)
// foreach(value; array)
// writeln(value);
assert(false, sup~sup~sup);
}