11import { describe , expect , it } from 'vitest' ;
22
3- import { assertDatasetValue , assertScalarValue } from './guards' ;
3+ import { assertScalarValue , assertValue } from './guards' ;
44import {
55 boolType ,
66 compoundType ,
@@ -108,43 +108,37 @@ describe('assertScalarValue', () => {
108108 } ) ;
109109} ) ;
110110
111- describe ( 'assertDatasetValue ' , ( ) => {
111+ describe ( 'assertValue ' , ( ) => {
112112 it ( 'should not throw when value satisfies dataset type and shape' , ( ) => {
113113 expect ( ( ) =>
114- assertDatasetValue ( 0 , dataset ( 'foo' , intType ( ) , [ ] ) ) ,
114+ assertValue ( 0 , dataset ( 'foo' , intType ( ) , [ ] ) ) ,
115115 ) . not . toThrowError ( ) ;
116116
117117 expect ( ( ) =>
118- assertDatasetValue ( 0n , dataset ( 'foo' , intType ( false , 64 ) , [ ] ) ) ,
118+ assertValue ( 0n , dataset ( 'foo' , intType ( false , 64 ) , [ ] ) ) ,
119119 ) . not . toThrowError ( ) ;
120120
121121 expect ( ( ) =>
122- assertDatasetValue ( '' , dataset ( 'foo' , strType ( ) , [ ] ) ) ,
122+ assertValue ( '' , dataset ( 'foo' , strType ( ) , [ ] ) ) ,
123123 ) . not . toThrowError ( ) ;
124124
125125 expect ( ( ) =>
126- assertDatasetValue (
127- [ true , false ] ,
128- dataset ( 'foo' , boolType ( intType ( ) ) , [ 2 ] ) ,
129- ) ,
126+ assertValue ( [ true , false ] , dataset ( 'foo' , boolType ( intType ( ) ) , [ 2 ] ) ) ,
130127 ) . not . toThrowError ( ) ;
131128
132129 expect ( ( ) =>
133- assertDatasetValue (
134- Float32Array . from ( [ 0 , 1 ] ) ,
135- dataset ( 'foo' , floatType ( ) , [ 2 ] ) ,
136- ) ,
130+ assertValue ( Float32Array . from ( [ 0 , 1 ] ) , dataset ( 'foo' , floatType ( ) , [ 2 ] ) ) ,
137131 ) . not . toThrowError ( ) ;
138132
139133 expect ( ( ) =>
140- assertDatasetValue (
134+ assertValue (
141135 BigInt64Array . from ( [ 0n , 1n ] ) ,
142136 dataset ( 'foo' , intType ( true , 64 ) , [ 2 ] ) ,
143137 ) ,
144138 ) . not . toThrowError ( ) ;
145139
146140 expect ( ( ) =>
147- assertDatasetValue (
141+ assertValue (
148142 Float32Array . from ( [ 0 , 1 ] ) , // big ints can be returned as any kind of numbers
149143 dataset ( 'foo' , intType ( true , 64 ) , [ 2 ] ) ,
150144 ) ,
@@ -154,18 +148,15 @@ describe('assertDatasetValue', () => {
154148 describe ( 'assertDatasetValue' , ( ) => {
155149 it ( "should throw when value doesn't satisfy dataset type and shape" , ( ) => {
156150 expect ( ( ) =>
157- assertDatasetValue (
158- true ,
159- dataset ( 'foo' , enumType ( intType ( ) , { FOO : 0 } ) , [ ] ) ,
160- ) ,
151+ assertValue ( true , dataset ( 'foo' , enumType ( intType ( ) , { FOO : 0 } ) , [ ] ) ) ,
161152 ) . toThrowError ( 'Expected number' ) ;
162153
163154 expect ( ( ) =>
164- assertDatasetValue ( [ 'foo' , 'bar' ] , dataset ( 'foo' , intType ( ) , [ 2 ] ) ) ,
155+ assertValue ( [ 'foo' , 'bar' ] , dataset ( 'foo' , intType ( ) , [ 2 ] ) ) ,
165156 ) . toThrowError ( 'Expected number' ) ;
166157
167158 expect ( ( ) =>
168- assertDatasetValue (
159+ assertValue (
169160 BigInt64Array . from ( [ 0n , 1n ] ) ,
170161 dataset ( 'foo' , intType ( ) , [ 2 ] ) ,
171162 ) ,
0 commit comments