@@ -38,7 +38,7 @@ let passed = 0;
3838let failed = 0 ;
3939
4040// Test 1: Basic throttle override still works
41- passed += runTest ( 'throttle override compiles' , ( ) => {
41+ if ( runTest ( 'throttle override compiles' , ( ) => {
4242 const code = `
4343const { flight, override } = inav;
4444if (flight.isArmed) {
@@ -51,10 +51,14 @@ if (flight.isArmed) {
5151 }
5252 assertEquals ( result . success , true , 'Compilation should succeed' ) ;
5353 assertContains ( result . commands . join ( ' ' ) , '29' , 'Should contain operation 29 (OVERRIDE_THROTTLE)' ) ;
54- } ) ;
54+ } ) ) {
55+ passed ++ ;
56+ } else {
57+ failed ++ ;
58+ }
5559
5660// Test 2: VTX override with nested object still works
57- passed += runTest ( 'vtx.power override compiles' , ( ) => {
61+ if ( runTest ( 'vtx.power override compiles' , ( ) => {
5862 const code = `
5963const { flight, override } = inav;
6064if (flight.homeDistance > 100) {
@@ -67,10 +71,14 @@ if (flight.homeDistance > 100) {
6771 }
6872 assertEquals ( result . success , true , 'Compilation should succeed' ) ;
6973 assertContains ( result . commands . join ( ' ' ) , '25' , 'Should contain operation 25 (SET_VTX_POWER_LEVEL)' ) ;
70- } ) ;
74+ } ) ) {
75+ passed ++ ;
76+ } else {
77+ failed ++ ;
78+ }
7179
7280// Test 3: VTX band override
73- passed += runTest ( 'vtx.band override compiles' , ( ) => {
81+ if ( runTest ( 'vtx.band override compiles' , ( ) => {
7482 const code = `
7583const { override } = inav;
7684override.vtx.band = 2;
@@ -81,10 +89,14 @@ override.vtx.band = 2;
8189 throw new Error ( `Compilation failed: ${ result . error } ` ) ;
8290 }
8391 assertContains ( result . commands . join ( ' ' ) , '30' , 'Should contain operation 30 (SET_VTX_BAND)' ) ;
84- } ) ;
92+ } ) ) {
93+ passed ++ ;
94+ } else {
95+ failed ++ ;
96+ }
8597
8698// Test 4: VTX channel override
87- passed += runTest ( 'vtx.channel override compiles' , ( ) => {
99+ if ( runTest ( 'vtx.channel override compiles' , ( ) => {
88100 const code = `
89101const { override } = inav;
90102override.vtx.channel = 5;
@@ -95,10 +107,14 @@ override.vtx.channel = 5;
95107 throw new Error ( `Compilation failed: ${ result . error } ` ) ;
96108 }
97109 assertContains ( result . commands . join ( ' ' ) , '31' , 'Should contain operation 31 (SET_VTX_CHANNEL)' ) ;
98- } ) ;
110+ } ) ) {
111+ passed ++ ;
112+ } else {
113+ failed ++ ;
114+ }
99115
100116// Test 5: Throttle scale override
101- passed += runTest ( 'throttleScale override compiles' , ( ) => {
117+ if ( runTest ( 'throttleScale override compiles' , ( ) => {
102118 const code = `
103119const { override } = inav;
104120override.throttleScale = 75;
@@ -109,10 +125,14 @@ override.throttleScale = 75;
109125 throw new Error ( `Compilation failed: ${ result . error } ` ) ;
110126 }
111127 assertContains ( result . commands . join ( ' ' ) , '23' , 'Should contain operation 23 (OVERRIDE_THROTTLE_SCALE)' ) ;
112- } ) ;
128+ } ) ) {
129+ passed ++ ;
130+ } else {
131+ failed ++ ;
132+ }
113133
114134// Test 6: Arm safety override
115- passed += runTest ( 'armSafety override compiles' , ( ) => {
135+ if ( runTest ( 'armSafety override compiles' , ( ) => {
116136 const code = `
117137const { override } = inav;
118138override.armSafety = true;
@@ -123,10 +143,14 @@ override.armSafety = true;
123143 throw new Error ( `Compilation failed: ${ result . error } ` ) ;
124144 }
125145 assertContains ( result . commands . join ( ' ' ) , '22' , 'Should contain operation 22 (OVERRIDE_ARMING_SAFETY)' ) ;
126- } ) ;
146+ } ) ) {
147+ passed ++ ;
148+ } else {
149+ failed ++ ;
150+ }
127151
128152// Test 7: OSD layout override
129- passed += runTest ( 'osdLayout override compiles' , ( ) => {
153+ if ( runTest ( 'osdLayout override compiles' , ( ) => {
130154 const code = `
131155const { override } = inav;
132156override.osdLayout = 2;
@@ -137,10 +161,14 @@ override.osdLayout = 2;
137161 throw new Error ( `Compilation failed: ${ result . error } ` ) ;
138162 }
139163 assertContains ( result . commands . join ( ' ' ) , '32' , 'Should contain operation 32 (SET_OSD_LAYOUT)' ) ;
140- } ) ;
164+ } ) ) {
165+ passed ++ ;
166+ } else {
167+ failed ++ ;
168+ }
141169
142170// Test 8: Loiter radius override
143- passed += runTest ( 'loiterRadius override compiles' , ( ) => {
171+ if ( runTest ( 'loiterRadius override compiles' , ( ) => {
144172 const code = `
145173const { override } = inav;
146174override.loiterRadius = 5000;
@@ -151,10 +179,14 @@ override.loiterRadius = 5000;
151179 throw new Error ( `Compilation failed: ${ result . error } ` ) ;
152180 }
153181 assertContains ( result . commands . join ( ' ' ) , '41' , 'Should contain operation 41 (LOITER_OVERRIDE)' ) ;
154- } ) ;
182+ } ) ) {
183+ passed ++ ;
184+ } else {
185+ failed ++ ;
186+ }
155187
156188// Test 9: Min ground speed override
157- passed += runTest ( 'minGroundSpeed override compiles' , ( ) => {
189+ if ( runTest ( 'minGroundSpeed override compiles' , ( ) => {
158190 const code = `
159191const { override } = inav;
160192override.minGroundSpeed = 10;
@@ -165,10 +197,14 @@ override.minGroundSpeed = 10;
165197 throw new Error ( `Compilation failed: ${ result . error } ` ) ;
166198 }
167199 assertContains ( result . commands . join ( ' ' ) , '56' , 'Should contain operation 56 (OVERRIDE_MIN_GROUND_SPEED)' ) ;
168- } ) ;
200+ } ) ) {
201+ passed ++ ;
202+ } else {
203+ failed ++ ;
204+ }
169205
170206// Test 10: Multiple overrides in one block
171- passed += runTest ( 'multiple overrides in same block' , ( ) => {
207+ if ( runTest ( 'multiple overrides in same block' , ( ) => {
172208 const code = `
173209const { flight, override } = inav;
174210if (flight.isArmed) {
@@ -182,10 +218,14 @@ if (flight.isArmed) {
182218 }
183219 assertContains ( result . commands . join ( ' ' ) , '29' , 'Should contain OVERRIDE_THROTTLE' ) ;
184220 assertContains ( result . commands . join ( ' ' ) , '25' , 'Should contain SET_VTX_POWER_LEVEL' ) ;
185- } ) ;
221+ } ) ) {
222+ passed ++ ;
223+ } else {
224+ failed ++ ;
225+ }
186226
187227// Test 11: Flight axis override doesn't break other overrides
188- passed += runTest ( 'flight axis and regular overrides together' , ( ) => {
228+ if ( runTest ( 'flight axis and regular overrides together' , ( ) => {
189229 const code = `
190230const { flight, override } = inav;
191231if (flight.isArmed) {
@@ -201,21 +241,29 @@ if (flight.isArmed) {
201241 assertContains ( result . commands . join ( ' ' ) , '45' , 'Should contain FLIGHT_AXIS_ANGLE_OVERRIDE' ) ;
202242 assertContains ( result . commands . join ( ' ' ) , '29' , 'Should contain OVERRIDE_THROTTLE' ) ;
203243 assertContains ( result . commands . join ( ' ' ) , '25' , 'Should contain SET_VTX_POWER_LEVEL' ) ;
204- } ) ;
244+ } ) ) {
245+ passed ++ ;
246+ } else {
247+ failed ++ ;
248+ }
205249
206250// Test 12: Invalid override target should fail gracefully
207- passed += runTest ( 'invalid override target produces error' , ( ) => {
251+ if ( runTest ( 'invalid override target produces error' , ( ) => {
208252 const code = `
209253const { override } = inav;
210254override.invalidProperty = 100;
211255` ;
212256 const transpiler = new Transpiler ( ) ;
213257 const result = transpiler . transpile ( code ) ;
214258 assertEquals ( result . success , false , 'Compilation should fail' ) ;
215- } ) ;
259+ } ) ) {
260+ passed ++ ;
261+ } else {
262+ failed ++ ;
263+ }
216264
217265// Test 13: Decompile existing overrides
218- passed += runTest ( 'decompile throttle override' , ( ) => {
266+ if ( runTest ( 'decompile throttle override' , ( ) => {
219267 const decompiler = new Decompiler ( ) ;
220268 const lcs = [
221269 {
@@ -234,10 +282,14 @@ passed += runTest('decompile throttle override', () => {
234282 throw new Error ( `Decompilation failed: ${ result . error || JSON . stringify ( result ) } ` ) ;
235283 }
236284 assertContains ( result . code , 'override.throttle' , 'Should contain override.throttle' ) ;
237- } ) ;
285+ } ) ) {
286+ passed ++ ;
287+ } else {
288+ failed ++ ;
289+ }
238290
239291// Test 14: Decompile VTX power
240- passed += runTest ( 'decompile vtx.power override' , ( ) => {
292+ if ( runTest ( 'decompile vtx.power override' , ( ) => {
241293 const decompiler = new Decompiler ( ) ;
242294 const lcs = [
243295 {
@@ -256,7 +308,11 @@ passed += runTest('decompile vtx.power override', () => {
256308 throw new Error ( `Decompilation failed: ${ result . error || JSON . stringify ( result ) } ` ) ;
257309 }
258310 assertContains ( result . code , 'override.vtx.power' , 'Should contain override.vtx.power' ) ;
259- } ) ;
311+ } ) ) {
312+ passed ++ ;
313+ } else {
314+ failed ++ ;
315+ }
260316
261317console . log ( '\n==================================================' ) ;
262318console . log ( `📊 Test Results:` ) ;
0 commit comments