Skip to content

Commit 2ebe5b2

Browse files
🔍 test: Fix t.throws calls.
1 parent 1f16ca5 commit 2ebe5b2

File tree

7 files changed

+60
-60
lines changed

7 files changed

+60
-60
lines changed

test/src/chainmap.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ test( "chainmap" , t => {
8888

8989
M = M.parents( ) ;
9090

91-
t.throws( M.get.bind( M , "w" ) , KeyError , "w throws" ) ;
91+
t.throws( M.get.bind( M , "w" ) , { instanceOf: KeyError } , "w throws" ) ;
9292

9393
t.deepEqual( M.len( ) , 3 , "-w DBAC len" ) ;
9494
t.deepEqual( M.get( "x" ) , "B" , "-w BAC depth 1" ) ;
@@ -100,7 +100,7 @@ test( "chainmap" , t => {
100100
t.true( M.has( "z" ) , "has z BAC depth 3" ) ;
101101

102102
t.deepEqual( M.delete( "x" ).len( ) , 3 , "delete" ) ;
103-
t.throws( M.delete.bind( M , "x" ) , KeyError , "delete raises" ) ;
103+
t.throws( M.delete.bind( M , "x" ) , { instanceOf: KeyError } , "delete raises" ) ;
104104
t.deepEqual( M.get( "x" ) , "A" , "-wx AC depth 1" ) ;
105105

106106
t.deepEqual( chainmap( C ).clear( ).len( ) , 0 , "clear" ) ;
@@ -115,8 +115,8 @@ test( "chainmap" , t => {
115115

116116
M = chainmap.fromkeys( "x" ).new_child( ) ;
117117

118-
t.throws( M.popitem.bind( M ) , KeyError , "popitem empty map[0]" ) ;
119-
t.throws( M.pop.bind( M , "x" ) , KeyError , "pop empty map[0]" ) ;
118+
t.throws( M.popitem.bind( M ) , { instanceOf: KeyError } , "popitem empty map[0]" ) ;
119+
t.throws( M.pop.bind( M , "x" ) , { instanceOf: KeyError } , "pop empty map[0]" ) ;
120120

121121
t.deepEqual( chainmap( ).getdefault( "y" ) , null , "getdefault null" ) ;
122122
t.deepEqual( chainmap( ).getdefault( "y" , "A" ) , "A" , "getdefault A" ) ;
@@ -129,9 +129,9 @@ test( "chainmap" , t => {
129129
"delete" : function ( ) { throw new Error( ) ; }
130130
} ) ;
131131

132-
t.throws( M.get.bind( M , 0 ) , Error , "get forwards" ) ;
133-
t.throws( M.pop.bind( M ) , Error , "pop forwards" ) ;
134-
t.throws( M.popitem.bind( M ) , Error , "popitem forwards" ) ;
135-
t.throws( M.delete.bind( M , 0 ) , Error , "delete forwards" ) ;
132+
t.throws( M.get.bind( M , 0 ) , null , "get forwards" ) ;
133+
t.throws( M.pop.bind( M ) , null , "pop forwards" ) ;
134+
t.throws( M.popitem.bind( M ) , null , "popitem forwards" ) ;
135+
t.throws( M.delete.bind( M , 0 ) , null , "delete forwards" ) ;
136136

137137
} ) ;

test/src/counter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ test( "counter" , t => {
4545
c = counter( [ "eggs" , "ham" ] ) ;
4646
t.deepEqual( c.get( "bacon" ) , 0 , "count of a missing element is zero" ) ;
4747

48-
t.throws( counter.fromkeys.bind( null , "abc" ) , NotImplementedError , "fromkeys default" ) ;
49-
t.throws( counter.fromkeys.bind( null , "abc" , 1 ) , NotImplementedError , "fromkeys" ) ;
48+
t.throws( counter.fromkeys.bind( null , "abc" ) , { instanceOf: NotImplementedError } , "fromkeys default" ) ;
49+
t.throws( counter.fromkeys.bind( null , "abc" , 1 ) , { instanceOf: NotImplementedError } , "fromkeys" ) ;
5050

5151
t.deepEqual( counter('aab').most_common(1) , [['a', 2]] , "most_common aab" ) ;
5252
t.deepEqual( counter('abracadabra').most_common(0) , [] , "most_common 0" ) ;

test/src/defaultdict.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ test( defaultdict.name , t => {
122122

123123
d.clear( ) ;
124124

125-
t.throws( d.get.bind( d , "x" ) , KeyError , "get raises" ) ;
125+
t.throws( d.get.bind( d , "x" ) , { instanceOf: KeyError } , "get raises" ) ;
126126

127-
t.throws( d.delete.bind( d , "x" ) , KeyError , "delete raises" ) ;
127+
t.throws( d.delete.bind( d , "x" ) , { instanceOf: KeyError } , "delete raises" ) ;
128128

129-
t.throws( d.popitem.bind( d ) , KeyError , "popitem raises" ) ;
129+
t.throws( d.popitem.bind( d ) , { instanceOf: KeyError } , "popitem raises" ) ;
130130

131-
t.throws( d.pop.bind( d , "x" ) , KeyError , "pop raises" ) ;
131+
t.throws( d.pop.bind( d , "x" ) , { instanceOf: KeyError } , "pop raises" ) ;
132132

133133
t.deepEqual( defaultdict.fromkeys( "abc" , -1 , default_factory ).get( "b" ) , -1 , "fromkeys default -1" ) ;
134134

test/src/deque.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,28 @@ test( deque.name , t => {
2424

2525
let d = new Deque( ) ;
2626

27-
t.throws( d.values.bind( d ) , NotImplementedError , "Deque values" ) ;
28-
t.throws( l.bind( null , d ) , NotImplementedError , "list( Deque )" ) ;
29-
t.throws( d.len.bind( d ) , NotImplementedError , "Deque len" ) ;
30-
t.throws( d.capacity.bind( d ) , NotImplementedError , "Deque capacity" ) ;
31-
t.throws( d.empty.bind( d ) , NotImplementedError , "Deque empty" ) ;
32-
t.throws( d.append.bind( d , 0 ) , NotImplementedError , "Deque append" ) ;
33-
t.throws( d.appendleft.bind( d , 0 ) , NotImplementedError , "Deque appendleft" ) ;
34-
t.throws( d.clear.bind( d ) , NotImplementedError , "Deque clear" ) ;
35-
t.throws( d.copy.bind( d ) , NotImplementedError , "Deque copy" ) ;
36-
t.throws( d.count.bind( d , 0 ) , NotImplementedError , "Deque count" ) ;
37-
t.throws( d.extend.bind( d , "a" ) , NotImplementedError , "Deque extend" ) ;
38-
t.throws( d.extendleft.bind( d , "a" ) , NotImplementedError , "Deque extendleft" ) ;
39-
t.throws( d._where.bind( d , 0 ) , NotImplementedError , "Deque _where" ) ;
40-
t.throws( d.get.bind( d , 0 ) , NotImplementedError , "Deque get" ) ;
41-
t.throws( d.set.bind( d , 0 , 0 ) , NotImplementedError , "Deque set" ) ;
42-
t.throws( d.insert.bind( d , 0 , 0 ) , NotImplementedError , "Deque insert" ) ;
43-
t.throws( d.pop.bind( d ) , NotImplementedError , "Deque pop" ) ;
44-
t.throws( d.popleft.bind( d ) , NotImplementedError , "Deque popleft" ) ;
45-
46-
t.throws( deque.bind( null , null , 1.2 ) , TypeError , "maxlen float" ) ;
47-
t.throws( deque.bind( null , null , -1 ) , ValueError , "maxlen negative" ) ;
48-
t.throws( deque.bind( null , null , { } ) , TypeError , "maxlen object" ) ;
27+
t.throws( d.values.bind( d ) , { instanceOf: NotImplementedError } , "Deque values" ) ;
28+
t.throws( l.bind( null , d ) , { instanceOf: NotImplementedError } , "list( Deque )" ) ;
29+
t.throws( d.len.bind( d ) , { instanceOf: NotImplementedError } , "Deque len" ) ;
30+
t.throws( d.capacity.bind( d ) , { instanceOf: NotImplementedError } , "Deque capacity" ) ;
31+
t.throws( d.empty.bind( d ) , { instanceOf: NotImplementedError } , "Deque empty" ) ;
32+
t.throws( d.append.bind( d , 0 ) , { instanceOf: NotImplementedError } , "Deque append" ) ;
33+
t.throws( d.appendleft.bind( d , 0 ) , { instanceOf: NotImplementedError } , "Deque appendleft" ) ;
34+
t.throws( d.clear.bind( d ) , { instanceOf: NotImplementedError } , "Deque clear" ) ;
35+
t.throws( d.copy.bind( d ) , { instanceOf: NotImplementedError } , "Deque copy" ) ;
36+
t.throws( d.count.bind( d , 0 ) , { instanceOf: NotImplementedError } , "Deque count" ) ;
37+
t.throws( d.extend.bind( d , "a" ) , { instanceOf: NotImplementedError } , "Deque extend" ) ;
38+
t.throws( d.extendleft.bind( d , "a" ) , { instanceOf: NotImplementedError } , "Deque extendleft" ) ;
39+
t.throws( d._where.bind( d , 0 ) , { instanceOf: NotImplementedError } , "Deque _where" ) ;
40+
t.throws( d.get.bind( d , 0 ) , { instanceOf: NotImplementedError } , "Deque get" ) ;
41+
t.throws( d.set.bind( d , 0 , 0 ) , { instanceOf: NotImplementedError } , "Deque set" ) ;
42+
t.throws( d.insert.bind( d , 0 , 0 ) , { instanceOf: NotImplementedError } , "Deque insert" ) ;
43+
t.throws( d.pop.bind( d ) , { instanceOf: NotImplementedError } , "Deque pop" ) ;
44+
t.throws( d.popleft.bind( d ) , { instanceOf: NotImplementedError } , "Deque popleft" ) ;
45+
46+
t.throws( deque.bind( null , null , 1.2 ) , { instanceOf: TypeError } , "maxlen float" ) ;
47+
t.throws( deque.bind( null , null , -1 ) , { instanceOf: ValueError } , "maxlen negative" ) ;
48+
t.throws( deque.bind( null , null , { } ) , { instanceOf: TypeError } , "maxlen object" ) ;
4949

5050
t.true( deque( ).empty( ) , "empty" ) ;
5151
t.true( !deque( "abc" ).empty( ) , "not empty" ) ;
@@ -86,9 +86,9 @@ test( deque.name , t => {
8686
t.true( d.copy( ) !== d , "empty copy is different" ) ;
8787
t.deepEqual( d.clear( ) , d , "empty clear" ) ;
8888

89-
t.throws( d.append( "a" ).get.bind( d , 0 ) , IndexError , "empty get" ) ;
90-
t.throws( d.append( "a" ).set.bind( d , 0 , "b" ) , IndexError , "empty set" ) ;
91-
t.throws( d.append( "a" ).pop.bind( d ) , IndexError , "empty pop" ) ;
89+
t.throws( d.append( "a" ).get.bind( d , 0 ) , { instanceOf: IndexError } , "empty get" ) ;
90+
t.throws( d.append( "a" ).set.bind( d , 0 , "b" ) , { instanceOf: IndexError } , "empty set" ) ;
91+
t.throws( d.append( "a" ).pop.bind( d ) , { instanceOf: IndexError } , "empty pop" ) ;
9292

9393
d = deque( "abc" , 1 ) ;
9494

@@ -98,12 +98,12 @@ test( deque.name , t => {
9898
t.deepEqual( d.clear( ) , d , "single clear" ) ;
9999
t.deepEqual( d.clear( ).len( ) , 0 , "single clear len" ) ;
100100

101-
t.throws( d.append( "a" ).get.bind( d , 1 ) , IndexError , "single get 1" ) ;
102-
t.throws( d.append( "a" ).set.bind( d , 1 , "b" ) , IndexError , "single set 1" ) ;
103-
t.throws( d.clear( ).pop.bind( d ) , IndexError , "single pop clear" ) ;
101+
t.throws( d.append( "a" ).get.bind( d , 1 ) , { instanceOf: IndexError } , "single get 1" ) ;
102+
t.throws( d.append( "a" ).set.bind( d , 1 , "b" ) , { instanceOf: IndexError } , "single set 1" ) ;
103+
t.throws( d.clear( ).pop.bind( d ) , { instanceOf: IndexError } , "single pop clear" ) ;
104104

105-
t.throws( d.clear( ).get.bind( d , 0 ) , IndexError , "single empty get 0" ) ;
106-
t.throws( d.clear( ).set.bind( d , 0 , "b" ) , IndexError , "single empty set 0" ) ;
105+
t.throws( d.clear( ).get.bind( d , 0 ) , { instanceOf: IndexError } , "single empty get 0" ) ;
106+
t.throws( d.clear( ).set.bind( d , 0 , "b" ) , { instanceOf: IndexError } , "single empty set 0" ) ;
107107

108108
d.extend( "abcdef" ) ;
109109

@@ -221,11 +221,11 @@ test( deque.name , t => {
221221
t.deepEqual( deque( "abc" ).index( "b" ) , 1 , "index abc" ) ;
222222
t.deepEqual( deque( "abcb" ).index( "b" ) , 1 , "index abcb" ) ;
223223
t.deepEqual( deque( "abcb" ).index( "b" , 2 ) , 3 , "index abcb 2" ) ;
224-
t.throws( d.clear( ).extend( "abc" ).index.bind( d , "d" ) , ValueError , "index raises" ) ;
225-
t.throws( d.clear( ).extend( "abc" ).index.bind( d , "b" , 2 , 3 ) , ValueError , "index raises range" ) ;
224+
t.throws( d.clear( ).extend( "abc" ).index.bind( d , "d" ) , { instanceOf: ValueError } , "index raises" ) ;
225+
t.throws( d.clear( ).extend( "abc" ).index.bind( d , "b" , 2 , 3 ) , { instanceOf: ValueError } , "index raises range" ) ;
226226

227-
t.throws( d.clear( ).extend( "abc" ).get.bind( d , -1 ) , IndexError , "get -1" ) ;
228-
t.throws( d.clear( ).extend( "abc" ).get.bind( d , 4 ) , IndexError , "get out of bounds" ) ;
227+
t.throws( d.clear( ).extend( "abc" ).get.bind( d , -1 ) , { instanceOf: IndexError } , "get -1" ) ;
228+
t.throws( d.clear( ).extend( "abc" ).get.bind( d , 4 ) , { instanceOf: IndexError } , "get out of bounds" ) ;
229229

230230
t.deepEqual( l( deque( "abcde" ).rotate( 2 ) ) , l( "deabc" ) , "rotate 2" ) ;
231231
t.deepEqual( l( deque( "abcde" ).rotate( 0 ) ) , l( "abcde" ) , "rotate 0" ) ;

test/src/dict.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ test( dict.name , t => {
126126

127127
d.clear( ) ;
128128

129-
t.throws( d.get.bind( d , "x" ) , KeyError , "get raises" ) ;
129+
t.throws( d.get.bind( d , "x" ) , { instanceOf: KeyError } , "get raises" ) ;
130130

131-
t.throws( d.delete.bind( d , "x" ) , KeyError , "delete raises" ) ;
131+
t.throws( d.delete.bind( d , "x" ) , { instanceOf: KeyError } , "delete raises" ) ;
132132

133-
t.throws( d.popitem.bind( d ) , KeyError , "popitem raises" ) ;
133+
t.throws( d.popitem.bind( d ) , { instanceOf: KeyError } , "popitem raises" ) ;
134134

135-
t.throws( d.pop.bind( d , "x" ) , KeyError , "pop raises" ) ;
135+
t.throws( d.pop.bind( d , "x" ) , { instanceOf: KeyError } , "pop raises" ) ;
136136

137137
t.deepEqual( dict.fromkeys( "abc" , -1 ).get( "b" ) , -1 , "fromkeys default -1" ) ;
138138

test/src/ordereddict.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ test( ordereddict.name , t => {
4242

4343
t.deepEqual( list( d.items( ) ) , [ [ "x" , -1 ] ] , "popitem items" ) ;
4444

45-
t.throws( d.clear( ).move_to_end.bind( d , "x" ) , KeyError , "move_to_end raises" ) ;
45+
t.throws( d.clear( ).move_to_end.bind( d , "x" ) , { instanceOf: KeyError } , "move_to_end raises" ) ;
4646

47-
t.throws( d.clear( ).move_to_end.bind( d , "x" , false ) , KeyError , "move_to_end false raises" ) ;
47+
t.throws( d.clear( ).move_to_end.bind( d , "x" , false ) , { instanceOf: KeyError } , "move_to_end false raises" ) ;
4848

49-
t.throws( d.clear( ).popitem.bind( d ) , KeyError , "popitem raises" ) ;
49+
t.throws( d.clear( ).popitem.bind( d ) , { instanceOf: KeyError } , "popitem raises" ) ;
5050

51-
t.throws( d.clear( ).popitem.bind( d , false ) , KeyError , "popitem false raises" ) ;
51+
t.throws( d.clear( ).popitem.bind( d , false ) , { instanceOf: KeyError } , "popitem false raises" ) ;
5252

5353
t.true( d.clear( ).isequal( d ) , "equal self" ) ;
5454

test/src/set.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ test( set.name , t => {
195195
s.clear( ) ;
196196
t.true( s.isequal( "" ) , "clear" ) ;
197197

198-
t.throws( s.clear( ).pop.bind( s ) , KeyError , "pop raises" ) ;
199-
t.throws( s.clear( ).pop.bind( s ) , KeyError , "pop raises" ) ;
198+
t.throws( s.clear( ).pop.bind( s ) , { instanceOf: KeyError } , "pop raises" ) ;
199+
t.throws( s.clear( ).pop.bind( s ) , { instanceOf: KeyError } , "pop raises" ) ;
200200

201-
t.throws( s.clear( ).add( "x" ).remove.bind( s , "y" ) , KeyError , "remove raises" ) ;
202-
t.throws( s.clear( ).add( "x" ).remove.bind( s , "y" ) , KeyError , "remove raises" ) ;
201+
t.throws( s.clear( ).add( "x" ).remove.bind( s , "y" ) , { instanceOf: KeyError } , "remove raises" ) ;
202+
t.throws( s.clear( ).add( "x" ).remove.bind( s , "y" ) , { instanceOf: KeyError } , "remove raises" ) ;
203203

204204
t.deepEqual( s.clear( ) , s , "ref clear" ) ;
205205
t.deepEqual( s.add( "x" ) , s , "ref add" ) ;

0 commit comments

Comments
 (0)