forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
111 lines (96 loc) · 3.19 KB
/
main.js
File metadata and controls
111 lines (96 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Chunked File library
var should = require("should");
var library2commonValue = library2common;
describe("library2", function() {
var tickExtra, tickEmpty, tickMerged;
var extraValue, testValue;
before(function(done) {
var asnycOk = false, asnycOk2 = false;
var sameTick1 = true;
require.ensure(["./extra"], function(require) {
asnycOk = true;
tickExtra = sameTick1;
var sameTick2 = true;
require.ensure([], function(require) {
asnycOk2 = true;
extraValue = require("./extra");
tickEmpty = sameTick2;
require.ensure(["./test.js"], function(require) {
tickMerged = sameTick2;
testValue = require("./test.js");
done();
});
});
Promise.resolve().then(function() {}).then(function() {}).then(function() {
sameTick2 = false;
});
});
Promise.resolve().then(function() {}).then(function() {}).then(function() {
sameTick1 = false;
});
});
it("should run after common", function() {
library2commonValue.should.be.eql({ok2: true});
});
it("should load stuff with require.ensure asynchron", function() {
should.strictEqual(tickExtra, false);
});
it("should load not include stuff from parent, remove empty chunks and apply a post loader", function() {
should.strictEqual(tickEmpty, true);
extraValue.should.be.eql("Lib2 extra2 with post loader");
});
it("should merge chunks if maxChunks specified", function() {
should.strictEqual(tickEmpty, true);
testValue.should.be.eql("test module");
});
it("should load require.amd from options", function() {
require.amd.should.have.property("fromOptions").be.eql(true);
});
it("should run empty AMD require", function(done) {
var emptyRequire = false;
require([], function() {
emptyRequire = true;
});
Promise.resolve().then(function() {}).then(function() {}).then(function() {
emptyRequire.should.be.eql(true);
done();
});
});
it("should provide free variables", function() {
s3().should.be.eql("submodule3");
});
it("should define values", function() {
(CONST_UNDEFINED === undefined).should.be.eql(true);
(CONST_NULL === null).should.be.eql(true);
CONST_TRUE.should.be.eql(true);
CONST_FALSE.should.be.eql(false);
(CONST_FUNCTION()).should.be.eql("ok");
(CONST_NUMBER).should.be.eql(123);
CONST_NUMBER_EXPR.should.be.eql(123);
(typeof CONST_TYPEOF).should.be.eql("typeof");
var o = CONST_OBJECT;
(CONST_OBJECT.A).should.be.eql(1);
CONST_OBJECT.B.should.be.eql("B");
CONST_OBJECT.C().should.be.eql("C");
o.A.should.be.eql(1);
o.B.should.be.eql("B");
o.C().should.be.eql("C");
(function(o) {
o.A.should.be.eql(1);
o.B.should.be.eql("B");
o.C().should.be.eql("C");
}(CONST_OBJECT));
if(CONST_FALSE) require("fail");
if(!CONST_TRUE) require("fail");
if(!CONST_NUMBER) require("fail");
if(!CONST_NUMBER_EXPR) require("fail");
if(typeof CONST_TYPEOF !== "typeof") require("fail");
if(typeof CONST_FALSE !== "boolean") require("fail");
if(typeof CONST_FUNCTION !== "function") require("fail");
if(typeof CONST_OBJECT !== "object") require("fail");
if(!CONST_OBJECT.A) require("fail");
if(typeof CONST_OBJECT.A !== "number") require("fail");
});
});
exports.library2 = {ok: true};
// it should not fail if comment in last line