-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathif_else_test.fun
More file actions
executable file
·52 lines (42 loc) · 1.04 KB
/
if_else_test.fun
File metadata and controls
executable file
·52 lines (42 loc) · 1.04 KB
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
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://fun-lang.xyz/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the Apache-2.0 license.
* https://opensource.org/license/apache-2-0
*/
/*
* Conditional Logic Testing Suite
*
* Tests various aspects of conditional execution including:
* - Basic if/else structures
* - Nested conditional statements
* - Ternary operator usage (`? :`)
* - Comparison conditionals with different operators
*/
// Test else / else if chains and nested if-blocks (two-space indentation)
print("=== if/else-if/else test ===")
number n = 42
if (n < 0)
print("neg")
else if (n == 0)
print("zero")
else if (n < 10)
print("small")
else
print("big") // expect: big
// Nested if inside a true branch
if (n >= 10)
print(n) // expect: 42
if (n == 42)
print("answer") // expect: answer
print("=== if/else-if/else done ===")
/* Expected output:
=== if/else-if/else test ===
big
42
answer
=== if/else-if/else done ===
*/