-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
11 changed files
with
293 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
void test_array() | ||
{ | ||
int[10] a; | ||
a[5] = a[5] + a[0]; | ||
a[0][0] = 1; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
void test_bitwise() | ||
{ | ||
int val_int; | ||
|
||
if (val_int & false) { | ||
} | ||
if (val_int & 0x01) { | ||
} | ||
if (val_int << 1) { | ||
} | ||
|
||
val_int <<= 1; | ||
val_int = val_int << 1; | ||
val_int = 1 >> val_int; | ||
val_int = ~(1 ^ 1); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
bool gblobal; | ||
|
||
bool retbtrue() | ||
{ | ||
return true; | ||
} | ||
|
||
bool retbfalse() | ||
{ | ||
return false; | ||
} | ||
|
||
void test_bool() | ||
{ | ||
bool v; | ||
v = retbtrue(); | ||
v = gblobal; | ||
v = !gblobal; | ||
v = 1 > 2; | ||
v = false || true; | ||
v = false && true || gblobal && !(null == null); | ||
v = false && 1; | ||
v = gblobal != true; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,129 @@ | ||
void test_complex_types() | ||
{ | ||
abilcmd val_abilcmd; | ||
actor val_actor; | ||
actorscope val_actorscope; | ||
aifilter val_aifilter; | ||
bank val_bank; | ||
bitmask val_bitmask; | ||
camerainfo val_camerainfo; | ||
color val_color; | ||
doodad val_doodad; | ||
handle val_handle; | ||
generichandle val_generichandle; | ||
effecthistory val_effecthistory; | ||
marker val_marker; | ||
order val_order; | ||
playergroup val_playergroup; | ||
point val_point; | ||
region val_region; | ||
revealer val_revealer; | ||
sound val_sound; | ||
soundlink val_soundlink; | ||
timer val_timer; | ||
transmissionsource val_transmissionsource; | ||
trigger val_trigger; | ||
unit val_unit; | ||
unitfilter val_unitfilter; | ||
unitgroup val_unitgroup; | ||
unitref val_unitref; | ||
wave val_wave; | ||
waveinfo val_waveinfo; | ||
wavetarget val_wavetarget; | ||
|
||
// null | ||
val_abilcmd = null; | ||
val_actor = null; | ||
val_actorscope = null; | ||
val_aifilter = null; | ||
val_bank = null; | ||
val_bitmask = null; | ||
val_camerainfo = null; | ||
// val_color = null; | ||
val_doodad = null; | ||
val_handle = null; | ||
val_generichandle = null; | ||
val_effecthistory = null; | ||
val_marker = null; | ||
val_order = null; | ||
val_playergroup = null; | ||
val_point = null; | ||
val_region = null; | ||
val_revealer = null; | ||
val_sound = null; | ||
val_soundlink = null; | ||
val_timer = null; | ||
val_transmissionsource = null; | ||
val_trigger = null; | ||
val_unit = null; | ||
val_unitfilter = null; | ||
val_unitgroup = null; | ||
val_unitref = null; | ||
val_wave = null; | ||
val_waveinfo = null; | ||
val_wavetarget = null; | ||
|
||
// to handle | ||
val_handle = val_abilcmd; | ||
val_handle = val_actor; | ||
val_handle = val_actorscope; | ||
val_handle = val_aifilter; | ||
val_handle = val_bank; | ||
val_handle = val_bitmask; | ||
val_handle = val_camerainfo; | ||
// val_handle = val_color; | ||
// val_handle = val_doodad; | ||
val_handle = val_handle; | ||
val_handle = val_generichandle; | ||
val_handle = val_effecthistory; | ||
val_handle = val_marker; | ||
val_handle = val_order; | ||
val_handle = val_playergroup; | ||
val_handle = val_point; | ||
val_handle = val_region; | ||
// val_handle = val_revealer; | ||
val_handle = val_sound; | ||
val_handle = val_soundlink; | ||
val_handle = val_timer; | ||
val_handle = val_transmissionsource; | ||
// val_handle = val_trigger; | ||
// val_handle = val_unit; | ||
val_handle = val_unitfilter; | ||
val_handle = val_unitgroup; | ||
val_handle = val_unitref; | ||
// val_handle = val_wave; | ||
val_handle = val_waveinfo; | ||
val_handle = val_wavetarget; | ||
|
||
// from handle | ||
val_abilcmd = val_handle; | ||
val_actor = val_handle; | ||
val_actorscope = val_handle; | ||
val_aifilter = val_handle; | ||
val_bank = val_handle; | ||
val_bitmask = val_handle; | ||
val_camerainfo = val_handle; | ||
// val_color = val_handle; | ||
// val_doodad = val_handle; | ||
val_handle = val_handle; | ||
val_generichandle = val_handle; | ||
val_effecthistory = val_handle; | ||
val_marker = val_handle; | ||
val_order = val_handle; | ||
val_playergroup = val_handle; | ||
val_point = val_handle; | ||
val_region = val_handle; | ||
// val_revealer = val_handle; | ||
val_sound = val_handle; | ||
val_soundlink = val_handle; | ||
val_timer = val_handle; | ||
val_transmissionsource = val_handle; | ||
// val_trigger = val_handle; | ||
// val_unit = val_handle; | ||
val_unitfilter = val_handle; | ||
val_unitgroup = val_handle; | ||
val_unitref = val_handle; | ||
// val_wave = val_handle; | ||
val_waveinfo = val_handle; | ||
val_wavetarget = val_handle; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
int call_int(int p1) | ||
{ | ||
return p1; | ||
} | ||
|
||
void test() | ||
{ | ||
int val_int; | ||
string val_str; | ||
val_int = call_int(val_int); | ||
val_int = call_int(val_str); | ||
val_str = call_int(val_int); | ||
call_int(null); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
void fn_prototype_t(int a); | ||
void fn_prototype_x(int a); | ||
void fn_prototype_c(int a, int b); | ||
|
||
void test_funcref() | ||
{ | ||
funcref<fn_prototype_t> ref; | ||
ref = fn_prototype_t; | ||
ref = fn_prototype_x; | ||
ref = fn_prototype_c; | ||
ref(1, 1); | ||
ref(ref(1)); | ||
|
||
ref = ref; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
void test_loop() | ||
{ | ||
break; | ||
continue; | ||
|
||
for (;;) { | ||
break; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/fixtures/type_checker/diagnostics/numeric_assignment.galaxy
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
int test() | ||
{ | ||
int val_int; | ||
fixed val_fixed; | ||
byte val_byte; | ||
|
||
val_int = 1; | ||
val_int = 1.0; | ||
val_int = val_fixed; | ||
|
||
val_byte = 0; | ||
val_byte = val_int; | ||
val_byte = val_fixed; | ||
|
||
val_fixed = 1.0; | ||
val_fixed = val_int; | ||
val_fixed = val_byte; | ||
} |
27 changes: 27 additions & 0 deletions
27
tests/fixtures/type_checker/diagnostics/numeric_comparison.galaxy
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
int test() | ||
{ | ||
int val_int; | ||
fixed val_fixed; | ||
byte val_byte; | ||
|
||
if (val_int) {} | ||
if (val_fixed) {} | ||
if (val_byte) {} | ||
|
||
if (!val_int) {} | ||
if (!val_fixed) {} | ||
if (!val_byte) {} | ||
|
||
if (val_int == val_fixed) {} | ||
if (val_int == val_byte) {} | ||
if (val_int == 1) {} | ||
if (val_int == 1.0) {} | ||
|
||
if (val_byte == val_fixed) {} | ||
if (val_byte == val_byte) {} | ||
if (val_byte == 1) {} | ||
if (val_byte == 1.0) {} | ||
|
||
if (val_int == null) {} | ||
if (val_int == "") {} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
void test_string() | ||
{ | ||
string s = "a" + "a" + s + s + "b"; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
struct struct1_t { | ||
int a; | ||
int b; | ||
}; | ||
|
||
struct struct2_t { | ||
int a; | ||
int b; | ||
}; | ||
|
||
void pass_struct1(struct1_t sref) | ||
{ | ||
} | ||
|
||
void pass_struct2(structref<struct1_t> sref) | ||
{ | ||
} | ||
|
||
void test_struct() | ||
{ | ||
struct1_t st1; | ||
struct2_t st2; | ||
|
||
st1 = st1; | ||
st1 = st2; | ||
st1.a = st2.b; | ||
|
||
pass_struct1(st1); | ||
pass_struct2(st1); | ||
pass_struct2(st2); | ||
} |