@@ -100,3 +100,26 @@ writePartial('writeFloatBE', [1, 6], 10,
100
100
Buffer . from ( [ 0 , 0 , 0 , 0 , 0 , 0 , 63 , 128 , 0 ] ) ) ;
101
101
writePartial ( 'writeFloatLE' , [ 1 , 6 ] , 10 ,
102
102
Buffer . from ( [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 128 ] ) ) ;
103
+
104
+ // https://github.com/nodejs/node/issues/8724 - specific to methods dealing
105
+ // with floating point types because they call out to C++ code.
106
+ for ( const noAssert of [ true , false ] ) {
107
+ const re = / ^ T y p e E r r o r : a r g u m e n t s h o u l d b e a B u f f e r $ / ;
108
+ const proto = Buffer . prototype ;
109
+ const { writeFloatBE, writeFloatLE, writeDoubleBE, writeDoubleLE } = proto ;
110
+ // Non-method call.
111
+ assert . throws ( ( ) => writeFloatBE ( 0 , 0 , noAssert ) , re ) ;
112
+ assert . throws ( ( ) => writeFloatLE ( 0 , 0 , noAssert ) , re ) ;
113
+ assert . throws ( ( ) => writeDoubleBE ( 0 , 0 , noAssert ) , re ) ;
114
+ assert . throws ( ( ) => writeDoubleLE ( 0 , 0 , noAssert ) , re ) ;
115
+ // Wrong receiver.
116
+ assert . throws ( ( ) => proto . writeFloatBE ( 0 , 0 , noAssert ) , re ) ;
117
+ assert . throws ( ( ) => proto . writeFloatLE ( 0 , 0 , noAssert ) , re ) ;
118
+ assert . throws ( ( ) => proto . writeDoubleBE ( 0 , 0 , noAssert ) , re ) ;
119
+ assert . throws ( ( ) => proto . writeDoubleLE ( 0 , 0 , noAssert ) , re ) ;
120
+ // Wrong receiver.
121
+ assert . throws ( ( ) => proto . writeFloatBE . call ( { } , 0 , 0 , noAssert ) , re ) ;
122
+ assert . throws ( ( ) => proto . writeFloatLE . call ( { } , 0 , 0 , noAssert ) , re ) ;
123
+ assert . throws ( ( ) => proto . writeDoubleBE . call ( { } , 0 , 0 , noAssert ) , re ) ;
124
+ assert . throws ( ( ) => proto . writeDoubleLE . call ( { } , 0 , 0 , noAssert ) , re ) ;
125
+ }
0 commit comments