@@ -7,15 +7,14 @@ var define = require('define-properties');
7
7
var hasSymbols = require ( 'has-symbols' ) ( ) ;
8
8
var ArrayFrom = require ( 'array.from' ) . implementation ;
9
9
10
- /* eslint-disable */
11
-
12
- var testMapping = function ( t , map , key , value , desc ) {
13
- if ( ! desc ) desc = "" ;
14
- t . equal ( map . has ( key ) , false , desc + " - .has(key) returns false" ) ;
15
- t . equal ( map . get ( key ) , undefined , desc + " - .get(key) returns undefined" ) ;
16
- t . equal ( map . set ( key , value ) , map , desc + " - .set(key) returns the map" ) ;
17
- t . equal ( map . get ( key ) , value , desc + " - .get(key) returns the value" ) ;
18
- t . equal ( map . has ( key ) , true , desc + " - .has(key) returns true" ) ;
10
+ // eslint-disable-next-line max-params
11
+ var testMapping = function testMapping ( t , map , key , value , desc ) {
12
+ if ( ! desc ) { desc = '' ; } // eslint-disable-line no-param-reassign
13
+ t . equal ( map . has ( key ) , false , desc + ' - .has(key) returns false' ) ;
14
+ t . equal ( map . get ( key ) , undefined , desc + ' - .get(key) returns undefined' ) ;
15
+ t . equal ( map . set ( key , value ) , map , desc + ' - .set(key) returns the map' ) ;
16
+ t . equal ( map . get ( key ) , value , desc + ' - .get(key) returns the value' ) ;
17
+ t . equal ( map . has ( key ) , true , desc + ' - .has(key) returns true' ) ;
19
18
} ;
20
19
21
20
var entriesArray = function ( map ) {
@@ -43,22 +42,22 @@ var expectNotEnumerable = function (t, object, desc) {
43
42
}
44
43
} ;
45
44
46
- module . exports = function ( Map , t ) {
45
+ module . exports = function runTests ( Map , t ) {
47
46
t . test ( 'should has valid getter and setter calls' , function ( st ) {
48
47
var map = new Map ( ) ;
49
48
50
- st . doesNotThrow ( function ( ) { map . get ( { } ) } ) ;
51
- st . doesNotThrow ( function ( ) { map . set ( { } ) } ) ;
52
- st . doesNotThrow ( function ( ) { map . has ( { } ) } ) ;
53
- st . doesNotThrow ( function ( ) { map [ " delete" ] ( { } ) } ) ;
49
+ st . doesNotThrow ( function ( ) { map . get ( { } ) ; } ) ;
50
+ st . doesNotThrow ( function ( ) { map . set ( { } ) ; } ) ;
51
+ st . doesNotThrow ( function ( ) { map . has ( { } ) ; } ) ;
52
+ st . doesNotThrow ( function ( ) { map [ ' delete' ] ( { } ) ; } ) ;
54
53
55
54
st . end ( ) ;
56
55
} ) ;
57
56
58
- t . test ( 'throws when `.call`ed with an existing instance' , function ( t ) {
57
+ t . test ( 'throws when `.call`ed with an existing instance' , function ( st ) {
59
58
var map = new Map ( ) ;
60
- t . throws ( function ( ) { Map . call ( map ) ; } , 'Map can not be .called on an existing map' ) ;
61
- t . end ( ) ;
59
+ st [ ' throws' ] ( function ( ) { Map . call ( map ) ; } , 'Map can not be .called on an existing map' ) ;
60
+ st . end ( ) ;
62
61
} ) ;
63
62
64
63
t . test ( 'should accept an iterable as argument' , function ( st ) {
@@ -78,16 +77,16 @@ module.exports = function (Map, t) {
78
77
} ) ;
79
78
80
79
t . test ( 'should throw with iterables that return primitives' , function ( st ) {
81
- st . throws ( function ( ) { return new Map ( '123' ) ; } , TypeError , 'string' ) ;
82
- st . throws ( function ( ) { return new Map ( [ 1 , 2 , 3 ] ) ; } , TypeError , 'array of numbers' ) ;
83
- st . throws ( function ( ) { return new Map ( [ '1' , '2' , '3' ] ) ; } , TypeError , 'array of strings' ) ;
84
- st . throws ( function ( ) { return new Map ( [ true ] ) ; } , TypeError , 'array of booleans' ) ;
80
+ st [ ' throws' ] ( function ( ) { return new Map ( '123' ) ; } , TypeError , 'string' ) ;
81
+ st [ ' throws' ] ( function ( ) { return new Map ( [ 1 , 2 , 3 ] ) ; } , TypeError , 'array of numbers' ) ;
82
+ st [ ' throws' ] ( function ( ) { return new Map ( [ '1' , '2' , '3' ] ) ; } , TypeError , 'array of strings' ) ;
83
+ st [ ' throws' ] ( function ( ) { return new Map ( [ true ] ) ; } , TypeError , 'array of booleans' ) ;
85
84
86
85
st . end ( ) ;
87
86
} ) ;
88
87
89
88
t . test ( 'should not be callable without "new"' , function ( st ) {
90
- st . throws ( Map , TypeError , 'call without new' ) ;
89
+ st [ ' throws' ] ( Map , TypeError , 'call without new' ) ;
91
90
92
91
st . end ( ) ;
93
92
} ) ;
@@ -188,11 +187,11 @@ module.exports = function (Map, t) {
188
187
var map = new Map ( ) ;
189
188
190
189
testMapping ( st , map , { } , true , 'test {} key' ) ;
191
- testMapping ( st , map , null , true , 'test null key' ) ;
192
- testMapping ( st , map , undefined , true , 'test undefined key' ) ;
190
+ testMapping ( st , map , null , true , 'test null key' ) ;
191
+ testMapping ( st , map , undefined , true , 'test undefined key' ) ;
193
192
testMapping ( st , map , '' , true , 'test "" key' ) ;
194
- testMapping ( st , map , NaN , true , 'test NaN key' ) ;
195
- testMapping ( st , map , 0 , true , 'test 0 key' ) ;
193
+ testMapping ( st , map , NaN , true , 'test NaN key' ) ;
194
+ testMapping ( st , map , 0 , true , 'test 0 key' ) ;
196
195
197
196
st . end ( ) ;
198
197
} ) ;
@@ -351,8 +350,8 @@ module.exports = function (Map, t) {
351
350
t . test ( '#size' , { skip : ! define . supportsDescriptors } , function ( st ) {
352
351
st . test ( 'throws TypeError when accessed directly' , function ( sst ) {
353
352
// see https://github.com/paulmillr/es6-shim/issues/176
354
- sst . throws ( function ( ) { return Map . prototype . size ; } , TypeError , 'Map.prototype.set throws (1)' ) ;
355
- sst . throws ( function ( ) { return Map . prototype . size ; } , TypeError , 'Map.prototype.set throws (2)' ) ;
353
+ sst [ ' throws' ] ( function ( ) { return Map . prototype . size ; } , TypeError , 'Map.prototype.set throws (1)' ) ;
354
+ sst [ ' throws' ] ( function ( ) { return Map . prototype . size ; } , TypeError , 'Map.prototype.set throws (2)' ) ;
356
355
357
356
sst . end ( ) ;
358
357
} ) ;
@@ -636,12 +635,14 @@ module.exports = function (Map, t) {
636
635
st . end ( ) ;
637
636
} ) ;
638
637
639
- // Disabled since we don't have Set here
640
- // t.test('MapIterator identification test prototype inequality', { skip: !Object.getPrototypeOf }, function (st) {
641
- // var mapEntriesProto = Object.getPrototypeOf(new Map().entries());
642
- // var setEntriesProto = Object.getPrototypeOf(new Set().entries());
643
- // st.notEqual(mapEntriesProto, setEntriesProto);
644
- // });
638
+ /*
639
+ * Disabled since we don't have Set here
640
+ * t.test('MapIterator identification test prototype inequality', { skip: !Object.getPrototypeOf }, function (st) {
641
+ * var mapEntriesProto = Object.getPrototypeOf(new Map().entries());
642
+ * var setEntriesProto = Object.getPrototypeOf(new Set().entries());
643
+ * st.notEqual(mapEntriesProto, setEntriesProto);
644
+ * });
645
+ */
645
646
646
647
t . test ( 'MapIterator identification' , function ( st ) {
647
648
var fnMapValues = Map . prototype . values ;
@@ -650,11 +651,13 @@ module.exports = function (Map, t) {
650
651
var testMapValues = testMap . values ( ) ;
651
652
st . equal ( testMapValues . next . call ( fnMapValues . call ( mapSentinel ) ) . value , 'MapSentinel' , 'extracts value from a different map' ) ;
652
653
653
- // var testSet = new Set();
654
- // var testSetValues = testSet.values();
655
- // st.throws(function () {
656
- // return testSetValues.next.call(fnMapValues.call(mapSentinel)).value;
657
- // }, TypeError);
654
+ /*
655
+ * var testSet = new Set();
656
+ * var testSetValues = testSet.values();
657
+ * st.throws(function () {
658
+ * return testSetValues.next.call(fnMapValues.call(mapSentinel)).value;
659
+ * }, TypeError);
660
+ */
658
661
659
662
st . end ( ) ;
660
663
} ) ;
0 commit comments