Skip to content

Commit 2e9115d

Browse files
committed
just a couple more tests
1 parent a0b4f1d commit 2e9115d

8 files changed

Lines changed: 351 additions & 38 deletions

File tree

test/datatypes/datetime-test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ describe('DateTime', () => {
219219
DateTime.fromJSDate(new Date(Date.UTC(1999, 1, 16, 13, 56, 24, 123)), +4.5).should.eql(
220220
DateTime.parse('1999-02-16T18:26:24.123+04:30')
221221
);
222+
DateTime.fromJSDate(
223+
new Date(Date.UTC(1999, 1, 16, 13, 56, 24, 123)),
224+
Decimal.from(-5)
225+
).should.eql(DateTime.parse('1999-02-16T08:56:24.123-05:00'));
222226
});
223227

224228
it('should construct from a Luxon DateTime', () =>

test/datatypes/decimal-test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ describe('Decimal', () => {
4242
Decimal.from('8').log(2).should.equalDecimal(Decimal.from(3));
4343
});
4444

45+
it('should reject an invalid scale', () => {
46+
(() => Decimal.from(1).setScale(-1)).should.throw(RangeError);
47+
(() => Decimal.from(1).setScale(1.5)).should.throw(RangeError);
48+
});
49+
4550
it('should reject non-finite and divide-by-zero values', () => {
4651
(() => Decimal.from('not a number')).should.throw();
4752
(() => Decimal.from(1).divideBy(0)).should.throw();

test/elm/aggregate/aggregate-test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,15 @@ describe('Mode', () => {
420420
(await this.bi_modal.exec(this.ctx)).should.eql([2, 3]);
421421
});
422422

423+
it('should preserve units for single and tied quantity modes', async function () {
424+
validateQuantity(await this.quantitySingleMode.exec(this.ctx), 1, 'g');
425+
426+
const modes = await this.quantityBiModal.exec(this.ctx);
427+
modes.should.have.length(2);
428+
validateQuantity(modes[0], 1, 'g');
429+
validateQuantity(modes[1], 2, 'g');
430+
});
431+
423432
it('should be null if some are numbers and some are quantities', async function () {
424433
should(await this.numbersAndQuantities.exec(this.ctx)).be.null();
425434
});

test/elm/aggregate/data.cql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ define has_null: Mode({1,null,null,2,2})
112112
define empty: Mode({})
113113

114114
define bi_modal: Mode({1,2,2,2,3,3,3,4,5})
115+
define QuantitySingleMode: Mode({1.0 'g', 1.0 'g', 2.0 'g'})
116+
define QuantityBiModal: Mode({1.0 'g', 1.0 'g', 2.0 'g', 2.0 'g'})
115117
define NumbersAndQuantities: Mode({1 ,2 'ml',3 'ml',4 'ml',5 'ml',0 'ml'})
116118
define IncompatibleUnitsNull: Mode({1 'mg/d', 0.002 '/d'})
117119

0 commit comments

Comments
 (0)