Skip to content

Commit

Permalink
Update dependencies and format
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasrw committed Dec 8, 2024
1 parent bf69bfb commit 3b4a3d1
Show file tree
Hide file tree
Showing 4 changed files with 256 additions and 263 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@
"blueimp-md5": "2.19.0",
"cmdmix": "2.2.2",
"dom-storage": "2.1.0",
"esbuild": "0.23.1",
"esbuild": "0.24.0",
"git-branch-is": "4.0.0",
"husky": "8.0.3",
"jison": "^0.4.18",
"mocha": "10.7.3",
"mocha.parallel": "0.15.6",
"open": "10.1.0",
"prettier": "3.3.3",
"prettier": "3.4.2",
"react-native-fetch-blob": "^0.10.8",
"react-native-fs": "^2.20.0",
"rexreplace": "7.1.11",
"rexreplace": "7.1.12",
"strftime": "0.10.3",
"tabletop": "1.6.3",
"uglify-js": "3.19.3"
Expand Down
101 changes: 50 additions & 51 deletions test/test1977.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ if (typeof exports === 'object') {
}

describe('Test 1977 - BigInt support', function () {

it('A) Should sum, find max, min, average of BigInt values, and calculate TOTAL', function () {
var data = [
{a: 9045645645644442n}, {a: 9147483647334432n}, {a: 20n}, {a : 45875651254783254n}
];
var data = [{a: 9045645645644442n}, {a: 9147483647334432n}, {a: 20n}, {a: 45875651254783254n}];

var res = alasql(
`SELECT SUM(a) AS sum_a,
Expand All @@ -20,19 +17,19 @@ describe('Test 1977 - BigInt support', function () {
[data]
);

assert.deepEqual(res, [{
sum_a: 64068780547762148n,
max_a: 45875651254783254n,
min_a: 20n,
avg_a: 16017195136940537n,
total_a: 64068780547762148n,
}]);
assert.deepEqual(res, [
{
sum_a: 64068780547762148n,
max_a: 45875651254783254n,
min_a: 20n,
avg_a: 16017195136940537n,
total_a: 64068780547762148n,
},
]);
});

it('B) Aggregate functions with mixed Number and BigInt types', function () {
var data = [
{a: 1}, {a: 2}, {a: 3}, {a: 4}, {a: 9147483647334432n}
];
var data = [{a: 1}, {a: 2}, {a: 3}, {a: 4}, {a: 9147483647334432n}];

var res = alasql(
`SELECT SUM(a) AS sum_a,
Expand All @@ -44,20 +41,19 @@ describe('Test 1977 - BigInt support', function () {
[data]
);

assert.deepEqual(res, [{
sum_a: 9147483647334442n,
max_a: 9147483647334432n,
min_a: 1n,
avg_a: 1829496729466888n,
total_a: 9147483647334442n,
}]);
assert.deepEqual(res, [
{
sum_a: 9147483647334442n,
max_a: 9147483647334432n,
min_a: 1n,
avg_a: 1829496729466888n,
total_a: 9147483647334442n,
},
]);
});

it('C) Aggregate functions with negative BigInt values', function () {
var data = [
{a: -9045645645644442n},
{a: -9147483647334432n}
];
var data = [{a: -9045645645644442n}, {a: -9147483647334432n}];

var res = alasql(
`SELECT SUM(a) AS sum_a,
Expand All @@ -69,19 +65,21 @@ describe('Test 1977 - BigInt support', function () {
[data]
);

assert.deepEqual(res, [{
sum_a: -18193129292978874n,
max_a: -9045645645644442n,
min_a: -9147483647334432n,
avg_a: -9096564646489437n,
total_a: -18193129292978874n,
}]);
assert.deepEqual(res, [
{
sum_a: -18193129292978874n,
max_a: -9045645645644442n,
min_a: -9147483647334432n,
avg_a: -9096564646489437n,
total_a: -18193129292978874n,
},
]);
});

it('D) Aggregate functions with large BigInt values', function () {
var data = [
{a: BigInt('123456789012345678901234567890')},
{a: BigInt('987654321098765432109876543210')}
{a: BigInt('987654321098765432109876543210')},
];

var res = alasql(
Expand All @@ -94,20 +92,19 @@ describe('Test 1977 - BigInt support', function () {
[data]
);

assert.deepEqual(res, [{
sum_a: BigInt('1111111110111111111011111111100'),
max_a: BigInt('987654321098765432109876543210'),
min_a: BigInt('123456789012345678901234567890'),
avg_a: BigInt('555555555055555555505555555550'),
total_a: BigInt('1111111110111111111011111111100'),
}]);
assert.deepEqual(res, [
{
sum_a: BigInt('1111111110111111111011111111100'),
max_a: BigInt('987654321098765432109876543210'),
min_a: BigInt('123456789012345678901234567890'),
avg_a: BigInt('555555555055555555505555555550'),
total_a: BigInt('1111111110111111111011111111100'),
},
]);
});

it('E) Aggregate functions with zero sum (positive and negative BigInt)', function () {
var data = [
{a: 12345678901234567890n},
{a: -12345678901234567890n}
];
var data = [{a: 12345678901234567890n}, {a: -12345678901234567890n}];

var res = alasql(
`SELECT SUM(a) AS sum_a,
Expand All @@ -119,12 +116,14 @@ describe('Test 1977 - BigInt support', function () {
[data]
);

assert.deepEqual(res, [{
sum_a: 0n,
max_a: 12345678901234567890n,
min_a: -12345678901234567890n,
avg_a: 0n,
total_a: 0n,
}]);
assert.deepEqual(res, [
{
sum_a: 0n,
max_a: 12345678901234567890n,
min_a: -12345678901234567890n,
avg_a: 0n,
total_a: 0n,
},
]);
});
});
102 changes: 48 additions & 54 deletions test/test2000.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
const alasql = require('../dist/alasql.js');
const alasql = require('../dist/alasql.js');

if (typeof exports === 'object') {
var assert = require('assert');
}

describe('Test 2000', function () {

before(function () {
before(function () {
alasql('create database test');
alasql('use test');
});
Expand All @@ -15,54 +14,52 @@ describe('Test 2000', function () {
alasql('drop database test');
});

it('A) Select from memory', () => {
alasql('CREATE TABLE osoby (id INT, meno STRING)');
alasql('INSERT INTO osoby VALUES (1, "John"), (2, "Jane"), (3, "Jake")');
const result = alasql('SELECT * FROM osoby');

assert.deepEqual(result, [
{ id: 1, meno: "John" },
{ id: 2, meno: "Jane" },
{ id: 3, meno: "Jake" }
]);
});

it('B) Max from memory', () => {
alasql('CREATE TABLE produkty (id INT, cena INT)');
alasql('INSERT INTO produkty VALUES (1, 100), (2, 150), (3, 200)');
const result = alasql('SELECT MAX(cena) AS maxCena FROM produkty');

assert.strictEqual(result[0].maxCena, 200);
});

it('C) Min from memory', () => {
alasql('CREATE TABLE produkty3 (id INT, cena INT)');
alasql('INSERT INTO produkty3 VALUES (1, 100), (2, 150), (3, 200)');
const result = alasql('SELECT MIN(cena) AS minCena FROM produkty3');

assert.strictEqual(result[0].minCena, 100);
});

it('Total from memory', () => {
alasql('CREATE TABLE produkty4 (id INT, cena INT)');
alasql('INSERT INTO produkty4 VALUES (1, 100), (2, 150), (3, 200)');

const result = alasql('SELECT TOTAL(cena) AS totalCena FROM produkty4');

assert.strictEqual(result[0].totalCena, 450);
});

it('E) Avg from memory', () => {
alasql('CREATE TABLE produkty2 (id INT, cena INT)');
alasql('INSERT INTO produkty2 VALUES (1, 100), (2, 150), (3, 200)');
const result = alasql('SELECT AVG(cena) AS avgCena FROM produkty2');

assert.strictEqual(result[0].avgCena, 150);
});



it('F) SUM with Round function from memory', function () {
it('A) Select from memory', () => {
alasql('CREATE TABLE osoby (id INT, meno STRING)');
alasql('INSERT INTO osoby VALUES (1, "John"), (2, "Jane"), (3, "Jake")');
const result = alasql('SELECT * FROM osoby');

assert.deepEqual(result, [
{id: 1, meno: 'John'},
{id: 2, meno: 'Jane'},
{id: 3, meno: 'Jake'},
]);
});

it('B) Max from memory', () => {
alasql('CREATE TABLE produkty (id INT, cena INT)');
alasql('INSERT INTO produkty VALUES (1, 100), (2, 150), (3, 200)');
const result = alasql('SELECT MAX(cena) AS maxCena FROM produkty');

assert.strictEqual(result[0].maxCena, 200);
});

it('C) Min from memory', () => {
alasql('CREATE TABLE produkty3 (id INT, cena INT)');
alasql('INSERT INTO produkty3 VALUES (1, 100), (2, 150), (3, 200)');
const result = alasql('SELECT MIN(cena) AS minCena FROM produkty3');

assert.strictEqual(result[0].minCena, 100);
});

it('Total from memory', () => {
alasql('CREATE TABLE produkty4 (id INT, cena INT)');
alasql('INSERT INTO produkty4 VALUES (1, 100), (2, 150), (3, 200)');

const result = alasql('SELECT TOTAL(cena) AS totalCena FROM produkty4');

assert.strictEqual(result[0].totalCena, 450);
});

it('E) Avg from memory', () => {
alasql('CREATE TABLE produkty2 (id INT, cena INT)');
alasql('INSERT INTO produkty2 VALUES (1, 100), (2, 150), (3, 200)');
const result = alasql('SELECT AVG(cena) AS avgCena FROM produkty2');

assert.strictEqual(result[0].avgCena, 150);
});

it('F) SUM with Round function from memory', function () {
var data = [
{
a: null,
Expand Down Expand Up @@ -105,8 +102,6 @@ describe('Test 2000', function () {
f: 13,
},
]);


});

it('G) MAX/MIN/SUM with Round or Ceil function from memory', function () {
Expand Down Expand Up @@ -160,4 +155,3 @@ describe('Test 2000', function () {
]);
});
});

Loading

0 comments on commit 3b4a3d1

Please sign in to comment.