cgen: fix tests
parent
7342dfdc6e
commit
b9955aee84
|
@ -456,8 +456,8 @@ fn (g mut Gen) expr(node ast.Expr) {
|
|||
g.write('/* as */')
|
||||
}
|
||||
ast.AssignExpr {
|
||||
g.expr(it.left)
|
||||
g.is_assign_expr = true
|
||||
g.expr(it.left)
|
||||
// arr[i] = val => `array_set(arr, i, val)`, not `array_get(arr, i) = val`
|
||||
if !g.is_array_set {
|
||||
g.write(' $it.op.str() ')
|
||||
|
|
|
@ -75,7 +75,7 @@ i < 10; i++) {
|
|||
array_int nums2 = array_slice(nums, 0, 2);
|
||||
array_int nums3 = array_slice(nums, 1, 2);
|
||||
array_int nums4 = array_slice(nums, 1, nums.len);
|
||||
int number = array_get(nums, 0);
|
||||
int number = (*(int*)array_get(nums, 0));
|
||||
array_set(&nums, 1, 10);
|
||||
array_bool bools = new_array_from_c_array(2, 2, sizeof(array_bool), (bool[]){
|
||||
true, false,
|
||||
|
@ -84,16 +84,16 @@ i < 10; i++) {
|
|||
(User){
|
||||
},
|
||||
});
|
||||
bool b = array_get(bools, 0);
|
||||
bool b = (*(bool*)array_get(bools, 0));
|
||||
array_string mystrings = new_array_from_c_array(2, 2, sizeof(array_string), (string[]){
|
||||
tos3("a"), tos3("b"),
|
||||
});
|
||||
string s = array_get(mystrings, 0);
|
||||
string s = (*(string*)array_get(mystrings, 0));
|
||||
int x = 0;
|
||||
x = get_int2();
|
||||
int n = get_int2();
|
||||
bool q = true || false;
|
||||
bool b2 = array_get(bools, 0) || true;
|
||||
bool b2 = (*(bool*)array_get(bools, 0)) || true;
|
||||
bool b3 = get_bool() || true;
|
||||
int f = array_first(nums);
|
||||
string d = tos3("d");
|
||||
|
|
|
@ -50,7 +50,7 @@ int main() {
|
|||
array_Foo arr_foo = new_array_from_c_array(1, 1, sizeof(array_Foo), (Foo[]){
|
||||
a,
|
||||
});
|
||||
Foo af_idx_el = array_get(arr_foo, 0);
|
||||
Foo af_idx_el = (*(Foo*)array_get(arr_foo, 0));
|
||||
string foo_a = af_idx_el.a;
|
||||
map_string_string m1 = new_map(1, sizeof(string));
|
||||
map_string_int m2 = new_map_init(2, sizeof(int), (string[2]){tos3("v"), tos3("lang"), }, (int[2]){1, 2, });
|
||||
|
|
Loading…
Reference in New Issue