-
Notifications
You must be signed in to change notification settings - Fork 12
/
browserify.js
41 lines (37 loc) · 1.11 KB
/
browserify.js
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
"use strict"
var browserify = require("browserify")
var vm = require("vm")
var path = require("path")
var tape = require("tape")
var cases = [ "unary", "binary", "offset", "fill" ]
bundleCasesFrom(0)
function bundleCasesFrom(i) {
if (i>=cases.length) return
var b = browserify()
b.ignore("tape")
b.add(__dirname + "/" + cases[i] + ".js")
b.transform(path.normalize(__dirname + "/../cwise.js"))
tape(cases[i], function(t) { // Without nested tests, the asynchronous nature of bundle causes issues with tape...
b.bundle(function(err, src) {
if(err) {
throw new Error("failed to bundle!")
}
vm.runInNewContext(src, {
test: t.test.bind(t),
Buffer: Buffer,
Int8Array: Int8Array,
Int16Array: Int16Array,
Int32Array: Int32Array,
Float32Array: Float32Array,
Float64Array: Float64Array,
Uint8Array: Uint8Array,
Uint16Array: Uint16Array,
Uint32Array: Uint32Array,
Uint8ClampedArray: Uint8ClampedArray,
console: { log: console.log.bind(console) }
})
t.end()
})
})
bundleCasesFrom(i+1)
}