@@ -8,113 +8,125 @@ module.exports = require('./common').runTest(binding => {
8
8
testLambda ( binding . function . lambda ) ;
9
9
} ) ;
10
10
11
- function test ( binding ) {
11
+ function test ( binding ) {
12
12
assert . strictEqual ( binding . emptyConstructor ( true ) , true ) ;
13
13
assert . strictEqual ( binding . emptyConstructor ( false ) , false ) ;
14
14
15
15
let obj = { } ;
16
16
assert . deepStrictEqual ( binding . voidCallback ( obj ) , undefined ) ;
17
- assert . deepStrictEqual ( obj , { " foo" : " bar" } ) ;
17
+ assert . deepStrictEqual ( obj , { foo : ' bar' } ) ;
18
18
19
- assert . deepStrictEqual ( binding . valueCallback ( ) , { " foo" : " bar" } ) ;
19
+ assert . deepStrictEqual ( binding . valueCallback ( ) , { foo : ' bar' } ) ;
20
20
21
21
let args = null ;
22
22
let ret = null ;
23
23
let receiver = null ;
24
- function testFunction ( ) {
24
+ function testFunction ( ) {
25
25
receiver = this ;
26
26
args = [ ] . slice . call ( arguments ) ;
27
27
return ret ;
28
28
}
29
- function testConstructor ( ) {
29
+ function testConstructor ( ) {
30
30
args = [ ] . slice . call ( arguments ) ;
31
31
}
32
32
33
- function makeCallbackTestFunction ( receiver , expectedOne , expectedTwo , expectedThree ) {
34
- return function callback ( one , two , three ) {
33
+ function makeCallbackTestFunction ( receiver , expectedOne , expectedTwo , expectedThree ) {
34
+ return function callback ( one , two , three ) {
35
35
assert . strictEqual ( this , receiver ) ;
36
36
assert . strictEqual ( one , expectedOne ) ;
37
37
assert . strictEqual ( two , expectedTwo ) ;
38
38
assert . strictEqual ( three , expectedThree ) ;
39
- }
39
+ } ;
40
40
}
41
41
42
42
ret = 4 ;
43
43
assert . strictEqual ( binding . callWithArgs ( testFunction , 1 , 2 , 3 ) , 4 ) ;
44
44
assert . strictEqual ( receiver , undefined ) ;
45
- assert . deepStrictEqual ( args , [ 1 , 2 , 3 ] ) ;
45
+ assert . deepStrictEqual ( args , [ 1 , 2 , 3 ] ) ;
46
46
47
47
ret = 5 ;
48
48
assert . strictEqual ( binding . callWithVector ( testFunction , 2 , 3 , 4 ) , 5 ) ;
49
49
assert . strictEqual ( receiver , undefined ) ;
50
- assert . deepStrictEqual ( args , [ 2 , 3 , 4 ] ) ;
50
+ assert . deepStrictEqual ( args , [ 2 , 3 , 4 ] ) ;
51
+
52
+ ret = 5 ;
53
+ assert . strictEqual ( binding . callWithVectorUsingCppWrapper ( testFunction , 2 , 3 , 4 ) , 5 ) ;
54
+ assert . strictEqual ( receiver , undefined ) ;
55
+ assert . deepStrictEqual ( args , [ 2 , 3 , 4 ] ) ;
51
56
52
57
ret = 6 ;
53
58
assert . strictEqual ( binding . callWithReceiverAndArgs ( testFunction , obj , 3 , 4 , 5 ) , 6 ) ;
54
59
assert . deepStrictEqual ( receiver , obj ) ;
55
- assert . deepStrictEqual ( args , [ 3 , 4 , 5 ] ) ;
60
+ assert . deepStrictEqual ( args , [ 3 , 4 , 5 ] ) ;
56
61
57
62
ret = 7 ;
58
63
assert . strictEqual ( binding . callWithReceiverAndVector ( testFunction , obj , 4 , 5 , 6 ) , 7 ) ;
59
64
assert . deepStrictEqual ( receiver , obj ) ;
60
- assert . deepStrictEqual ( args , [ 4 , 5 , 6 ] ) ;
65
+ assert . deepStrictEqual ( args , [ 4 , 5 , 6 ] ) ;
66
+
67
+ ret = 7 ;
68
+ assert . strictEqual ( binding . callWithReceiverAndVectorUsingCppWrapper ( testFunction , obj , 4 , 5 , 6 ) , 7 ) ;
69
+ assert . deepStrictEqual ( receiver , obj ) ;
70
+ assert . deepStrictEqual ( args , [ 4 , 5 , 6 ] ) ;
61
71
62
72
ret = 8 ;
63
73
assert . strictEqual ( binding . callWithCStyleArray ( testFunction , 5 , 6 , 7 ) , ret ) ;
64
74
assert . deepStrictEqual ( receiver , undefined ) ;
65
- assert . deepStrictEqual ( args , [ 5 , 6 , 7 ] ) ;
75
+ assert . deepStrictEqual ( args , [ 5 , 6 , 7 ] ) ;
66
76
67
77
ret = 9 ;
68
78
assert . strictEqual ( binding . callWithReceiverAndCStyleArray ( testFunction , obj , 6 , 7 , 8 ) , ret ) ;
69
79
assert . deepStrictEqual ( receiver , obj ) ;
70
- assert . deepStrictEqual ( args , [ 6 , 7 , 8 ] ) ;
80
+ assert . deepStrictEqual ( args , [ 6 , 7 , 8 ] ) ;
71
81
72
82
ret = 10 ;
73
83
assert . strictEqual ( binding . callWithFunctionOperator ( testFunction , 7 , 8 , 9 ) , ret ) ;
74
84
assert . strictEqual ( receiver , undefined ) ;
75
- assert . deepStrictEqual ( args , [ 7 , 8 , 9 ] ) ;
85
+ assert . deepStrictEqual ( args , [ 7 , 8 , 9 ] ) ;
76
86
77
87
assert . throws ( ( ) => {
78
88
binding . callWithInvalidReceiver ( ) ;
79
89
} , / I n v a l i d ( p o i n t e r p a s s e d a s ) ? a r g u m e n t / ) ;
80
90
81
91
obj = binding . callConstructorWithArgs ( testConstructor , 5 , 6 , 7 ) ;
82
92
assert ( obj instanceof testConstructor ) ;
83
- assert . deepStrictEqual ( args , [ 5 , 6 , 7 ] ) ;
93
+ assert . deepStrictEqual ( args , [ 5 , 6 , 7 ] ) ;
84
94
85
95
obj = binding . callConstructorWithVector ( testConstructor , 6 , 7 , 8 ) ;
86
96
assert ( obj instanceof testConstructor ) ;
87
- assert . deepStrictEqual ( args , [ 6 , 7 , 8 ] ) ;
97
+ assert . deepStrictEqual ( args , [ 6 , 7 , 8 ] ) ;
88
98
89
99
obj = binding . callConstructorWithCStyleArray ( testConstructor , 7 , 8 , 9 ) ;
90
100
assert ( obj instanceof testConstructor ) ;
91
- assert . deepStrictEqual ( args , [ 7 , 8 , 9 ] ) ;
101
+ assert . deepStrictEqual ( args , [ 7 , 8 , 9 ] ) ;
92
102
93
103
obj = { } ;
94
104
assert . deepStrictEqual ( binding . voidCallbackWithData ( obj ) , undefined ) ;
95
- assert . deepStrictEqual ( obj , { " foo" : " bar" , " data" : 1 } ) ;
105
+ assert . deepStrictEqual ( obj , { foo : ' bar' , data : 1 } ) ;
96
106
97
- assert . deepStrictEqual ( binding . valueCallbackWithData ( ) , { " foo" : " bar" , " data" : 1 } ) ;
107
+ assert . deepStrictEqual ( binding . valueCallbackWithData ( ) , { foo : ' bar' , data : 1 } ) ;
98
108
99
109
assert . strictEqual ( binding . voidCallback . name , 'voidCallback' ) ;
100
110
assert . strictEqual ( binding . valueCallback . name , 'valueCallback' ) ;
101
111
102
- let testConstructCall = undefined ;
112
+ let testConstructCall ;
103
113
binding . isConstructCall ( ( result ) => { testConstructCall = result ; } ) ;
104
114
assert . ok ( ! testConstructCall ) ;
115
+ /* eslint-disable no-new, new-cap */
105
116
new binding . isConstructCall ( ( result ) => { testConstructCall = result ; } ) ;
117
+ /* eslint-enable no-new, new-cap */
106
118
assert . ok ( testConstructCall ) ;
107
119
108
120
obj = { } ;
109
- binding . makeCallbackWithArgs ( makeCallbackTestFunction ( obj , "1" , "2" , "3" ) , obj , "1" , "2" , "3" ) ;
121
+ binding . makeCallbackWithArgs ( makeCallbackTestFunction ( obj , '1' , '2' , '3' ) , obj , '1' , '2' , '3' ) ;
110
122
binding . makeCallbackWithVector ( makeCallbackTestFunction ( obj , 4 , 5 , 6 ) , obj , 4 , 5 , 6 ) ;
111
123
binding . makeCallbackWithCStyleArray ( makeCallbackTestFunction ( obj , 7 , 8 , 9 ) , obj , 7 , 8 , 9 ) ;
112
124
assert . throws ( ( ) => {
113
125
binding . makeCallbackWithInvalidReceiver ( ( ) => { } ) ;
114
126
} ) ;
115
127
}
116
128
117
- function testLambda ( binding ) {
129
+ function testLambda ( binding ) {
118
130
assert . ok ( binding . lambdaWithNoCapture ( ) ) ;
119
131
assert . ok ( binding . lambdaWithCapture ( ) ) ;
120
132
assert . ok ( binding . lambdaWithMoveOnlyCapture ( ) ) ;
0 commit comments