1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | import { upcastType } from './types';
|
18 | describe('upcastType', () => {
|
19 | it('upcasts bool to bool', () => {
|
20 | expect(upcastType('bool', 'bool')).toBe('bool');
|
21 | });
|
22 | it('upcasts bool/int32 to int32', () => {
|
23 | expect(upcastType('bool', 'int32')).toBe('int32');
|
24 | expect(upcastType('int32', 'int32')).toBe('int32');
|
25 | });
|
26 | it('upcasts bool/int32/float32 to float32', () => {
|
27 | expect(upcastType('bool', 'float32')).toBe('float32');
|
28 | expect(upcastType('int32', 'float32')).toBe('float32');
|
29 | expect(upcastType('float32', 'float32')).toBe('float32');
|
30 | });
|
31 | it('upcasts bool/int32/float32/complex64 to complex64', () => {
|
32 | expect(upcastType('bool', 'complex64')).toBe('complex64');
|
33 | expect(upcastType('int32', 'complex64')).toBe('complex64');
|
34 | expect(upcastType('float32', 'complex64')).toBe('complex64');
|
35 | expect(upcastType('complex64', 'complex64')).toBe('complex64');
|
36 | });
|
37 | it('fails to upcast anything other than string with string', () => {
|
38 | expect(() => upcastType('bool', 'string')).toThrowError();
|
39 | expect(() => upcastType('int32', 'string')).toThrowError();
|
40 | expect(() => upcastType('float32', 'string')).toThrowError();
|
41 | expect(() => upcastType('complex64', 'string')).toThrowError();
|
42 |
|
43 | expect(upcastType('string', 'string')).toBe('string');
|
44 | });
|
45 | });
|
46 |
|
\ | No newline at end of file |