1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
19 | var int64_tensors_1 = require("./int64_tensors");
|
20 | describe('int64 tensors', function () {
|
21 | it('positive value', function () {
|
22 | var x = new int64_tensors_1.Int64Scalar(42);
|
23 | expect(x.dtype).toEqual('int64');
|
24 | var valueArray = x.valueArray;
|
25 | expect(valueArray.constructor.name).toEqual('Int32Array');
|
26 | expect(valueArray.length).toEqual(2);
|
27 | expect(valueArray[0]).toEqual(42);
|
28 | expect(valueArray[1]).toEqual(0);
|
29 | });
|
30 | it('zero value', function () {
|
31 | var x = new int64_tensors_1.Int64Scalar(0);
|
32 | expect(x.dtype).toEqual('int64');
|
33 | var valueArray = x.valueArray;
|
34 | expect(valueArray.constructor.name).toEqual('Int32Array');
|
35 | expect(valueArray.length).toEqual(2);
|
36 | expect(valueArray[0]).toEqual(0);
|
37 | expect(valueArray[1]).toEqual(0);
|
38 | });
|
39 | it('negative value', function () {
|
40 | var x = new int64_tensors_1.Int64Scalar(-3);
|
41 | expect(x.dtype).toEqual('int64');
|
42 | var valueArray = x.valueArray;
|
43 | expect(valueArray.constructor.name).toEqual('Int32Array');
|
44 | expect(valueArray.length).toEqual(2);
|
45 | expect(valueArray[0]).toEqual(-3);
|
46 | expect(valueArray[1]).toEqual(-1);
|
47 | });
|
48 | it('Non-integer value leads to error', function () {
|
49 | expect(function () { return new int64_tensors_1.Int64Scalar(0.4); }).toThrowError(/integer/);
|
50 | expect(function () { return new int64_tensors_1.Int64Scalar(-3.2); }).toThrowError(/integer/);
|
51 | });
|
52 | it('Out-of-bound value leads to error', function () {
|
53 | expect(function () { return new int64_tensors_1.Int64Scalar(2147483648); }).toThrowError(/bound/);
|
54 | expect(function () { return new int64_tensors_1.Int64Scalar(2147483648 * 2); }).toThrowError(/bound/);
|
55 | expect(function () { return new int64_tensors_1.Int64Scalar(-2147483648 - 1); }).toThrowError(/bound/);
|
56 | });
|
57 | });
|