booleans, comparisons, and if/else
This commit is contained in:
@@ -1793,6 +1793,27 @@ sentinel_pointer_views_compile_and_run :: proc(t: ^testing.T) {
|
||||
testing.expect_value(t, state.exit_code, 303)
|
||||
}
|
||||
|
||||
@(test)
|
||||
control_flow_compiles_and_runs :: proc(t: ^testing.T) {
|
||||
output := "/tmp/brolang-test-control-flow"
|
||||
defer _ = os.remove(output)
|
||||
status := compiler_core.compile_package("examples/programs/control_flow", output)
|
||||
testing.expect_value(t, status, 0)
|
||||
state, stdout, stderr, _ := os2.process_exec(
|
||||
os2.Process_Desc{command=[]string{output}},
|
||||
context.allocator,
|
||||
)
|
||||
defer delete(stdout)
|
||||
defer delete(stderr)
|
||||
// if / else if / else, comparisons, logical and/or/not, bool locals, and
|
||||
// block scoping together produce 42.
|
||||
testing.expect_value(t, state.exit_code, 42)
|
||||
// Short-circuit: `noisy()` is never reached, so its output must be absent,
|
||||
// while the taken or-branch must print.
|
||||
testing.expect(t, !strings.contains(string(stdout), "rhs-evaluated"))
|
||||
testing.expect(t, strings.contains(string(stdout), "or-taken"))
|
||||
}
|
||||
|
||||
@(test)
|
||||
foreign_function_links_from_c_source :: proc(t: ^testing.T) {
|
||||
output := "/tmp/brolang-test-foreign-source"
|
||||
|
||||
Reference in New Issue
Block a user