@@ -188,53 +188,6 @@ export class ExpressionTests {
188188 Expect ( util . transpileString ( input ) ) . toBe ( lua ) ;
189189 }
190190
191- @Test ( "Arrow Function Expression" )
192- public arrowFunctionExpression ( ) {
193- // Transpile
194- const lua = util . transpileString ( `let add = (a, b) => a+b; return add(1,2);` ) ;
195-
196- // Execute
197- const result = util . executeLua ( lua ) ;
198-
199- // Assert
200- Expect ( result ) . toBe ( 3 ) ;
201- }
202-
203- @TestCase ( [ ] )
204- @TestCase ( [ 5 ] )
205- @TestCase ( [ 1 , 2 ] )
206- @Test ( "Arrow Default Values" )
207- public arrowFunctionDefaultValues ( inp : number [ ] ) {
208- // Default value is 3 for v1
209- const v1 = inp . length > 0 ? inp [ 0 ] : 3 ;
210- // Default value is 4 for v2
211- const v2 = inp . length > 1 ? inp [ 1 ] : 4 ;
212-
213- const callArgs = inp . join ( "," ) ;
214-
215- // Transpile
216- const lua = util . transpileString ( `let add = (a: number = 3, b: number = 4) => { return a+b; }`
217- + `return add(${ callArgs } );` ) ;
218-
219- // Execute
220- const result = util . executeLua ( lua ) ;
221-
222- // Assert
223- Expect ( result ) . toBe ( v1 + v2 ) ;
224- }
225-
226- @Test ( "Function Expression" )
227- public functionExpression ( ) {
228- // Transpile
229- const lua = util . transpileString ( `let add = function(a, b) {return a+b}; return add(1,2);` ) ;
230-
231- // Execute
232- const result = util . executeLua ( lua ) ;
233-
234- // Assert
235- Expect ( result ) . toBe ( 3 ) ;
236- }
237-
238191 @Test ( "Null Expression" )
239192 public nullExpression ( ) {
240193 Expect ( util . transpileString ( "null" ) ) . toBe ( "nil" ) ;
@@ -245,29 +198,6 @@ export class ExpressionTests {
245198 Expect ( util . transpileString ( "undefined" ) ) . toBe ( "nil" ) ;
246199 }
247200
248- @TestCase ( [ ] , 7 )
249- @TestCase ( [ 5 ] , 9 )
250- @TestCase ( [ 1 , 2 ] , 3 )
251- @Test ( "Arrow Default Values" )
252- public functionExpressionDefaultValues ( inp : number [ ] ) {
253- // Default value is 3 for v1
254- const v1 = inp . length > 0 ? inp [ 0 ] : 3 ;
255- // Default value is 4 for v2
256- const v2 = inp . length > 1 ? inp [ 1 ] : 4 ;
257-
258- const callArgs = inp . join ( "," ) ;
259-
260- // Transpile
261- const lua = util . transpileString ( `let add = function(a: number = 3, b: number = 4) { return a+b; }`
262- + `return add(${ callArgs } );` ) ;
263-
264- // Execute
265- const result = util . executeLua ( lua ) ;
266-
267- // Assert
268- Expect ( result ) . toBe ( v1 + v2 ) ;
269- }
270-
271201 @TestCase ( "inst.field" , 8 )
272202 @TestCase ( "inst.field + 3" , 8 + 3 )
273203 @TestCase ( "inst.field * 3" , 8 * 3 )
@@ -330,104 +260,6 @@ export class ExpressionTests {
330260 Expect ( result ) . toBe ( expected ) ;
331261 }
332262
333- @Test ( "Class method call" )
334- public classMethod ( ) {
335- const returnValue = 4 ;
336- const source = `class TestClass {
337- public classMethod(): number { return ${ returnValue } ; }
338- }
339-
340- const classInstance = new TestClass();
341- return classInstance.classMethod();` ;
342-
343- // Transpile
344- const lua = util . transpileString ( source ) ;
345-
346- // Execute
347- const result = util . executeLua ( lua ) ;
348-
349- // Assert
350- Expect ( result ) . toBe ( returnValue ) ;
351- }
352-
353- @Test ( "Class dot method call void" )
354- public classDotMethod ( ) {
355- const returnValue = 4 ;
356- const source = `class TestClass {
357- public dotMethod: () => number = () => ${ returnValue } ;
358- }
359-
360- const classInstance = new TestClass();
361- return classInstance.dotMethod();` ;
362-
363- // Transpile
364- const lua = util . transpileString ( source ) ;
365-
366- // Execute
367- const result = util . executeLua ( lua ) ;
368-
369- // Assert
370- Expect ( result ) . toBe ( returnValue ) ;
371- }
372-
373- @Test ( "Class dot method call with parameter" )
374- public classDotMethod2 ( ) {
375- const returnValue = 4 ;
376- const source = `class TestClass {
377- public dotMethod: (x: number) => number = x => 3 * x;
378- }
379-
380- const classInstance = new TestClass();
381- return classInstance.dotMethod(${ returnValue } );` ;
382-
383- // Transpile
384- const lua = util . transpileString ( source ) ;
385-
386- // Execute
387- const result = util . executeLua ( lua ) ;
388-
389- // Assert
390- Expect ( result ) . toBe ( 3 * returnValue ) ;
391- }
392-
393- @Test ( "Class static dot method" )
394- public classDotMethodStatic ( ) {
395- const returnValue = 4 ;
396- const source = `class TestClass {
397- public static dotMethod: () => number = () => ${ returnValue } ;
398- }
399-
400- return TestClass.dotMethod();` ;
401-
402- // Transpile
403- const lua = util . transpileString ( source ) ;
404-
405- // Execute
406- const result = util . executeLua ( lua ) ;
407-
408- // Assert
409- Expect ( result ) . toBe ( returnValue ) ;
410- }
411-
412- @Test ( "Class static dot method with parameter" )
413- public classDotMethodStaticWithParameter ( ) {
414- const returnValue = 4 ;
415- const source = `class TestClass {
416- public static dotMethod: (x: number) => number = x => 3 * x;
417- }
418-
419- return TestClass.dotMethod(${ returnValue } );` ;
420-
421- // Transpile
422- const lua = util . transpileString ( source ) ;
423-
424- // Execute
425- const result = util . executeLua ( lua ) ;
426-
427- // Assert
428- Expect ( result ) . toBe ( 3 * returnValue ) ;
429- }
430-
431263 // ====================================
432264 // Test expected errors
433265 // ====================================
@@ -534,16 +366,4 @@ export class ExpressionTests {
534366 Expect ( ( ) => transpiler . transpileObjectLiteral ( mockObject as ts . ObjectLiteralExpression ) )
535367 . toThrowError ( Error , "Encountered unsupported object literal element: FalseKeyword." ) ;
536368 }
537-
538- @Test ( "Invalid property access call transpilation" )
539- public invalidPropertyCall ( ) {
540- const transpiler = util . makeTestTranspiler ( ) ;
541-
542- const mockObject : any = {
543- expression : ts . createLiteral ( "abc" ) ,
544- } ;
545-
546- Expect ( ( ) => transpiler . transpilePropertyCall ( mockObject as ts . CallExpression ) )
547- . toThrowError ( Error , "Tried to transpile a non-property call as property call." ) ;
548- }
549369}
0 commit comments