-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuint-test.js
More file actions
38 lines (33 loc) · 1.09 KB
/
uint-test.js
File metadata and controls
38 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const assert = require('assert');
const coreTypes = require('../src/coretypes');
/* eslint-disable no-unused-vars */
const {UInt8, UInt16, UInt32, UInt64} = coreTypes;
/* eslint-enable no-unused-vars */
function compareToTests() {
function check(expr, is) {
it(expr, function() {
/* eslint-disable no-eval */
assert.equal(eval(expr), is);
/* eslint-enable no-eval */
});
}
check('UInt8.from(124).compareTo(UInt64.from(124))', 0);
check('UInt64.from(124).compareTo(UInt8.from(124))', 0);
check('UInt64.from(124).compareTo(UInt8.from(123))', 1);
check('UInt8.from(124).compareTo(UInt8.from(13))', 1);
check('UInt8.from(124).compareTo(124)', 0);
check('UInt64.from(124).compareTo(124)', 0);
check('UInt64.from(124).compareTo(123)', 1);
check('UInt8.from(124).compareTo(13)', 1);
}
function valueOfTests() {
it('The Uint classes work with |= operator', function() {
let val = UInt8.from(1);
val |= 0x2;
assert.equal(val, 3);
});
}
describe('Uint*', function() {
describe('compareToTests', compareToTests);
describe('valueOfTests', valueOfTests);
});