Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marchenko Max V8 #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['@babel/preset-env'],
};
36 changes: 36 additions & 0 deletions libs/variant8.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const {arraySize, validate, _validate, validateIndex, resize, _resize, DimensionError} = require("./variant8")
describe('arraySize', function() {
it('should return the correct size of a multi-dimensional array', function() {
var arr = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
expect(arraySize(arr)).toEqual([2, 2, 2]);
});

it('should return an empty array if the input is not an array', function() {
var arr = 123; // not an array
expect(arraySize(arr)).toEqual([]);
});

it('should return an empty array if the input is an empty array', function() {
var arr = [];
expect(arraySize(arr)).toEqual([0]);
});
});


describe('validate', function() {
it('should throw a DimensionError if the array dimensions do not match the provided size', function() {
var arr = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
var size = [2, 3, 2]; // dimensions do not match
expect(function() {
validate(arr, size);
}).toThrow(DimensionError);
});

it('should not throw any errors if the array dimensions match the provided size', function() {
var arr = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
var size = [2, 2, 2]; // dimensions match
expect(function() {
validate(arr, size);
}).not.toThrow();
});
});
Loading