nx_decl_simple_scene_test.nx source
↩ module page · 71 lines · 2856 B
1// nx_decl_simple_scene_test.nx -- smoke for the composed declarator.
2//
3// expect_exit: 0
4//
5// license_tier: ORIGINAL
6
7import "nx_syscalls.nx"
8import "nx_types.nx"
9import "nx_tier.nx"
10import "nx_biome_classifier.nx"
11import "nx_decl_random_environment.nx"
12import "nx_decl_simple_scene.nx"
13
14func main() -> nx_int {
15 // ---- T1: light validity ---------------------------------------
16 if nx_ss_light_is_valid(NX_SS_LIGHT_DAWN) != 1 { return 1 }
17 if nx_ss_light_is_valid(NX_SS_LIGHT_FANTASTICAL) != 1 { return 2 }
18 if nx_ss_light_is_valid(NX_SS_LIGHT_N) != 0 { return 3 }
19 if nx_ss_light_is_valid(-1) != 0 { return 4 }
20
21 // ---- T2: REAL modifier -> valid scene + sensible fields -------
22 let s: *NxSimpleScene = nx_ss_alloc()
23 nx_decl_simple_scene(s, NX_RE_MODIFIER_REAL, 0xABCDEF)
24 if s.is_valid != 1 { return 10 }
25 if s.env.is_valid != 1 { return 11 }
26 if nx_biome_is_valid(s.env.biome) != 1 { return 12 }
27 if s.cam_distance_m <= 0 { return 13 }
28 if s.cam_fov_deg < 30 { return 14 }
29 if s.cam_fov_deg > 120 { return 15 }
30 if nx_ss_light_is_valid(s.light_kind) != 1 { return 16 }
31 if s.light_temp_kelvin < 1500 { return 17 }
32 if s.light_temp_kelvin > 10000 { return 18 }
33 if s.light_intensity_q10 < 0 { return 19 }
34 if s.light_intensity_q10 > 1024 { return 20 }
35
36 // ---- T3: FANTASY -> FANTASTICAL light, 75 FOV ----------------
37 let s2: *NxSimpleScene = nx_ss_alloc()
38 nx_decl_simple_scene(s2, NX_RE_MODIFIER_FANTASY, 0xABCDEF)
39 if s2.light_kind != NX_SS_LIGHT_FANTASTICAL { return 30 }
40 if s2.cam_fov_deg != 75 { return 31 }
41 if s2.env.size_tiles != 512 { return 32 }
42
43 // ---- T4: SCI_FI -> ALIEN light, 90 FOV -----------------------
44 let s3: *NxSimpleScene = nx_ss_alloc()
45 nx_decl_simple_scene(s3, NX_RE_MODIFIER_SCI_FI, 0xABCDEF)
46 if s3.light_kind != NX_SS_LIGHT_ALIEN { return 40 }
47 if s3.cam_fov_deg != 90 { return 41 }
48 if s3.env.size_tiles != 1024 { return 42 }
49
50 // ---- T5: determinism (same seed -> identical scene) ----------
51 let a: *NxSimpleScene = nx_ss_alloc()
52 let b: *NxSimpleScene = nx_ss_alloc()
53 nx_decl_simple_scene(a, NX_RE_MODIFIER_REAL, 42)
54 nx_decl_simple_scene(b, NX_RE_MODIFIER_REAL, 42)
55 if a.env.biome != b.env.biome { return 50 }
56 if a.cam_yaw_q14 != b.cam_yaw_q14 { return 51 }
57 if a.light_kind != b.light_kind { return 52 }
58 if a.light_temp_kelvin != b.light_temp_kelvin { return 53 }
59
60 // ---- T6: composition -- s.env fields populated -----------------
61 if a.env.river_count < 0 { return 60 }
62 if a.env.forest_count < 0 { return 61 }
63 if a.env.size_tiles != 256 { return 62 }
64
65 // ---- T7: invalid modifier -> is_valid=0 -----------------------
66 let bad: *NxSimpleScene = nx_ss_alloc()
67 nx_decl_simple_scene(bad, 999, 0)
68 if bad.is_valid != 0 { return 70 }
69
70 return 0
71}