Skip to content

Commit

Permalink
🔍 test: Fix t.throws calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Apr 28, 2020
1 parent 1f16ca5 commit 2ebe5b2
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 60 deletions.
16 changes: 8 additions & 8 deletions test/src/chainmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ test( "chainmap" , t => {

M = M.parents( ) ;

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

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

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

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

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

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

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

t.throws( M.get.bind( M , 0 ) , Error , "get forwards" ) ;
t.throws( M.pop.bind( M ) , Error , "pop forwards" ) ;
t.throws( M.popitem.bind( M ) , Error , "popitem forwards" ) ;
t.throws( M.delete.bind( M , 0 ) , Error , "delete forwards" ) ;
t.throws( M.get.bind( M , 0 ) , null , "get forwards" ) ;
t.throws( M.pop.bind( M ) , null , "pop forwards" ) ;
t.throws( M.popitem.bind( M ) , null , "popitem forwards" ) ;
t.throws( M.delete.bind( M , 0 ) , null , "delete forwards" ) ;

} ) ;
4 changes: 2 additions & 2 deletions test/src/counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ test( "counter" , t => {
c = counter( [ "eggs" , "ham" ] ) ;
t.deepEqual( c.get( "bacon" ) , 0 , "count of a missing element is zero" ) ;

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

t.deepEqual( counter('aab').most_common(1) , [['a', 2]] , "most_common aab" ) ;
t.deepEqual( counter('abracadabra').most_common(0) , [] , "most_common 0" ) ;
Expand Down
8 changes: 4 additions & 4 deletions test/src/defaultdict.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ test( defaultdict.name , t => {

d.clear( ) ;

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

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

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

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

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

Expand Down
68 changes: 34 additions & 34 deletions test/src/deque.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,28 @@ test( deque.name , t => {

let d = new Deque( ) ;

t.throws( d.values.bind( d ) , NotImplementedError , "Deque values" ) ;
t.throws( l.bind( null , d ) , NotImplementedError , "list( Deque )" ) ;
t.throws( d.len.bind( d ) , NotImplementedError , "Deque len" ) ;
t.throws( d.capacity.bind( d ) , NotImplementedError , "Deque capacity" ) ;
t.throws( d.empty.bind( d ) , NotImplementedError , "Deque empty" ) ;
t.throws( d.append.bind( d , 0 ) , NotImplementedError , "Deque append" ) ;
t.throws( d.appendleft.bind( d , 0 ) , NotImplementedError , "Deque appendleft" ) ;
t.throws( d.clear.bind( d ) , NotImplementedError , "Deque clear" ) ;
t.throws( d.copy.bind( d ) , NotImplementedError , "Deque copy" ) ;
t.throws( d.count.bind( d , 0 ) , NotImplementedError , "Deque count" ) ;
t.throws( d.extend.bind( d , "a" ) , NotImplementedError , "Deque extend" ) ;
t.throws( d.extendleft.bind( d , "a" ) , NotImplementedError , "Deque extendleft" ) ;
t.throws( d._where.bind( d , 0 ) , NotImplementedError , "Deque _where" ) ;
t.throws( d.get.bind( d , 0 ) , NotImplementedError , "Deque get" ) ;
t.throws( d.set.bind( d , 0 , 0 ) , NotImplementedError , "Deque set" ) ;
t.throws( d.insert.bind( d , 0 , 0 ) , NotImplementedError , "Deque insert" ) ;
t.throws( d.pop.bind( d ) , NotImplementedError , "Deque pop" ) ;
t.throws( d.popleft.bind( d ) , NotImplementedError , "Deque popleft" ) ;

t.throws( deque.bind( null , null , 1.2 ) , TypeError , "maxlen float" ) ;
t.throws( deque.bind( null , null , -1 ) , ValueError , "maxlen negative" ) ;
t.throws( deque.bind( null , null , { } ) , TypeError , "maxlen object" ) ;
t.throws( d.values.bind( d ) , { instanceOf: NotImplementedError } , "Deque values" ) ;
t.throws( l.bind( null , d ) , { instanceOf: NotImplementedError } , "list( Deque )" ) ;
t.throws( d.len.bind( d ) , { instanceOf: NotImplementedError } , "Deque len" ) ;
t.throws( d.capacity.bind( d ) , { instanceOf: NotImplementedError } , "Deque capacity" ) ;
t.throws( d.empty.bind( d ) , { instanceOf: NotImplementedError } , "Deque empty" ) ;
t.throws( d.append.bind( d , 0 ) , { instanceOf: NotImplementedError } , "Deque append" ) ;
t.throws( d.appendleft.bind( d , 0 ) , { instanceOf: NotImplementedError } , "Deque appendleft" ) ;
t.throws( d.clear.bind( d ) , { instanceOf: NotImplementedError } , "Deque clear" ) ;
t.throws( d.copy.bind( d ) , { instanceOf: NotImplementedError } , "Deque copy" ) ;
t.throws( d.count.bind( d , 0 ) , { instanceOf: NotImplementedError } , "Deque count" ) ;
t.throws( d.extend.bind( d , "a" ) , { instanceOf: NotImplementedError } , "Deque extend" ) ;
t.throws( d.extendleft.bind( d , "a" ) , { instanceOf: NotImplementedError } , "Deque extendleft" ) ;
t.throws( d._where.bind( d , 0 ) , { instanceOf: NotImplementedError } , "Deque _where" ) ;
t.throws( d.get.bind( d , 0 ) , { instanceOf: NotImplementedError } , "Deque get" ) ;
t.throws( d.set.bind( d , 0 , 0 ) , { instanceOf: NotImplementedError } , "Deque set" ) ;
t.throws( d.insert.bind( d , 0 , 0 ) , { instanceOf: NotImplementedError } , "Deque insert" ) ;
t.throws( d.pop.bind( d ) , { instanceOf: NotImplementedError } , "Deque pop" ) ;
t.throws( d.popleft.bind( d ) , { instanceOf: NotImplementedError } , "Deque popleft" ) ;

t.throws( deque.bind( null , null , 1.2 ) , { instanceOf: TypeError } , "maxlen float" ) ;
t.throws( deque.bind( null , null , -1 ) , { instanceOf: ValueError } , "maxlen negative" ) ;
t.throws( deque.bind( null , null , { } ) , { instanceOf: TypeError } , "maxlen object" ) ;

t.true( deque( ).empty( ) , "empty" ) ;
t.true( !deque( "abc" ).empty( ) , "not empty" ) ;
Expand Down Expand Up @@ -86,9 +86,9 @@ test( deque.name , t => {
t.true( d.copy( ) !== d , "empty copy is different" ) ;
t.deepEqual( d.clear( ) , d , "empty clear" ) ;

t.throws( d.append( "a" ).get.bind( d , 0 ) , IndexError , "empty get" ) ;
t.throws( d.append( "a" ).set.bind( d , 0 , "b" ) , IndexError , "empty set" ) ;
t.throws( d.append( "a" ).pop.bind( d ) , IndexError , "empty pop" ) ;
t.throws( d.append( "a" ).get.bind( d , 0 ) , { instanceOf: IndexError } , "empty get" ) ;
t.throws( d.append( "a" ).set.bind( d , 0 , "b" ) , { instanceOf: IndexError } , "empty set" ) ;
t.throws( d.append( "a" ).pop.bind( d ) , { instanceOf: IndexError } , "empty pop" ) ;

d = deque( "abc" , 1 ) ;

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

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

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

d.extend( "abcdef" ) ;

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

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

t.deepEqual( l( deque( "abcde" ).rotate( 2 ) ) , l( "deabc" ) , "rotate 2" ) ;
t.deepEqual( l( deque( "abcde" ).rotate( 0 ) ) , l( "abcde" ) , "rotate 0" ) ;
Expand Down
8 changes: 4 additions & 4 deletions test/src/dict.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ test( dict.name , t => {

d.clear( ) ;

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

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

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

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

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

Expand Down
8 changes: 4 additions & 4 deletions test/src/ordereddict.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ test( ordereddict.name , t => {

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

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

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

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

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

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

Expand Down
8 changes: 4 additions & 4 deletions test/src/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ test( set.name , t => {
s.clear( ) ;
t.true( s.isequal( "" ) , "clear" ) ;

t.throws( s.clear( ).pop.bind( s ) , KeyError , "pop raises" ) ;
t.throws( s.clear( ).pop.bind( s ) , KeyError , "pop raises" ) ;
t.throws( s.clear( ).pop.bind( s ) , { instanceOf: KeyError } , "pop raises" ) ;
t.throws( s.clear( ).pop.bind( s ) , { instanceOf: KeyError } , "pop raises" ) ;

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

t.deepEqual( s.clear( ) , s , "ref clear" ) ;
t.deepEqual( s.add( "x" ) , s , "ref add" ) ;
Expand Down

0 comments on commit 2ebe5b2

Please sign in to comment.