forked from regl-project/regl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontext.js
62 lines (56 loc) · 1.35 KB
/
context.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var createContext = require('./util/create-context')
var createREGL = require('../regl')
var tape = require('tape')
tape('context', function (t) {
var gl = createContext(16, 16)
var regl = createREGL(gl)
var simpleScope = regl({
context: {
a: function (context, props) {
t.equals(context.a, undefined)
t.equals(context.b, undefined)
t.equals(context.c, undefined)
t.equals(context.d, undefined)
t.equals(context.e, undefined)
return 1
},
b: regl.this('bbb'),
c: regl.context('viewportWidth'),
d: regl.prop('ddd'),
e: 'eee'
}
})
simpleScope.call({
bbb: 3
}, {
ddd: 7
}, function (context, props) {
t.equals(context.a, 1)
t.equals(context.b, 3)
t.equals(context.c, 16)
t.equals(context.d, 7)
t.equals(context.e, 'eee')
regl({
context: {
b: 5,
c: 7,
d: regl.context('b')
}
}).call({}, {}, function () {
t.equals(context.a, 1)
t.equals(context.b, 5)
t.equals(context.c, 7)
t.equals(context.d, 3)
t.equals(context.e, 'eee')
})
t.equals(context.a, 1)
t.equals(context.b, 3)
t.equals(context.c, 16)
t.equals(context.d, 7)
t.equals(context.e, 'eee')
})
regl.destroy()
t.equals(gl.getError(), 0, 'error ok')
createContext.destroy(gl)
t.end()
})