@@ -60,4 +60,34 @@ describe("MurmurHash3_64", function () {
60
60
const hexdigest2 = hash . hexdigest ( ) ;
61
61
expect ( hexdigest1 ) . not . toEqual ( hexdigest2 ) ;
62
62
} ) ;
63
+
64
+ it (
65
+ "generates correct hashes for TypedArrays which share the same " +
66
+ "underlying ArrayBuffer (issue 12533)" ,
67
+ function ( ) {
68
+ // prettier-ignore
69
+ const typedArray = new Uint8Array ( [
70
+ 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 ,
71
+ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1
72
+ ] ) ;
73
+ const startArray = new Uint8Array ( typedArray . buffer , 0 , 10 ) ;
74
+ const endArray = new Uint8Array ( typedArray . buffer , 10 , 10 ) ;
75
+
76
+ expect ( startArray ) . not . toEqual ( endArray ) ;
77
+
78
+ const startHash = new MurmurHash3_64 ( ) ;
79
+ startHash . update ( startArray ) ;
80
+ const startHexdigest = startHash . hexdigest ( ) ;
81
+
82
+ const endHash = new MurmurHash3_64 ( ) ;
83
+ endHash . update ( endArray ) ;
84
+ const endHexdigest = endHash . hexdigest ( ) ;
85
+
86
+ // The two hashes *must* be different.
87
+ expect ( startHexdigest ) . not . toEqual ( endHexdigest ) ;
88
+
89
+ expect ( startHexdigest ) . toEqual ( "a49de339cc5b0819" ) ;
90
+ expect ( endHexdigest ) . toEqual ( "f81a92d9e214ab35" ) ;
91
+ }
92
+ ) ;
63
93
} ) ;
0 commit comments