@@ -455,18 +455,13 @@ describe("lua keyword as identifier doesn't interfere with lua's value", () => {
455455 } ) ;
456456
457457 test ( "variable (require)" , ( ) => {
458- const code = `
459- const require = "foobar";
460- export { foo } from "someModule";
461- export const result = require;` ;
462-
463- const lua = `
464- package.loaded.someModule = {foo = "bar"}
465- return (function()
466- ${ util . transpileString ( code , undefined , true ) }
467- end)().result` ;
468-
469- expect ( util . executeLua ( lua ) ) . toBe ( "foobar" ) ;
458+ util . testBundle `
459+ const require = true;
460+ import "./module";
461+ export const result = require;
462+ `
463+ . addExtraFile ( "module.ts" , "" )
464+ . expectToEqual ( { result : true } ) ;
470465 } ) ;
471466
472467 test ( "variable (tostring)" , ( ) => {
@@ -575,19 +570,14 @@ describe("lua keyword as identifier doesn't interfere with lua's value", () => {
575570 expect ( util . transpileAndExecute ( code ) ) . toBe ( "foobar|string" ) ;
576571 } ) ;
577572
578- test . each ( [ "type" , "type as type" ] ) ( "imported variable (%p)" , importName => {
579- const luaHeader = `
580- package.loaded.someModule = {type = "foobar"}` ;
581-
582- const code = `
583- import {${ importName } } from "someModule";
584- export const result = typeof 7 + "|" + type;
585- ` ;
586-
587- const lua = util . transpileString ( code ) ;
588- const result = util . executeLua ( `${ luaHeader } return (function() ${ lua } end)().result` ) ;
589-
590- expect ( result ) . toBe ( "number|foobar" ) ;
573+ test . each ( [ "type" , "type as type" ] ) ( "imported variable (%p)" , importSpecifier => {
574+ util . testBundle `
575+ import { ${ importSpecifier } } from "./module";
576+ typeof 0;
577+ export const result = type;
578+ `
579+ . addExtraFile ( "module.ts" , "export const type = true;" )
580+ . expectToEqual ( { result : true } ) ;
591581 } ) ;
592582
593583 test . each ( [
@@ -605,16 +595,12 @@ describe("lua keyword as identifier doesn't interfere with lua's value", () => {
605595 } ) ;
606596
607597 test . each ( [ "type" , "type as type" ] ) ( "re-exported variable with lua keyword as name (%p)" , importName => {
608- const code = `
609- export { ${ importName } } from "someModule"` ;
610-
611- const lua = `
612- package.loaded.someModule = {type = "foobar"}
613- return (function()
614- ${ util . transpileString ( code ) }
615- end)().type` ;
616-
617- expect ( util . executeLua ( lua ) ) . toBe ( "foobar" ) ;
598+ util . testBundle `
599+ export { ${ importName } } from "./module";
600+ typeof 0;
601+ `
602+ . addExtraFile ( "module.ts" , "export const type = true" )
603+ . expectToEqual ( { type : true } ) ;
618604 } ) ;
619605
620606 test ( "class" , ( ) => {
0 commit comments