@@ -509,7 +509,7 @@ test.each(["pairs", "ipairs"])("can spread %s (#1244)", func => {
509509} ) ;
510510
511511// https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1244
512- test . each ( [ "LuaTable" , "LuaMap" ] ) ( "can spread %s (#1244)" , type => {
512+ test . each ( [ "LuaTable" , "LuaMap" ] ) ( "can spread %s with pairs (#1244)" , type => {
513513 const result : Array < [ string , string ] > = util . testFunction `
514514 const tbl = new ${ type } ();
515515 tbl.set("foo", "bar");
@@ -524,6 +524,40 @@ test.each(["LuaTable", "LuaMap"])("can spread %s (#1244)", type => {
524524
525525 // We don't know the order so match like this
526526 expect ( result ) . toHaveLength ( 2 ) ;
527- expect ( result . some ( ( [ k , v ] ) => k === "foo" && v === "bar" ) ) . toBe ( true ) ;
528- expect ( result . some ( ( [ k , v ] ) => k === "fizz" && v === "buzz" ) ) . toBe ( true ) ;
527+ expect ( result ) . toContainEqual ( [ "foo" , "bar" ] ) ;
528+ expect ( result ) . toContainEqual ( [ "fizz" , "buzz" ] ) ;
529+ } ) ;
530+
531+ // https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1384
532+ test . each ( [ "LuaTable" , "LuaMap" ] ) ( "can spread %s (#1384)" , type => {
533+ const result : Array < [ string , string ] > = util . testFunction `
534+ const tbl = new ${ type } ();
535+ tbl.set("foo", "bar");
536+ tbl.set("fizz", "buzz");
537+ return [...tbl];
538+ `
539+ . withLanguageExtensions ( )
540+ . getLuaExecutionResult ( ) ;
541+
542+ // We don't know the order so match like this
543+ expect ( result ) . toHaveLength ( 2 ) ;
544+ expect ( result ) . toContainEqual ( [ "foo" , "bar" ] ) ;
545+ expect ( result ) . toContainEqual ( [ "fizz" , "buzz" ] ) ;
546+ } ) ;
547+
548+ // https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1384
549+ test ( "can spread LuaSet (#1384)" , ( ) => {
550+ const result : Array < [ string , string ] > = util . testFunction `
551+ const tbl = new LuaSet();
552+ tbl.add("foo");
553+ tbl.add("bar");
554+ return [...tbl];
555+ `
556+ . withLanguageExtensions ( )
557+ . getLuaExecutionResult ( ) ;
558+
559+ // We don't know the order so match like this
560+ expect ( result ) . toHaveLength ( 2 ) ;
561+ expect ( result ) . toContain ( "foo" ) ;
562+ expect ( result ) . toContain ( "bar" ) ;
529563} ) ;
0 commit comments