mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Top level $if now uses $if: / $endif; Fix of boolean globals. Fix of $else: clause. Fix of $assert inside of $if
This commit is contained in:
committed by
Christoffer Lerno
parent
321ee81c9d
commit
9572c4afc9
65
test/test_suite/compile_time/ct_if.c3t
Normal file
65
test/test_suite/compile_time/ct_if.c3t
Normal file
@@ -0,0 +1,65 @@
|
||||
$if (0):
|
||||
$else:
|
||||
$if (0):
|
||||
$elif (0):
|
||||
$elif (0):
|
||||
$else:
|
||||
int x = 1;
|
||||
$endif;
|
||||
$endif;
|
||||
|
||||
$if (0):
|
||||
$assert(false);
|
||||
$elif (0):
|
||||
$assert(false);
|
||||
$else:
|
||||
$assert(true);
|
||||
$endif;
|
||||
|
||||
$if (1):
|
||||
$assert(true);
|
||||
int d = 5;
|
||||
$elif (0):
|
||||
$assert(false);
|
||||
$else:
|
||||
$assert(false);
|
||||
$endif;
|
||||
|
||||
$if (0):
|
||||
$assert(true);
|
||||
$elif (1):
|
||||
$assert(true);
|
||||
int c = 5;
|
||||
$else:
|
||||
$assert(false);
|
||||
$endif;
|
||||
|
||||
$if (0):
|
||||
$assert(true);
|
||||
$elif (1):
|
||||
$assert(true);
|
||||
int b = 4;
|
||||
$elif (0):
|
||||
$assert(false);
|
||||
$else:
|
||||
$assert(false);
|
||||
$endif;
|
||||
|
||||
$if (0):
|
||||
$assert(true);
|
||||
$elif (0):
|
||||
$assert(false);
|
||||
$elif (1):
|
||||
$assert(true);
|
||||
int a = 3;
|
||||
$else:
|
||||
$assert(false);
|
||||
$endif;
|
||||
|
||||
// #expect: ct_if.ll
|
||||
|
||||
@ct_if.d = global i32 5, align 4
|
||||
@ct_if.c = global i32 5, align 4
|
||||
@ct_if.b = global i32 4, align 4
|
||||
@ct_if.a = global i32 3, align 4
|
||||
@ct_if.x = global i32 1, align 4
|
||||
31
test/test_suite/compile_time/ct_if_fails.c3
Normal file
31
test/test_suite/compile_time/ct_if_fails.c3
Normal file
@@ -0,0 +1,31 @@
|
||||
$if 3: // #error: Expected '('
|
||||
$endif;
|
||||
|
||||
int x;
|
||||
$if (x > 0):
|
||||
$endif;
|
||||
|
||||
$if (0):
|
||||
$assert(false);
|
||||
$endif;
|
||||
|
||||
$if (1):
|
||||
$else:
|
||||
$endif;
|
||||
|
||||
$if (1):
|
||||
$else:
|
||||
$else: // #error: Expected a top level declaration here.
|
||||
$endif;
|
||||
|
||||
|
||||
$if (1):
|
||||
$elif (2):
|
||||
$else:
|
||||
$endif;
|
||||
|
||||
$if (1):
|
||||
$elif (2):
|
||||
$elif (3):
|
||||
$else:
|
||||
$endif;
|
||||
Reference in New Issue
Block a user