@@ -5,6 +5,47 @@ var Buffer = require('../../').Buffer;
5
5
var assert = require ( 'assert' ) ;
6
6
var Buffer = require ( '../../' ) . Buffer ;
7
7
8
+ /**
9
+ * TEMPORARY HACK UNTIL THIS ASSERT BUG IS FIXED IN NODE CORE
10
+ * https://github.com/nodejs/node/issues/8001
11
+ */
12
+ var pToString = function ( obj ) { return Object . prototype . toString . call ( obj ) }
13
+ var _deepStrictEqual = assert . deepStrictEqual
14
+ assert . deepStrictEqual = function ( actual , expected , msg ) {
15
+ if ( typeof ArrayBuffer !== 'undefined' && ArrayBuffer . isView ( actual ) &&
16
+ ArrayBuffer . isView ( expected ) && ! require ( 'buffer' ) . Buffer . isBuffer ( actual ) &&
17
+ ! require ( 'buffer' ) . Buffer . isBuffer ( expected ) && pToString ( actual ) === pToString ( expected ) &&
18
+ ! ( actual instanceof Float32Array || actual instanceof Float64Array ) ) {
19
+ assert . equal ( Buffer . compare ( Buffer . from ( actual . buffer ,
20
+ actual . byteOffset ,
21
+ actual . byteLength ) ,
22
+ Buffer . from ( expected . buffer ,
23
+ expected . byteOffset ,
24
+ expected . byteLength ) ) , 0 ) ;
25
+ } else {
26
+ _deepStrictEqual . call ( assert , actual , expected , msg )
27
+ }
28
+ }
29
+ var _deepEqual = assert . deepEqual
30
+ assert . deepEqual = function ( actual , expected , msg ) {
31
+ if ( typeof ArrayBuffer !== 'undefined' && ArrayBuffer . isView ( actual ) &&
32
+ ArrayBuffer . isView ( expected ) && ! require ( 'buffer' ) . Buffer . isBuffer ( actual ) &&
33
+ ! require ( 'buffer' ) . Buffer . isBuffer ( expected ) && pToString ( actual ) === pToString ( expected ) &&
34
+ ! ( actual instanceof Float32Array || actual instanceof Float64Array ) ) {
35
+ assert . ok ( Buffer . compare ( Buffer . from ( actual . buffer ,
36
+ actual . byteOffset ,
37
+ actual . byteLength ) ,
38
+ Buffer . from ( expected . buffer ,
39
+ expected . byteOffset ,
40
+ expected . byteLength ) ) === 0 ) ;
41
+ } else {
42
+ _deepEqual . call ( assert , actual , expected , msg )
43
+ }
44
+ }
45
+ /**
46
+ * END HACK
47
+ */
48
+
8
49
// Test hex strings and bad hex strings
9
50
{
10
51
var buf1 = Buffer . alloc ( 4 ) ;
0 commit comments