@@ -12,13 +12,13 @@ export class LuaLibArrayTests {
1212 @Test ( "array.map" )
1313 public map < T > ( inp : T [ ] , func : string ) {
1414 // Transpile
15- let lua = util . transpileString ( `return ArrayToString ([${ inp . toString ( ) } ].map(${ func } ))` , util . dummyTypes . Array ) ;
15+ let lua = util . transpileString ( `return JSONStringify ([${ inp . toString ( ) } ].map(${ func } ))` , util . dummyTypes . Array ) ;
1616
1717 // Execute
1818 let result = util . executeLua ( lua ) ;
1919
2020 // Assert
21- Expect ( result ) . toBe ( inp . map ( eval ( func ) ) . toString ( ) ) ;
21+ Expect ( result ) . toBe ( JSON . stringify ( inp . map ( eval ( func ) ) ) ) ;
2222 }
2323
2424 @TestCase ( [ ] , "x => x > 1" )
@@ -31,13 +31,13 @@ export class LuaLibArrayTests {
3131 @Test ( "array.filter" )
3232 public filter < T > ( inp : T [ ] , func : string ) {
3333 // Transpile
34- let lua = util . transpileString ( `return ArrayToString ([${ inp . toString ( ) } ].filter(${ func } ))` , util . dummyTypes . Array ) ;
34+ let lua = util . transpileString ( `return JSONStringify ([${ inp . toString ( ) } ].filter(${ func } ))` , util . dummyTypes . Array ) ;
3535
3636 // Execute
3737 let result = util . executeLua ( lua ) ;
3838
3939 // Assert
40- Expect ( result ) . toBe ( inp . filter ( eval ( func ) ) . toString ( ) ) ;
40+ Expect ( result ) . toBe ( JSON . stringify ( inp . filter ( eval ( func ) ) ) ) ;
4141 }
4242
4343 @TestCase ( [ ] , "x => x > 1" )
@@ -53,7 +53,7 @@ export class LuaLibArrayTests {
5353 let result = util . executeLua ( lua ) ;
5454
5555 // Assert
56- Expect ( result . toString ( ) ) . toBe ( inp . every ( eval ( func ) ) . toString ( ) ) ;
56+ Expect ( JSON . stringify ( result ) ) . toBe ( JSON . stringify ( inp . every ( eval ( func ) ) ) ) ;
5757 }
5858
5959 @TestCase ( [ ] , "x => x > 1" )
@@ -69,7 +69,7 @@ export class LuaLibArrayTests {
6969 let result = util . executeLua ( lua ) ;
7070
7171 // Assert
72- Expect ( result . toString ( ) ) . toBe ( inp . some ( eval ( func ) ) . toString ( ) ) ;
72+ Expect ( JSON . stringify ( result ) ) . toBe ( JSON . stringify ( inp . some ( eval ( func ) ) ) ) ;
7373 }
7474
7575 @TestCase ( [ ] , 1 , 2 )
@@ -82,13 +82,13 @@ export class LuaLibArrayTests {
8282 @Test ( "array.slice" )
8383 public slice < T > ( inp : T [ ] , start : number , end ?: number ) {
8484 // Transpile
85- let lua = util . transpileString ( `return ArrayToString ([${ inp . toString ( ) } ].slice(${ start } , ${ end } ))` , util . dummyTypes . Array ) ;
85+ let lua = util . transpileString ( `return JSONStringify ([${ inp . toString ( ) } ].slice(${ start } , ${ end } ))` , util . dummyTypes . Array ) ;
8686
8787 // Execute
8888 let result = util . executeLua ( lua ) ;
8989
9090 // Assert
91- Expect ( result ) . toBe ( inp . slice ( start , end ) . toString ( ) ) ;
91+ Expect ( result ) . toBe ( JSON . stringify ( inp . slice ( start , end ) ) ) ;
9292 }
9393
9494 @TestCase ( [ ] , 0 , 0 , 9 , 10 , 11 )
@@ -104,7 +104,7 @@ export class LuaLibArrayTests {
104104 let lua = util . transpileString (
105105 `let spliceTestTable = [${ inp . toString ( ) } ];
106106 spliceTestTable.splice(${ start } , ${ deleteCount } , ${ newElements } );
107- return ArrayToString (spliceTestTable);` ,
107+ return JSONStringify (spliceTestTable);` ,
108108 util . dummyTypes . Array
109109 ) ;
110110
@@ -113,7 +113,7 @@ export class LuaLibArrayTests {
113113
114114 // Assert
115115 inp . splice ( start , deleteCount , ...newElements )
116- Expect ( result ) . toBe ( inp . toString ( ) ) ;
116+ Expect ( result ) . toBe ( JSON . stringify ( inp ) ) ;
117117 }
118118
119119 @TestCase ( [ ] , 1 , 1 )
@@ -126,16 +126,16 @@ export class LuaLibArrayTests {
126126 @Test ( "array.splice[Remove]" )
127127 public spliceRemove < T > ( inp : T [ ] , start : number , deleteCount ?: number , ...newElements : any [ ] ) {
128128 // Transpile
129- let lua = util . transpileString ( `return ArrayToString ([${ inp . toString ( ) } ].splice(${ start } , ${ deleteCount } , ${ newElements } ))` , util . dummyTypes . Array ) ;
129+ let lua = util . transpileString ( `return JSONStringify ([${ inp . toString ( ) } ].splice(${ start } , ${ deleteCount } , ${ newElements } ))` , util . dummyTypes . Array ) ;
130130
131131 // Execute
132132 let result = util . executeLua ( lua ) ;
133133
134134 // Assert
135135 if ( deleteCount ) {
136- Expect ( result ) . toBe ( inp . splice ( start , deleteCount , ...newElements ) . toString ( ) ) ;
136+ Expect ( result ) . toBe ( JSON . stringify ( inp . splice ( start , deleteCount , ...newElements ) ) ) ;
137137 } else {
138- Expect ( result ) . toBe ( inp . splice ( start ) . toString ( ) ) ;
138+ Expect ( result ) . toBe ( JSON . stringify ( inp . splice ( start ) ) ) ;
139139 }
140140 }
141141}
0 commit comments