@@ -4,33 +4,27 @@ const assert = require('assert');
4
4
5
5
module . exports = require ( '../common' ) . runTest ( test ) ;
6
6
7
- function test ( binding ) {
7
+ function test ( binding ) {
8
8
const externalValue = binding . basic_types_value . createExternal ( ) ;
9
9
10
- function isObject ( value ) {
10
+ function isObject ( value ) {
11
11
return ( typeof value === 'object' && value !== externalValue ) ||
12
12
( typeof value === 'function' ) ;
13
13
}
14
14
15
- function detailedTypeOf ( value ) {
15
+ function detailedTypeOf ( value ) {
16
16
const type = typeof value ;
17
- if ( type !== 'object' )
18
- return type ;
17
+ if ( type !== 'object' ) { return type ; }
19
18
20
- if ( value === null )
21
- return 'null' ;
19
+ if ( value === null ) { return 'null' ; }
22
20
23
- if ( Array . isArray ( value ) )
24
- return 'array' ;
21
+ if ( Array . isArray ( value ) ) { return 'array' ; }
25
22
26
- if ( value === externalValue )
27
- return 'external' ;
23
+ if ( value === externalValue ) { return 'external' ; }
28
24
29
- if ( ! value . constructor )
30
- return type ;
25
+ if ( ! value . constructor ) { return type ; }
31
26
32
- if ( value instanceof ArrayBuffer )
33
- return 'arraybuffer' ;
27
+ if ( value instanceof ArrayBuffer ) { return 'arraybuffer' ; }
34
28
35
29
if ( ArrayBuffer . isView ( value ) ) {
36
30
if ( value instanceof DataView ) {
@@ -40,13 +34,12 @@ function test(binding) {
40
34
}
41
35
}
42
36
43
- if ( value instanceof Promise )
44
- return 'promise' ;
37
+ if ( value instanceof Promise ) { return 'promise' ; }
45
38
46
39
return 'object' ;
47
40
}
48
41
49
- function typeCheckerTest ( typeChecker , expectedType ) {
42
+ function typeCheckerTest ( typeChecker , expectedType ) {
50
43
const testValueList = [
51
44
undefined ,
52
45
null ,
@@ -58,7 +51,7 @@ function test(binding) {
58
51
new ArrayBuffer ( 10 ) ,
59
52
new Int32Array ( new ArrayBuffer ( 12 ) ) ,
60
53
{ } ,
61
- function ( ) { } ,
54
+ function ( ) { } ,
62
55
new Promise ( ( resolve , reject ) => { } ) ,
63
56
new DataView ( new ArrayBuffer ( 12 ) ) ,
64
57
externalValue
@@ -73,7 +66,7 @@ function test(binding) {
73
66
} ) ;
74
67
}
75
68
76
- function typeConverterTest ( typeConverter , expectedType ) {
69
+ function typeConverterTest ( typeConverter , expectedType ) {
77
70
const testValueList = [
78
71
true ,
79
72
false ,
@@ -84,7 +77,7 @@ function test(binding) {
84
77
new ArrayBuffer ( 10 ) ,
85
78
new Int32Array ( new ArrayBuffer ( 12 ) ) ,
86
79
{ } ,
87
- function ( ) { } ,
80
+ function ( ) { } ,
88
81
new Promise ( ( resolve , reject ) => { } )
89
82
] ;
90
83
@@ -100,8 +93,38 @@ function test(binding) {
100
93
} ) ;
101
94
}
102
95
96
+ function assertValueStrictlyEqual ( value ) {
97
+ const newValue = value . createNonEmptyValue ( ) ;
98
+ assert ( value . strictlyEquals ( newValue , newValue ) ) ;
99
+ assert ( value . strictlyEqualsOverload ( newValue , newValue ) ) ;
100
+ }
101
+
102
+ function assertValueStrictlyNonEqual ( value ) {
103
+ const valueA = value . createNonEmptyValue ( ) ;
104
+ const valueB = value . createExternal ( ) ;
105
+ assert ( value . strictlyNotEqualsOverload ( valueA , valueB ) ) ;
106
+ }
107
+
108
+ function assertValueReturnsCorrectEnv ( value ) {
109
+ assert ( value . assertValueReturnsCorrectEnv ( ) ) ;
110
+ }
111
+
112
+ function assertEmptyValueNullPtrOnCast ( value ) {
113
+ assert ( value . assertEmptyValReturnNullPtrOnCast ( ) ) ;
114
+ }
115
+
116
+ function assertNonEmptyReturnValOnCast ( value ) {
117
+ assert ( value . assertNonEmptyReturnValOnCast ( ) ) ;
118
+ }
119
+
103
120
const value = binding . basic_types_value ;
104
121
122
+ assertValueStrictlyEqual ( value ) ;
123
+ assertValueStrictlyNonEqual ( value ) ;
124
+ assertValueReturnsCorrectEnv ( value ) ;
125
+ assertEmptyValueNullPtrOnCast ( value ) ;
126
+ assertNonEmptyReturnValOnCast ( value ) ;
127
+
105
128
typeCheckerTest ( value . isUndefined , 'undefined' ) ;
106
129
typeCheckerTest ( value . isNull , 'null' ) ;
107
130
typeCheckerTest ( value . isBoolean , 'boolean' ) ;
0 commit comments