@@ -5,24 +5,34 @@ assert(vec:display() == "Vec3 { x: 1.0, y: 2.0, z: 3.0 }",
5
5
6
6
7
7
-- multiline
8
+ local function strip_alloc_ids (s )
9
+ s = s :gsub (" ReflectAllocationId%b()" , " ReflectAllocationId()" )
10
+ return s
11
+ end
12
+
8
13
local expected_vec3_debug = [[
9
14
ReflectReference {
10
15
base: ReflectBaseType {
11
16
type_id: TypeId(
12
17
"glam::Vec3",
13
18
),
14
19
base_id: Owned(
15
- ReflectAllocationId(
16
- 385,
17
- ),
20
+ ReflectAllocationId(*anything*),
18
21
),
19
22
},
20
23
reflect_path: ParsedPath(
21
24
[],
22
25
),
23
26
}
24
27
]]
25
- assert_str_eq (vec :debug (), expected_vec3_debug );
28
+ -- normalize allocation ids before comparison so tests don't fail on runtime-generated ids
29
+ do
30
+ local actual = vec :debug ()
31
+ local expected = expected_vec3_debug
32
+ actual = strip_alloc_ids (actual )
33
+ expected = strip_alloc_ids (expected )
34
+ assert_str_eq (actual , expected )
35
+ end
26
36
27
37
28
38
local test_resource = world .get_resource (types .TestResource )
@@ -45,8 +55,15 @@ ReflectReference {
45
55
}
46
56
]]
47
57
48
- assert_str_eq (test_resource :debug (), expected_test_resource_debug ,
49
- " TestResource debug incorrect, expected " .. expected_test_resource_debug .. " but got " .. test_resource :debug ())
58
+ -- normalize allocation ids before comparison so tests don't fail on runtime-generated ids
59
+ do
60
+ local actual = test_resource :debug ()
61
+ local expected = expected_test_resource_debug
62
+ actual = strip_alloc_ids (actual )
63
+ expected = strip_alloc_ids (expected )
64
+ assert_str_eq (actual , expected ,
65
+ " TestResource debug incorrect, expected " .. expected .. " but got " .. actual )
66
+ end
50
67
51
68
52
69
assert_str_eq (test_resource :display (), " TestResource { bytes: [0, 1, 2, 3, 4, 5] }" ,
0 commit comments