@@ -12,11 +12,22 @@ import { a as rea, b as reb, c as rec, o as reo, two as retwo } from "reexport";
1212
1313import threeIsOdd , { even } from "circularEven" ;
1414
15+ import Thing , { Other } from "commonjs" ;
16+ import Thing2 , { Other as Other2 } from "commonjs-trans" ;
17+
1518it ( "should import an identifier from a module" , function ( ) {
1619 a . should . be . eql ( "a" ) ;
1720 B . should . be . eql ( "b" ) ;
1821} ) ;
1922
23+ it ( "should import a whole module" , function ( ) {
24+ abc . a . should . be . eql ( "a" ) ;
25+ abc . b . should . be . eql ( "b" ) ;
26+ var copy = ( function ( a ) { return a ; } ( abc ) ) ;
27+ copy . a . should . be . eql ( "a" ) ;
28+ copy . b . should . be . eql ( "b" ) ;
29+ } ) ;
30+
2031it ( "should export functions" , function ( ) {
2132 fn . should . have . type ( "function" ) ;
2233 fn ( ) . should . be . eql ( "fn" ) ;
@@ -43,4 +54,17 @@ it("should reexport a module", function() {
4354it ( "should support circular dependencies" , function ( ) {
4455 threeIsOdd . should . be . eql ( true ) ;
4556 even ( 4 ) . should . be . eql ( true ) ;
46- } )
57+ } ) ;
58+
59+ it ( "should be able to import commonjs" , function ( ) {
60+ function x ( ) { throw new Error ( "should not be executed" ) ; }
61+ // next line doesn't end with semicolon
62+ x
63+ Thing . should . have . type ( "function" ) ;
64+ Thing ( ) . should . be . eql ( "thing" ) ;
65+ Other . should . be . eql ( "other" ) ;
66+
67+ Thing2 . should . have . type ( "function" ) ;
68+ new Thing2 ( ) . value . should . be . eql ( "thing" ) ;
69+ Other2 . should . be . eql ( "other" ) ;
70+ } ) ;
0 commit comments