@@ -22,7 +22,6 @@ export class ExpressionTests {
2222
2323 @TestCase ( "obj instanceof someClass" , "Unsupported binary operator kind: instanceof" )
2424 @TestCase ( "typeof obj" , "Unsupported expression kind: TypeOfExpression" )
25- @TestCase ( "2 in obj" , "Unsupported binary operator kind: in" )
2625 @Test ( "Prohibted Expressions" )
2726 public prohibtedExpressions ( input : string , expectedError : string ) {
2827 Expect ( ( ) => {
@@ -47,8 +46,32 @@ export class ExpressionTests {
4746 @TestCase ( "1&&1" , "1 and 1" )
4847 @TestCase ( "1||1" , "1 or 1" )
4948 @Test ( "Binary expressions basic" )
50- public binary ( input : string , lua : string ) {
51- Expect ( util . transpileString ( input ) ) . toBe ( lua ) ;
49+ public binary ( input : string , output : string ) {
50+ // Transpile
51+ const lua = util . transpileString ( input ) ;
52+
53+ // Execute
54+ const result = util . executeLua ( `return ${ lua } ` ) ;
55+
56+ // Assert
57+ Expect ( lua ) . toBe ( output ) ;
58+ Expect ( result ) . toBe ( eval ( input ) ) ;
59+ }
60+
61+ @TestCase ( "'key' in obj" )
62+ @TestCase ( "'existingKey' in obj" )
63+ @TestCase ( "0 in obj" )
64+ @TestCase ( "9 in obj" )
65+ @Test ( "Binary expression in" )
66+ public binaryIn ( input : string ) {
67+ // Transpile
68+ const lua = util . transpileString ( input ) ;
69+
70+ // Execute
71+ const result = util . executeLua ( `obj = { existingKey = 1 }\nreturn ${ lua } ` ) ;
72+
73+ // Assert
74+ Expect ( result ) . toBe ( eval ( `let obj = { existingKey: 1 }; ${ input } ` ) ) ;
5275 }
5376
5477 @TestCase ( "a+=b" , "a=a+b" )
0 commit comments