diff --git a/README.md b/README.md index 0ea13a80a..ed6a8a760 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,4 @@ You might also be interested in our [users](https://groups.google.com/forum/#!fo Please [contact us](https://opencor.ws/libopencor/contactUs.html) if you have any questions about libOpenCOR. [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/opencor/libopencor) +![Alt](https://repobeats.axiom.co/api/embed/e57859796c7c35c163c88238f9bfd3f2aad9649f.svg "Repobeats analytics image") diff --git a/VERSION.txt b/VERSION.txt index 3e63e3598..7c9c4fdb0 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -0.20260210.0 +0.20260211.0 diff --git a/newversion b/newversion index 9c196cc97..716c9dc42 100755 --- a/newversion +++ b/newversion @@ -1,38 +1,35 @@ #!/bin/sh -# Major version. +# Current version from `VERSION.txt`. -major_version=0 +version_file=$(cd "$(dirname "$0")" && pwd)/VERSION.txt -# Minor version. +old_version=$(cat "$version_file") + +old_major_version=$(echo $old_version | cut -d. -f1) +old_minor_version=$(echo $old_version | cut -d. -f2) +old_patch_version=$(echo $old_version | cut -d. -f3) + +# Determine the new version based on the current version and the current date. now=$(date +%Y%m%d) -minor_version=$now - -# Patch version. - -patch_version=0 - -if latest_tag_commit=$(git rev-list --tags --max-count=1 2> /dev/null); then - if git_describe=$(git describe --tags "$latest_tag_commit" 2> /dev/null); then - if echo "$git_describe" | grep -Eo '^v?[0-9]+\.[0-9]+\.[0-9]+' > /dev/null; then - minor=$(echo "$git_describe" | cut -d. -f2) - patch=$(echo "$git_describe" | cut -d. -f3) - patch_version=$patch - - if [ "$minor" = "$minor_version" ]; then - patch_version=$((patch_version + 1)) - else - patch_version=0 - fi - fi - fi -fi -# Full version. +new_major_version=$old_major_version +new_minor_version=$now -version="$major_version.$minor_version.$patch_version" +if [ $old_minor_version -lt $now ]; then + new_patch_version=0 +else + new_patch_version=$(($old_patch_version + 1)) +fi + +new_version="$new_major_version.$new_minor_version.$new_patch_version" # Update our version file. -echo $version > $(cd $(dirname $0); pwd)/VERSION.txt +echo "$new_version" > "$version_file" + +# Display the old and new versions. + +printf '\033[1mOld version:\033[0m %s\n' "$old_version" +printf '\033[1mNew version:\033[0m %s\n' "$new_version" diff --git a/newversion.bat b/newversion.bat index 6e43f136b..15f1777e3 100755 --- a/newversion.bat +++ b/newversion.bat @@ -2,49 +2,38 @@ SETLOCAL ENABLEDELAYEDEXPANSION -REM Major version. +REM Current version from `VERSION.txt`. -SET MajorVersion=0 +SET VersionFile=%~dp0VERSION.txt -REM Minor version. +FOR /F "usebackq delims=" %%I IN ("%VersionFile%") DO SET OldVersion=%%I -FOR /F "tokens=2 delims==" %%I IN ('wmic os get localdatetime /value') DO SET Now=%%I -SET MinorVersion=!Now:~0,8! -ECHO "MinorVersion: !MinorVersion!" +FOR /F "tokens=1-3 delims=." %%A IN ("!OldVersion!") DO ( + SET OldMajorVersion=%%A + SET OldMinorVersion=%%B + SET OldPatchVersion=%%C +) -REM Patch version. +REM Determine the new version based on the current version and the current date. -SET PatchVersion=0 +FOR /F "tokens=2 delims==" %%I IN ('wmic os get localdatetime /value') DO SET Now=%%I -FOR /F %%I IN ('git rev-list --tags --max-count=1 2^> NUL') DO ( - SET LatestTagCommit=%%I -) -ECHO "LatestTagCommit: !LatestTagCommit!" - -IF DEFINED LatestTagCommit ( - FOR /F %%I IN ('git describe --tags !LatestTagCommit! 2^> NUL') DO ( - SET GitDescribe=%%I - ) - ECHO "GitDescribe: !GitDescribe!" - - FOR /F "tokens=2,3 delims=." %%A IN ("!GitDescribe!") DO ( - SET MinorVersion=%%A - ECHO "MinorVersion: !MinorVersion!" - SET PatchVersion=%%B - ECHO "PatchVersion: !PatchVersion!" - - IF "!MinorVersion!"=="!MinorVersion!" ( - SET /A PatchVersion+=1 - ) ELSE ( - SET PatchVersion=0 - ) - ) -) +SET NewMajorVersion=!OldMajorVersion! +SET NewMinorVersion=!Now:~0,8! -REM Full version. +IF !OldMinorVersion! LSS !NewMinorVersion! ( + SET NewPatchVersion=0 +) ELSE ( + SET /A NewPatchVersion=!OldPatchVersion! + 1 +) -SET Version=!MajorVersion!.!MinorVersion!.!PatchVersion! +SET NewVersion=!NewMajorVersion!.!NewMinorVersion!.!NewPatchVersion! REM Update our version file. -ECHO !Version! > "%~dp0VERSION.txt" +ECHO !NewVersion! > "%VersionFile%" + +REM Display the old and new versions. + +ECHO Old version: !OldVersion! +ECHO New version: !NewVersion! diff --git a/src/bindings/javascript/file.cpp b/src/bindings/javascript/file.cpp index ead40d950..3722c7605 100644 --- a/src/bindings/javascript/file.cpp +++ b/src/bindings/javascript/file.cpp @@ -41,10 +41,14 @@ void fileApi() return res; })) - .function("setContents", emscripten::optional_override([](const libOpenCOR::FilePtr &pThis, uintptr_t pContents, size_t pSize) { - auto contents {reinterpret_cast(pContents)}; + .function("setContents", emscripten::optional_override([](const libOpenCOR::FilePtr &pThis, emscripten::val pContents) { + if (pContents.isNull() || pContents.isUndefined()) { + pThis->setContents(libOpenCOR::UnsignedChars {}); - pThis->setContents(libOpenCOR::UnsignedChars(contents, contents + pSize)); + return; + } + + pThis->setContents(emscripten::vecFromJSArray(pContents)); })) .property("hasChildFiles", &libOpenCOR::File::hasChildFiles) .property("childFileCount", &libOpenCOR::File::childFileCount) diff --git a/tests/bindings/javascript/file.basic.test.js b/tests/bindings/javascript/file.basic.test.js index 90ad4813a..ab2d33f52 100644 --- a/tests/bindings/javascript/file.basic.test.js +++ b/tests/bindings/javascript/file.basic.test.js @@ -29,20 +29,10 @@ const expectedUnknownFileIssues = [ ]; test.describe('File basic tests', () => { - let unknownContentsPtr; - - test.before(() => { - unknownContentsPtr = utils.allocateMemory(loc, utils.UNKNOWN_CONTENTS); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, unknownContentsPtr); - }); - test('Local file', () => { const file = new loc.File(utils.LOCAL_FILE); @@ -53,7 +43,7 @@ test.describe('File basic tests', () => { assert.deepStrictEqual(file.contents(), utils.NO_CONTENTS); assertIssues(loc, file, expectedNoIssues); - file.setContents(unknownContentsPtr, utils.UNKNOWN_CONTENTS.length); + file.setContents(utils.UNKNOWN_CONTENTS); assert.strictEqual(file.type.value, loc.File.Type.UNKNOWN_FILE.value); assert.deepStrictEqual(file.contents(), utils.UNKNOWN_CONTENTS); @@ -70,7 +60,7 @@ test.describe('File basic tests', () => { assert.deepStrictEqual(file.contents(), utils.NO_CONTENTS); assertIssues(loc, file, expectedNoIssues); - file.setContents(unknownContentsPtr, utils.UNKNOWN_CONTENTS.length); + file.setContents(utils.UNKNOWN_CONTENTS); assert.strictEqual(file.type.value, loc.File.Type.UNKNOWN_FILE.value); assert.deepStrictEqual(file.contents(), utils.UNKNOWN_CONTENTS); @@ -87,7 +77,7 @@ test.describe('File basic tests', () => { assert.deepStrictEqual(file.contents(), utils.NO_CONTENTS); assertIssues(loc, file, expectedNoIssues); - file.setContents(unknownContentsPtr, utils.UNKNOWN_CONTENTS.length); + file.setContents(utils.UNKNOWN_CONTENTS); assert.strictEqual(file.type.value, loc.File.Type.UNKNOWN_FILE.value); assert.deepStrictEqual(file.contents(), utils.UNKNOWN_CONTENTS); diff --git a/tests/bindings/javascript/file.child.test.js b/tests/bindings/javascript/file.child.test.js index 45e67ff8f..bd4beaf21 100644 --- a/tests/bindings/javascript/file.child.test.js +++ b/tests/bindings/javascript/file.child.test.js @@ -23,33 +23,14 @@ import * as utils from './utils.js'; const loc = await libOpenCOR(); test.describe('File type tests', () => { - let dataset135OmexContentsPtr; - let dataset135JsonContentsPtr; - let dataset157OmexContentsPtr; - let dataset157JsonContentsPtr; - - test.before(() => { - dataset135OmexContentsPtr = utils.allocateMemory(loc, utils.DATASET_135_OMEX_CONTENTS); - dataset135JsonContentsPtr = utils.allocateMemory(loc, utils.DATASET_135_JSON_CONTENTS); - dataset157OmexContentsPtr = utils.allocateMemory(loc, utils.DATASET_157_OMEX_CONTENTS); - dataset157JsonContentsPtr = utils.allocateMemory(loc, utils.DATASET_157_JSON_CONTENTS); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, dataset135OmexContentsPtr); - utils.freeMemory(loc, dataset135JsonContentsPtr); - utils.freeMemory(loc, dataset157OmexContentsPtr); - utils.freeMemory(loc, dataset157JsonContentsPtr); - }); - - function doTestDataset(omexContentsPtr, omexContents, jsonContents, specificChildFileNames) { + function doTestDataset(omexContents, jsonContents, specificChildFileNames) { const file = new loc.File(utils.COMBINE_ARCHIVE); - file.setContents(omexContentsPtr, omexContents.length); + file.setContents(omexContents); assert.strictEqual(file.hasChildFiles, true); assert.strictEqual(file.childFileCount, specificChildFileNames.length + 1); @@ -85,13 +66,13 @@ test.describe('File type tests', () => { }); test('Dataset 135', () => { - doTestDataset(dataset135OmexContentsPtr, utils.DATASET_135_OMEX_CONTENTS, utils.DATASET_135_JSON_CONTENTS, [ + doTestDataset(utils.DATASET_135_OMEX_CONTENTS, utils.DATASET_135_JSON_CONTENTS, [ 'HumanSAN_Fabbri_Fantini_Wilders_Severi_2017.cellml' ]); }); test('Dataset 157', () => { - doTestDataset(dataset157OmexContentsPtr, utils.DATASET_157_OMEX_CONTENTS, utils.DATASET_157_JSON_CONTENTS, [ + doTestDataset(utils.DATASET_157_OMEX_CONTENTS, utils.DATASET_157_JSON_CONTENTS, [ 'fabbri_et_al_based_composite_SAN_model.cellml', 'fabbri_et_al_based_composite_SAN_model.sedml' ]); diff --git a/tests/bindings/javascript/file.coverage.test.js b/tests/bindings/javascript/file.coverage.test.js index 6360f9491..68554bb65 100644 --- a/tests/bindings/javascript/file.coverage.test.js +++ b/tests/bindings/javascript/file.coverage.test.js @@ -23,27 +23,14 @@ import * as utils from './utils.js'; const loc = await libOpenCOR(); test.describe('File coverage tests', () => { - let nullCharacterContentsPtr; - let combineArchiveContentsPtr; - - test.before(() => { - nullCharacterContentsPtr = utils.allocateMemory(loc, utils.NULL_CHARACTER_CONTENTS); - combineArchiveContentsPtr = utils.allocateMemory(loc, utils.COMBINE_ARCHIVE_CONTENTS); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, nullCharacterContentsPtr); - utils.freeMemory(loc, combineArchiveContentsPtr); - }); - test('Empty file', () => { const file = new loc.File(utils.UNKNOWN_FILE); - file.setContents(null, 0); + file.setContents(null); assert.strictEqual(file.type.value, loc.File.Type.UNKNOWN_FILE.value); }); @@ -51,7 +38,7 @@ test.describe('File coverage tests', () => { test('File with null character', () => { const file = new loc.File(utils.UNKNOWN_FILE); - file.setContents(nullCharacterContentsPtr, utils.NULL_CHARACTER_CONTENTS.length); + file.setContents(utils.NULL_CHARACTER_CONTENTS); assert.strictEqual(file.type.value, loc.File.Type.UNKNOWN_FILE.value); }); @@ -59,7 +46,7 @@ test.describe('File coverage tests', () => { test('SED-ML file with no parent', () => { const file = new loc.File(utils.SEDML_FILE); - file.setContents(utils.SEDML_CONTENTS, utils.SEDML_CONTENTS.length); + file.setContents(utils.SEDML_CONTENTS); }); test('Same local file', () => { @@ -80,7 +67,7 @@ test.describe('File coverage tests', () => { const file = new loc.File(utils.COMBINE_ARCHIVE); const fileManager = loc.FileManager.instance(); - file.setContents(combineArchiveContentsPtr, utils.COMBINE_ARCHIVE_CONTENTS.length); + file.setContents(utils.COMBINE_ARCHIVE_CONTENTS); assert.strictEqual(fileManager.fileCount, 3); diff --git a/tests/bindings/javascript/file.type.test.js b/tests/bindings/javascript/file.type.test.js index e031d0598..001ff690e 100644 --- a/tests/bindings/javascript/file.type.test.js +++ b/tests/bindings/javascript/file.type.test.js @@ -24,33 +24,14 @@ import { assertIssues } from './utils.js'; const loc = await libOpenCOR(); test.describe('File type tests', () => { - let unknownContentsPtr; - let cellmlContentsPtr; - let sedmlContentsPtr; - let combineArchiveContentsPtr; - - test.before(() => { - unknownContentsPtr = utils.allocateMemory(loc, utils.UNKNOWN_CONTENTS); - cellmlContentsPtr = utils.allocateMemory(loc, utils.CELLML_CONTENTS); - sedmlContentsPtr = utils.allocateMemory(loc, utils.SEDML_CONTENTS); - combineArchiveContentsPtr = utils.allocateMemory(loc, utils.COMBINE_ARCHIVE_CONTENTS); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, unknownContentsPtr); - utils.freeMemory(loc, cellmlContentsPtr); - utils.freeMemory(loc, sedmlContentsPtr); - utils.freeMemory(loc, combineArchiveContentsPtr); - }); - test('Unknown file', () => { const file = new loc.File(utils.UNKNOWN_FILE); - file.setContents(unknownContentsPtr, utils.UNKNOWN_CONTENTS.length); + file.setContents(utils.UNKNOWN_CONTENTS); assert.strictEqual(file.type.value, loc.File.Type.UNKNOWN_FILE.value); assertIssues(loc, file, [ @@ -61,7 +42,7 @@ test.describe('File type tests', () => { test('CellML file', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); assert.strictEqual(file.type.value, loc.File.Type.CELLML_FILE.value); }); @@ -69,7 +50,7 @@ test.describe('File type tests', () => { test('SED-ML file', () => { const file = new loc.File(utils.SEDML_FILE); - file.setContents(sedmlContentsPtr, utils.SEDML_CONTENTS.length); + file.setContents(utils.SEDML_CONTENTS); assert.strictEqual(file.type.value, loc.File.Type.SEDML_FILE.value); }); @@ -77,7 +58,7 @@ test.describe('File type tests', () => { test('COMBINE archive', () => { const file = new loc.File(utils.COMBINE_ARCHIVE); - file.setContents(combineArchiveContentsPtr, utils.COMBINE_ARCHIVE_CONTENTS.length); + file.setContents(utils.COMBINE_ARCHIVE_CONTENTS); assert.strictEqual(file.type.value, loc.File.Type.COMBINE_ARCHIVE.value); }); diff --git a/tests/bindings/javascript/logger.coverage.test.js b/tests/bindings/javascript/logger.coverage.test.js index 82da4c092..7534a265f 100644 --- a/tests/bindings/javascript/logger.coverage.test.js +++ b/tests/bindings/javascript/logger.coverage.test.js @@ -23,30 +23,14 @@ import * as utils from './utils.js'; const loc = await libOpenCOR(); test.describe('Issue coverage tests', () => { - let cellmlContentsPtr; - let errorCellmlContentsPtr; - let sedmlContentsPtr; - - test.before(() => { - cellmlContentsPtr = utils.allocateMemory(loc, utils.CELLML_CONTENTS); - errorCellmlContentsPtr = utils.allocateMemory(loc, utils.ERROR_CELLML_CONTENTS); - sedmlContentsPtr = utils.allocateMemory(loc, utils.SEDML_CONTENTS); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, cellmlContentsPtr); - utils.freeMemory(loc, errorCellmlContentsPtr); - utils.freeMemory(loc, sedmlContentsPtr); - }); - test('hasIssues', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); assert.strictEqual(file.hasIssues, false); }); @@ -54,7 +38,7 @@ test.describe('Issue coverage tests', () => { test('issueCount', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); assert.strictEqual(file.issueCount, 0); }); @@ -62,7 +46,7 @@ test.describe('Issue coverage tests', () => { test('issues', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); assert.strictEqual(file.issues.size(), 0); }); @@ -70,7 +54,7 @@ test.describe('Issue coverage tests', () => { test('issue()', () => { const file = new loc.File(utils.ERROR_CELLML_FILE); - file.setContents(errorCellmlContentsPtr, utils.ERROR_CELLML_CONTENTS.length); + file.setContents(utils.ERROR_CELLML_CONTENTS); assert.notStrictEqual(file.issue(0), null); assert.strictEqual(file.issue(file.issueCount), null); @@ -79,7 +63,7 @@ test.describe('Issue coverage tests', () => { test('hasErrors', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); assert.strictEqual(file.hasErrors, false); }); @@ -87,7 +71,7 @@ test.describe('Issue coverage tests', () => { test('errorCount', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); assert.strictEqual(file.errorCount, 0); }); @@ -95,7 +79,7 @@ test.describe('Issue coverage tests', () => { test('errors', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); assert.strictEqual(file.errors.size(), 0); }); @@ -103,7 +87,7 @@ test.describe('Issue coverage tests', () => { test('error()', () => { const file = new loc.File(utils.ERROR_CELLML_FILE); - file.setContents(errorCellmlContentsPtr, utils.ERROR_CELLML_CONTENTS.length); + file.setContents(utils.ERROR_CELLML_CONTENTS); assert.notStrictEqual(file.error(0), null); assert.strictEqual(file.error(file.errorCount), null); @@ -112,7 +96,7 @@ test.describe('Issue coverage tests', () => { test('hasWarnings', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); assert.strictEqual(file.hasWarnings, false); }); @@ -120,7 +104,7 @@ test.describe('Issue coverage tests', () => { test('warningCount', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); assert.strictEqual(file.warningCount, 0); }); @@ -128,7 +112,7 @@ test.describe('Issue coverage tests', () => { test('warnings', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); assert.strictEqual(file.warnings.size(), 0); }); @@ -136,7 +120,7 @@ test.describe('Issue coverage tests', () => { test('warning()', () => { const file = new loc.File(utils.SEDML_FILE); - file.setContents(sedmlContentsPtr, utils.SEDML_CONTENTS.length); + file.setContents(utils.SEDML_CONTENTS); const document = new loc.SedDocument(file); diff --git a/tests/bindings/javascript/res/index.html b/tests/bindings/javascript/res/index.html index f00a80b24..f952de655 100644 --- a/tests/bindings/javascript/res/index.html +++ b/tests/bindings/javascript/res/index.html @@ -62,7 +62,7 @@
-

is .

+

is .

diff --git a/tests/bindings/javascript/res/res/libopencor.js b/tests/bindings/javascript/res/res/libopencor.js index 6d5be24b7..2b9859006 100644 --- a/tests/bindings/javascript/res/res/libopencor.js +++ b/tests/bindings/javascript/res/res/libopencor.js @@ -199,23 +199,13 @@ $(() => { const inputFile = input.files[0]; const fileReader = new FileReader(); - input.value = ''; // Allow the user to select the same file again. - - fileReader.readAsArrayBuffer(inputFile); - - fileReader.onload = async () => { + fileReader.onload = () => { try { - // Retrieve the contents of the file. - - const fileArrayBuffer = await inputFile.arrayBuffer(); - const memPtr = loc._malloc(inputFile.size); - const mem = new Uint8Array(loc.HEAPU8.buffer, memPtr, inputFile.size); - - mem.set(new Uint8Array(fileArrayBuffer)); + // Retrieve the contents of the file and pass a Uint8Array to the binding. file = new loc.File(inputFile.name); - file.setContents(memPtr, inputFile.size); + file.setContents(new Uint8Array(fileReader.result)); // Determine the type of the file. @@ -307,6 +297,14 @@ $(() => { fileReader.onerror = () => { showIssues([fileReader.error.message]); }; + + // Reset the input so that the user can select the same file again if they want to. + + input.value = ''; + + // Read the file as an array buffer. + + fileReader.readAsArrayBuffer(inputFile); } else { updateFileUi(false, false, false, false); } diff --git a/tests/bindings/javascript/sed.basic.test.js b/tests/bindings/javascript/sed.basic.test.js index 623524a73..a9dbb4337 100644 --- a/tests/bindings/javascript/sed.basic.test.js +++ b/tests/bindings/javascript/sed.basic.test.js @@ -24,65 +24,10 @@ import { assertIssues } from './utils.js'; const loc = await libOpenCOR(); test.describe('Sed basic tests', () => { - let unknownContentsPtr; - let cellmlContentsPtr; - let sedmlContentsPtr; - let sedmlWithAbsoluteCellmlFileContentsPtr; - let sedmlWithRemoteCellmlFileContentsPtr; - let combineArchiveContentsPtr; - let combineArchiveWithNoManifestFileContentsPtr; - let combineArchiveWithNoMasterFileContentsPtr; - let combineArchiveWithUnknownDirectCellmlFileContentsPtr; - let combineArchiveWithUnknownIndirectCellmlFileContentsPtr; - let combineArchiveWithUnknownSedmlFileContentsPtr; - - test.before(() => { - unknownContentsPtr = utils.allocateMemory(loc, utils.UNKNOWN_CONTENTS); - cellmlContentsPtr = utils.allocateMemory(loc, utils.CELLML_CONTENTS); - sedmlContentsPtr = utils.allocateMemory(loc, utils.SEDML_CONTENTS); - sedmlWithAbsoluteCellmlFileContentsPtr = utils.allocateMemory(loc, utils.SEDML_WITH_ABSOLUTE_CELLML_FILE_CONTENTS); - sedmlWithRemoteCellmlFileContentsPtr = utils.allocateMemory(loc, utils.SEDML_WITH_REMOTE_CELLML_FILE_CONTENTS); - combineArchiveContentsPtr = utils.allocateMemory(loc, utils.COMBINE_ARCHIVE_CONTENTS); - combineArchiveWithNoManifestFileContentsPtr = utils.allocateMemory( - loc, - utils.COMBINE_ARCHIVE_WITH_NO_MANIFEST_FILE_CONTENTS - ); - combineArchiveWithNoMasterFileContentsPtr = utils.allocateMemory( - loc, - utils.COMBINE_ARCHIVE_WITH_NO_MASTER_FILE_CONTENTS - ); - combineArchiveWithUnknownDirectCellmlFileContentsPtr = utils.allocateMemory( - loc, - utils.COMBINE_ARCHIVE_WITH_UNKNOWN_DIRECT_CELLML_FILE_CONTENTS - ); - combineArchiveWithUnknownIndirectCellmlFileContentsPtr = utils.allocateMemory( - loc, - utils.COMBINE_ARCHIVE_WITH_UNKNOWN_INDIRECT_CELLML_FILE_CONTENTS - ); - combineArchiveWithUnknownSedmlFileContentsPtr = utils.allocateMemory( - loc, - utils.COMBINE_ARCHIVE_WITH_UNKNOWN_SEDML_FILE_CONTENTS - ); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, unknownContentsPtr); - utils.freeMemory(loc, cellmlContentsPtr); - utils.freeMemory(loc, sedmlContentsPtr); - utils.freeMemory(loc, sedmlWithAbsoluteCellmlFileContentsPtr); - utils.freeMemory(loc, sedmlWithRemoteCellmlFileContentsPtr); - utils.freeMemory(loc, combineArchiveContentsPtr); - utils.freeMemory(loc, combineArchiveWithNoManifestFileContentsPtr); - utils.freeMemory(loc, combineArchiveWithNoMasterFileContentsPtr); - utils.freeMemory(loc, combineArchiveWithUnknownDirectCellmlFileContentsPtr); - utils.freeMemory(loc, combineArchiveWithUnknownIndirectCellmlFileContentsPtr); - utils.freeMemory(loc, combineArchiveWithUnknownSedmlFileContentsPtr); - }); - test('No file', () => { const document = new loc.SedDocument(); @@ -92,7 +37,7 @@ test.describe('Sed basic tests', () => { test('Unknown file', () => { const file = new loc.File(utils.UNKNOWN_FILE); - file.setContents(unknownContentsPtr, utils.UNKNOWN_CONTENTS.length); + file.setContents(utils.UNKNOWN_CONTENTS); const document = new loc.SedDocument(file); @@ -104,7 +49,7 @@ test.describe('Sed basic tests', () => { test('CellML file', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); @@ -114,7 +59,7 @@ test.describe('Sed basic tests', () => { test('SED-ML file', () => { const file = new loc.File(utils.SEDML_FILE); - file.setContents(sedmlContentsPtr, utils.SEDML_CONTENTS.length); + file.setContents(utils.SEDML_CONTENTS); let document = new loc.SedDocument(file); @@ -130,7 +75,7 @@ test.describe('Sed basic tests', () => { test('SED-ML file with absolute CellML file', () => { const file = new loc.File(utils.SEDML_FILE); - file.setContents(sedmlWithAbsoluteCellmlFileContentsPtr, utils.SEDML_WITH_ABSOLUTE_CELLML_FILE_CONTENTS.length); + file.setContents(utils.SEDML_WITH_ABSOLUTE_CELLML_FILE_CONTENTS); let document = new loc.SedDocument(file); @@ -146,7 +91,7 @@ test.describe('Sed basic tests', () => { test('SED-ML file with remote CellML file', () => { const file = new loc.File(utils.SEDML_FILE); - file.setContents(sedmlWithRemoteCellmlFileContentsPtr, utils.SEDML_WITH_REMOTE_CELLML_FILE_CONTENTS.length); + file.setContents(utils.SEDML_WITH_REMOTE_CELLML_FILE_CONTENTS); let document = new loc.SedDocument(file); @@ -162,7 +107,7 @@ test.describe('Sed basic tests', () => { test('COMBINE archive', () => { const file = new loc.File(utils.COMBINE_ARCHIVE); - file.setContents(combineArchiveContentsPtr, utils.COMBINE_ARCHIVE_CONTENTS.length); + file.setContents(utils.COMBINE_ARCHIVE_CONTENTS); const document = new loc.SedDocument(file); @@ -172,10 +117,7 @@ test.describe('Sed basic tests', () => { test('COMBINE archive with no manifest file', () => { const file = new loc.File(utils.COMBINE_ARCHIVE); - file.setContents( - combineArchiveWithNoManifestFileContentsPtr, - utils.COMBINE_ARCHIVE_WITH_NO_MANIFEST_FILE_CONTENTS.length - ); + file.setContents(utils.COMBINE_ARCHIVE_WITH_NO_MANIFEST_FILE_CONTENTS); const document = new loc.SedDocument(file); @@ -190,10 +132,7 @@ test.describe('Sed basic tests', () => { test('COMBINE archive with no master file', () => { const file = new loc.File(utils.COMBINE_ARCHIVE); - file.setContents( - combineArchiveWithNoMasterFileContentsPtr, - utils.COMBINE_ARCHIVE_WITH_NO_MASTER_FILE_CONTENTS.length - ); + file.setContents(utils.COMBINE_ARCHIVE_WITH_NO_MASTER_FILE_CONTENTS); const document = new loc.SedDocument(file); @@ -208,10 +147,7 @@ test.describe('Sed basic tests', () => { test('COMBINE archive with unknown direct CellML file', () => { const file = new loc.File(utils.COMBINE_ARCHIVE); - file.setContents( - combineArchiveWithUnknownDirectCellmlFileContentsPtr, - utils.COMBINE_ARCHIVE_WITH_UNKNOWN_DIRECT_CELLML_FILE_CONTENTS.length - ); + file.setContents(utils.COMBINE_ARCHIVE_WITH_UNKNOWN_DIRECT_CELLML_FILE_CONTENTS); const document = new loc.SedDocument(file); @@ -226,10 +162,7 @@ test.describe('Sed basic tests', () => { test('COMBINE archive with unknown indirect CellML file', () => { const file = new loc.File(utils.COMBINE_ARCHIVE); - file.setContents( - combineArchiveWithUnknownIndirectCellmlFileContentsPtr, - utils.COMBINE_ARCHIVE_WITH_UNKNOWN_INDIRECT_CELLML_FILE_CONTENTS.length - ); + file.setContents(utils.COMBINE_ARCHIVE_WITH_UNKNOWN_INDIRECT_CELLML_FILE_CONTENTS); const document = new loc.SedDocument(file); const instance = document.instantiate(); @@ -242,10 +175,7 @@ test.describe('Sed basic tests', () => { test('COMBINE archive with unknown SED-ML file', () => { const file = new loc.File(utils.COMBINE_ARCHIVE); - file.setContents( - combineArchiveWithUnknownSedmlFileContentsPtr, - utils.COMBINE_ARCHIVE_WITH_UNKNOWN_SEDML_FILE_CONTENTS.length - ); + file.setContents(utils.COMBINE_ARCHIVE_WITH_UNKNOWN_SEDML_FILE_CONTENTS); const document = new loc.SedDocument(file); diff --git a/tests/bindings/javascript/sed.coverage.test.js b/tests/bindings/javascript/sed.coverage.test.js index 8711b6395..ad4ba922a 100644 --- a/tests/bindings/javascript/sed.coverage.test.js +++ b/tests/bindings/javascript/sed.coverage.test.js @@ -24,35 +24,10 @@ import { assertIssues, assertValues } from './utils.js'; const loc = await libOpenCOR(); test.describe('Sed coverage tests', () => { - let sedChangesContentsPtr; - let invalidSedChangesContentsPtr; - let unsupportedSedChangesContentsPtr; - let solverOdeContentsPtr; - let solverNla1ContentsPtr; - let mathContentsPtr; - - test.before(() => { - sedChangesContentsPtr = utils.allocateMemory(loc, utils.SED_CHANGES_CONTENTS); - invalidSedChangesContentsPtr = utils.allocateMemory(loc, utils.INVALID_SED_CHANGES_CONTENTS); - unsupportedSedChangesContentsPtr = utils.allocateMemory(loc, utils.UNSUPPORTED_SED_CHANGES_CONTENTS); - solverOdeContentsPtr = utils.allocateMemory(loc, utils.SOLVER_ODE_CONTENTS); - solverNla1ContentsPtr = utils.allocateMemory(loc, utils.SOLVER_NLA1_CONTENTS); - mathContentsPtr = utils.allocateMemory(loc, utils.MATH_CONTENTS); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, sedChangesContentsPtr); - utils.freeMemory(loc, invalidSedChangesContentsPtr); - utils.freeMemory(loc, unsupportedSedChangesContentsPtr); - utils.freeMemory(loc, solverOdeContentsPtr); - utils.freeMemory(loc, solverNla1ContentsPtr); - utils.freeMemory(loc, mathContentsPtr); - }); - function sedTaskExpectedSerialisation(withProperties) { return ` @@ -140,13 +115,13 @@ test.describe('Sed coverage tests', () => { test('Changes', () => { const file = new loc.File(utils.COMBINE_ARCHIVE); - file.setContents(sedChangesContentsPtr, utils.SED_CHANGES_CONTENTS.length); + file.setContents(utils.SED_CHANGES_CONTENTS); let document = new loc.SedDocument(file); assert.strictEqual(document.hasIssues, false); - file.setContents(invalidSedChangesContentsPtr, utils.INVALID_SED_CHANGES_CONTENTS.length); + file.setContents(utils.INVALID_SED_CHANGES_CONTENTS); document = new loc.SedDocument(file); @@ -181,7 +156,7 @@ test.describe('Sed coverage tests', () => { ] ]); - file.setContents(unsupportedSedChangesContentsPtr, utils.UNSUPPORTED_SED_CHANGES_CONTENTS.length); + file.setContents(utils.UNSUPPORTED_SED_CHANGES_CONTENTS); document = new loc.SedDocument(file); @@ -385,7 +360,7 @@ test.describe('Sed coverage tests', () => { test('SedInstanceAndSedInstanceTaskDifferentialModel', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const solver = document.simulations.get(0).odeSolver; @@ -469,7 +444,7 @@ test.describe('Sed coverage tests', () => { test('SedInstanceAndSedInstanceTaskNonDifferentialModel', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverNla1ContentsPtr, utils.SOLVER_NLA1_CONTENTS.length); + file.setContents(utils.SOLVER_NLA1_CONTENTS); const document = new loc.SedDocument(file); @@ -513,7 +488,7 @@ test.describe('Sed coverage tests', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -561,7 +536,7 @@ test.describe('Sed coverage tests', () => { test('Math', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(mathContentsPtr, utils.MATH_CONTENTS.length); + file.setContents(utils.MATH_CONTENTS); const document = new loc.SedDocument(file); const instance = document.instantiate(); diff --git a/tests/bindings/javascript/sed.instance.test.js b/tests/bindings/javascript/sed.instance.test.js index 28288171d..2ff76b6a7 100644 --- a/tests/bindings/javascript/sed.instance.test.js +++ b/tests/bindings/javascript/sed.instance.test.js @@ -24,50 +24,10 @@ import { assertIssues } from './utils.js'; const loc = await libOpenCOR(); test.describe('Sed instance tests', () => { - let cellmlContentsPtr; - let errorCellmlContentsPtr; - let overconstrainedContentsPtr; - let underconstrainedContentsPtr; - let unsuitablyConstrainedContentsPtr; - let algebraicContentsPtr; - let nlaContentsPtr; - let daeContentsPtr; - let combineArchiveContentsPtr; - let combineArchiveWithCellmlFileAsMasterFileContentsPtr; - - test.before(() => { - cellmlContentsPtr = utils.allocateMemory(loc, utils.CELLML_CONTENTS); - errorCellmlContentsPtr = utils.allocateMemory(loc, utils.ERROR_CELLML_CONTENTS); - overconstrainedContentsPtr = utils.allocateMemory(loc, utils.OVERCONSTRAINED_CONTENTS); - underconstrainedContentsPtr = utils.allocateMemory(loc, utils.UNDERCONSTRAINED_CONTENTS); - unsuitablyConstrainedContentsPtr = utils.allocateMemory(loc, utils.UNSUITABLY_CONSTRAINED_CONTENTS); - algebraicContentsPtr = utils.allocateMemory(loc, utils.ALGEBRAIC_CONTENTS); - nlaContentsPtr = utils.allocateMemory(loc, utils.NLA_CONTENTS); - daeContentsPtr = utils.allocateMemory(loc, utils.DAE_CONTENTS); - combineArchiveContentsPtr = utils.allocateMemory(loc, utils.COMBINE_ARCHIVE_CONTENTS); - combineArchiveWithCellmlFileAsMasterFileContentsPtr = utils.allocateMemory( - loc, - utils.COMBINE_ARCHIVE_WITH_CELLML_FILE_AS_MASTER_FILE_CONTENTS - ); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, cellmlContentsPtr); - utils.freeMemory(loc, errorCellmlContentsPtr); - utils.freeMemory(loc, overconstrainedContentsPtr); - utils.freeMemory(loc, underconstrainedContentsPtr); - utils.freeMemory(loc, unsuitablyConstrainedContentsPtr); - utils.freeMemory(loc, algebraicContentsPtr); - utils.freeMemory(loc, nlaContentsPtr); - utils.freeMemory(loc, daeContentsPtr); - utils.freeMemory(loc, combineArchiveContentsPtr); - utils.freeMemory(loc, combineArchiveWithCellmlFileAsMasterFileContentsPtr); - }); - test('No file', () => { const document = new loc.SedDocument(); const instance = document.instantiate(); @@ -80,7 +40,7 @@ test.describe('Sed instance tests', () => { test('Invalid CellML file', () => { const file = new loc.File(utils.ERROR_CELLML_FILE); - file.setContents(errorCellmlContentsPtr, utils.ERROR_CELLML_CONTENTS.length); + file.setContents(utils.ERROR_CELLML_CONTENTS); const document = new loc.SedDocument(file); const instance = document.instantiate(); @@ -97,7 +57,7 @@ test.describe('Sed instance tests', () => { test('Overconstrained CellML file', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(overconstrainedContentsPtr, utils.OVERCONSTRAINED_CONTENTS.length); + file.setContents(utils.OVERCONSTRAINED_CONTENTS); const document = new loc.SedDocument(file); const instance = document.instantiate(); @@ -114,7 +74,7 @@ test.describe('Sed instance tests', () => { test('Underconstrained CellML file', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(underconstrainedContentsPtr, utils.UNDERCONSTRAINED_CONTENTS.length); + file.setContents(utils.UNDERCONSTRAINED_CONTENTS); const document = new loc.SedDocument(file); const instance = document.instantiate(); @@ -131,7 +91,7 @@ test.describe('Sed instance tests', () => { test('Unsuitably constrained CellML file', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(unsuitablyConstrainedContentsPtr, utils.UNSUITABLY_CONSTRAINED_CONTENTS.length); + file.setContents(utils.UNSUITABLY_CONSTRAINED_CONTENTS); const document = new loc.SedDocument(file); const instance = document.instantiate(); @@ -152,7 +112,7 @@ test.describe('Sed instance tests', () => { test('Algebraic model', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(algebraicContentsPtr, utils.ALGEBRAIC_CONTENTS.length); + file.setContents(utils.ALGEBRAIC_CONTENTS); const document = new loc.SedDocument(file); const instance = document.instantiate(); @@ -165,7 +125,7 @@ test.describe('Sed instance tests', () => { test('ODE model', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -195,7 +155,7 @@ test.describe('Sed instance tests', () => { test('ODE model with no ODE solver', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); @@ -214,7 +174,7 @@ test.describe('Sed instance tests', () => { test('NLA model', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(nlaContentsPtr, utils.NLA_CONTENTS.length); + file.setContents(utils.NLA_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -242,7 +202,7 @@ test.describe('Sed instance tests', () => { test('NLA model with no NLA solver', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(nlaContentsPtr, utils.NLA_CONTENTS.length); + file.setContents(utils.NLA_CONTENTS); const document = new loc.SedDocument(file); @@ -261,7 +221,7 @@ test.describe('Sed instance tests', () => { test('DAE model', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(daeContentsPtr, utils.DAE_CONTENTS.length); + file.setContents(utils.DAE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -300,7 +260,7 @@ test.describe('Sed instance tests', () => { test('DAE model with no ODE or NLA solver', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(daeContentsPtr, utils.DAE_CONTENTS.length); + file.setContents(utils.DAE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -325,7 +285,7 @@ test.describe('Sed instance tests', () => { test('COMBINE archive', () => { const file = new loc.File(utils.COMBINE_ARCHIVE); - file.setContents(combineArchiveContentsPtr, utils.COMBINE_ARCHIVE_CONTENTS.length); + file.setContents(utils.COMBINE_ARCHIVE_CONTENTS); const document = new loc.SedDocument(file); const instance = document.instantiate(); @@ -338,10 +298,7 @@ test.describe('Sed instance tests', () => { test('COMBINE archive with CellML file as master file', () => { const file = new loc.File(utils.COMBINE_ARCHIVE); - file.setContents( - combineArchiveWithCellmlFileAsMasterFileContentsPtr, - utils.COMBINE_ARCHIVE_WITH_CELLML_FILE_AS_MASTER_FILE_CONTENTS.length - ); + file.setContents(utils.COMBINE_ARCHIVE_WITH_CELLML_FILE_AS_MASTER_FILE_CONTENTS); const document = new loc.SedDocument(file); const instance = document.instantiate(); diff --git a/tests/bindings/javascript/sed.serialise.test.js b/tests/bindings/javascript/sed.serialise.test.js index 981bf238d..964f0235e 100644 --- a/tests/bindings/javascript/sed.serialise.test.js +++ b/tests/bindings/javascript/sed.serialise.test.js @@ -24,35 +24,10 @@ import { assertIssues } from './utils.js'; const loc = await libOpenCOR(); test.describe('Sed serialise tests', () => { - let cellmlContentsPtr; - let sedmlContentsPtr; - let algebraicContentsPtr; - let daeContentsPtr; - let nlaContentsPtr; - let sedmlWithSimulationsContentsPtr; - - test.before(() => { - cellmlContentsPtr = utils.allocateMemory(loc, utils.CELLML_CONTENTS); - sedmlContentsPtr = utils.allocateMemory(loc, utils.SEDML_CONTENTS); - algebraicContentsPtr = utils.allocateMemory(loc, utils.ALGEBRAIC_CONTENTS); - daeContentsPtr = utils.allocateMemory(loc, utils.DAE_CONTENTS); - nlaContentsPtr = utils.allocateMemory(loc, utils.NLA_CONTENTS); - sedmlWithSimulationsContentsPtr = utils.allocateMemory(loc, utils.SEDML_WITH_SIMULATIONS_CONTENTS); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, cellmlContentsPtr); - utils.freeMemory(loc, sedmlContentsPtr); - utils.freeMemory(loc, algebraicContentsPtr); - utils.freeMemory(loc, daeContentsPtr); - utils.freeMemory(loc, nlaContentsPtr); - utils.freeMemory(loc, sedmlWithSimulationsContentsPtr); - }); - function cvodeExpectedSerialisation(source, parameters = {}) { const integrationMethod = parameters['KISAO:0000475'] || 'BDF'; const iterationType = parameters['KISAO:0000476'] || 'Newton'; @@ -121,7 +96,7 @@ test.describe('Sed serialise tests', () => { test('Local CellML file with base path', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); @@ -131,7 +106,7 @@ test.describe('Sed serialise tests', () => { test('Local CellML file without base path', () => { const file = new loc.File(utils.LOCAL_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); @@ -141,7 +116,7 @@ test.describe('Sed serialise tests', () => { test('Relative local CellML file with base path', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); @@ -154,7 +129,7 @@ test.describe('Sed serialise tests', () => { test('Relative local CellML file without base path', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); @@ -164,7 +139,7 @@ test.describe('Sed serialise tests', () => { test('Remote CellML file with base path', () => { const file = new loc.File(utils.REMOTE_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); @@ -174,7 +149,7 @@ test.describe('Sed serialise tests', () => { test('Remote CellML file without base path', () => { const file = new loc.File(utils.REMOTE_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); @@ -189,7 +164,7 @@ test.describe('Sed serialise tests', () => { test('Relative remote CellML file with base path', () => { const file = new loc.File(utils.REMOTE_FILE); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); @@ -240,7 +215,7 @@ test.describe('Sed serialise tests', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(daeContentsPtr, utils.DAE_CONTENTS.length); + file.setContents(utils.DAE_CONTENTS); const document = new loc.SedDocument(file); @@ -250,7 +225,7 @@ test.describe('Sed serialise tests', () => { test('NLA model', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(nlaContentsPtr, utils.NLA_CONTENTS.length); + file.setContents(utils.NLA_CONTENTS); const document = new loc.SedDocument(file); @@ -274,7 +249,7 @@ test.describe('Sed serialise tests', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(algebraicContentsPtr, utils.ALGEBRAIC_CONTENTS.length); + file.setContents(utils.ALGEBRAIC_CONTENTS); const document = new loc.SedDocument(file); @@ -356,7 +331,7 @@ test.describe('Sed serialise tests', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -369,7 +344,7 @@ test.describe('Sed serialise tests', () => { test('CVODE solver with the Adams-Moulton integration method', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -388,7 +363,7 @@ test.describe('Sed serialise tests', () => { test('CVODE solver with a functional iteration type', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -407,7 +382,7 @@ test.describe('Sed serialise tests', () => { test('CVODE solver with a banded linear solver', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -426,7 +401,7 @@ test.describe('Sed serialise tests', () => { test('CVODE solver with a diagonal linear solver', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -445,7 +420,7 @@ test.describe('Sed serialise tests', () => { test('CVODE solver with a GMRES linear solver', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -464,7 +439,7 @@ test.describe('Sed serialise tests', () => { test('CVODE solver with a BiCGStab linear solver', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -483,7 +458,7 @@ test.describe('Sed serialise tests', () => { test('CVODE solver with a TFQMR linear solver', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -502,7 +477,7 @@ test.describe('Sed serialise tests', () => { test('CVODE solver with no preconditioner', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -519,7 +494,7 @@ test.describe('Sed serialise tests', () => { test('CVODE solver with no interpolate solution', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -538,7 +513,7 @@ test.describe('Sed serialise tests', () => { test('KINSOL solver with a banded linear solver', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(nlaContentsPtr, utils.NLA_CONTENTS.length); + file.setContents(utils.NLA_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -555,7 +530,7 @@ test.describe('Sed serialise tests', () => { test('KINSOL solver with a GMRES linear solver', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(nlaContentsPtr, utils.NLA_CONTENTS.length); + file.setContents(utils.NLA_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -572,7 +547,7 @@ test.describe('Sed serialise tests', () => { test('KINSOL solver with a BiCGStab linear solver', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(nlaContentsPtr, utils.NLA_CONTENTS.length); + file.setContents(utils.NLA_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -589,7 +564,7 @@ test.describe('Sed serialise tests', () => { test('KINSOL solver with a TFQMR linear solver', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(nlaContentsPtr, utils.NLA_CONTENTS.length); + file.setContents(utils.NLA_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -620,7 +595,7 @@ test.describe('Sed serialise tests', () => { const file = new loc.File(utils.resourcePath(utils.CELLML_FILE)); - file.setContents(cellmlContentsPtr, utils.CELLML_CONTENTS.length); + file.setContents(utils.CELLML_CONTENTS); const document = new loc.SedDocument(file); @@ -666,7 +641,7 @@ test.describe('Sed serialise tests', () => { const file = new loc.File(utils.resourcePath(utils.SEDML_FILE)); - file.setContents(sedmlContentsPtr, utils.SEDML_CONTENTS.length); + file.setContents(utils.SEDML_CONTENTS); const document = new loc.SedDocument(file); @@ -920,7 +895,7 @@ test.describe('Sed serialise tests', () => { const file = new loc.File(utils.resourcePath(utils.SEDML_FILE)); - file.setContents(sedmlWithSimulationsContentsPtr, utils.SEDML_WITH_SIMULATIONS_CONTENTS.length); + file.setContents(utils.SEDML_WITH_SIMULATIONS_CONTENTS); const document = new loc.SedDocument(file); diff --git a/tests/bindings/javascript/solver.coverage.test.js b/tests/bindings/javascript/solver.coverage.test.js index e170d2f03..42897bc99 100644 --- a/tests/bindings/javascript/solver.coverage.test.js +++ b/tests/bindings/javascript/solver.coverage.test.js @@ -24,27 +24,14 @@ import { assertIssues, assertValue } from './utils.js'; const loc = await libOpenCOR(); test.describe('Solver coverage tests', () => { - let algebraicSedChangesContentsPtr; - let odeSedChangesContentsPtr; - - test.before(() => { - algebraicSedChangesContentsPtr = utils.allocateMemory(loc, utils.ALGEBRAIC_SED_CHANGES_CONTENTS); - odeSedChangesContentsPtr = utils.allocateMemory(loc, utils.ODE_SED_CHANGES_CONTENTS); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, algebraicSedChangesContentsPtr); - utils.freeMemory(loc, odeSedChangesContentsPtr); - }); - test('ODE changes', () => { const file = new loc.File(utils.COMBINE_ARCHIVE); - file.setContents(odeSedChangesContentsPtr, utils.ODE_SED_CHANGES_CONTENTS.length); + file.setContents(utils.ODE_SED_CHANGES_CONTENTS); const document = new loc.SedDocument(file); const instance = document.instantiate(); @@ -95,7 +82,7 @@ test.describe('Solver coverage tests', () => { const file = new loc.File(utils.COMBINE_ARCHIVE); - file.setContents(algebraicSedChangesContentsPtr, utils.ALGEBRAIC_SED_CHANGES_CONTENTS.length); + file.setContents(utils.ALGEBRAIC_SED_CHANGES_CONTENTS); const document = new loc.SedDocument(file); const instance = document.instantiate(); diff --git a/tests/bindings/javascript/solver.cvode.test.js b/tests/bindings/javascript/solver.cvode.test.js index 12b46e8f3..1dd174a47 100644 --- a/tests/bindings/javascript/solver.cvode.test.js +++ b/tests/bindings/javascript/solver.cvode.test.js @@ -24,24 +24,14 @@ import { assertIssues } from './utils.js'; const loc = await libOpenCOR(); test.describe('Solver CVODE tests', () => { - let solverOdeContentsPtr; - - test.before(() => { - solverOdeContentsPtr = utils.allocateMemory(loc, utils.SOLVER_ODE_CONTENTS); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, solverOdeContentsPtr); - }); - test('Maximum step value with invalid number', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -62,7 +52,7 @@ test.describe('Solver CVODE tests', () => { test('Maximum number of steps value with invalid number', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -83,7 +73,7 @@ test.describe('Solver CVODE tests', () => { test('Banded linear solver and upper half-bandwidth value with number too small', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -105,7 +95,7 @@ test.describe('Solver CVODE tests', () => { test('Banded linear solver and upper half-bandwidth value with number too big', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -127,7 +117,7 @@ test.describe('Solver CVODE tests', () => { test('Banded linear solver and lower half-bandwidth value with number too small', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -149,7 +139,7 @@ test.describe('Solver CVODE tests', () => { test('Banded linear solver and lower half-bandwidth value with number too big', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -171,7 +161,7 @@ test.describe('Solver CVODE tests', () => { test('Relative tolerance value with invalid number', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -192,7 +182,7 @@ test.describe('Solver CVODE tests', () => { test('Absolute tolerance value with invalid number', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -213,7 +203,7 @@ test.describe('Solver CVODE tests', () => { test('Solve', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); @@ -238,7 +228,7 @@ test.describe('Solver CVODE tests', () => { test('Solve without interpolate solution', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -267,7 +257,7 @@ test.describe('Solver CVODE tests', () => { test('Solve with Adams-Moulton integration method', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -296,7 +286,7 @@ test.describe('Solver CVODE tests', () => { test('Solve with functional iteration type', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -325,7 +315,7 @@ test.describe('Solver CVODE tests', () => { test('Solve with banded linear solver', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -354,7 +344,7 @@ test.describe('Solver CVODE tests', () => { test('Solve with diagonal linear solver', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -383,7 +373,7 @@ test.describe('Solver CVODE tests', () => { test('Solve with GMRES linear solver', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -412,7 +402,7 @@ test.describe('Solver CVODE tests', () => { test('Solve with Bi-CGstab linear solver', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -441,7 +431,7 @@ test.describe('Solver CVODE tests', () => { test('Solve with TFQMR linear solver', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -470,7 +460,7 @@ test.describe('Solver CVODE tests', () => { test('Solve with GMRES linear solver and no preconditioner', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -500,7 +490,7 @@ test.describe('Solver CVODE tests', () => { test('Solve with Bi-CGstab linear solver and no preconditioner', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -530,7 +520,7 @@ test.describe('Solver CVODE tests', () => { test('Solve with TFQMR linear solver and no preconditioner', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); diff --git a/tests/bindings/javascript/solver.forwardeuler.test.js b/tests/bindings/javascript/solver.forwardeuler.test.js index 0c401fd79..7e8064105 100644 --- a/tests/bindings/javascript/solver.forwardeuler.test.js +++ b/tests/bindings/javascript/solver.forwardeuler.test.js @@ -24,24 +24,14 @@ import { assertIssues } from './utils.js'; const loc = await libOpenCOR(); test.describe('Solver Forward Euler tests', () => { - let solverOdeContentsPtr; - - test.before(() => { - solverOdeContentsPtr = utils.allocateMemory(loc, utils.SOLVER_ODE_CONTENTS); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, solverOdeContentsPtr); - }); - test('Step value with invalid number', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -61,7 +51,7 @@ test.describe('Solver Forward Euler tests', () => { test('Solve', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); diff --git a/tests/bindings/javascript/solver.fourthorderrungekutta.test.js b/tests/bindings/javascript/solver.fourthorderrungekutta.test.js index c447dd561..9a1ee7871 100644 --- a/tests/bindings/javascript/solver.fourthorderrungekutta.test.js +++ b/tests/bindings/javascript/solver.fourthorderrungekutta.test.js @@ -24,24 +24,14 @@ import { assertIssues } from './utils.js'; const loc = await libOpenCOR(); test.describe('Solver Fourth-Order Runge-Kutta tests', () => { - let solverOdeContentsPtr; - - test.before(() => { - solverOdeContentsPtr = utils.allocateMemory(loc, utils.SOLVER_ODE_CONTENTS); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, solverOdeContentsPtr); - }); - test('Step value with invalid number', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -64,7 +54,7 @@ test.describe('Solver Fourth-Order Runge-Kutta tests', () => { test('Solve', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); diff --git a/tests/bindings/javascript/solver.heun.test.js b/tests/bindings/javascript/solver.heun.test.js index 04c3417ae..d510ebc9f 100644 --- a/tests/bindings/javascript/solver.heun.test.js +++ b/tests/bindings/javascript/solver.heun.test.js @@ -24,24 +24,14 @@ import { assertIssues } from './utils.js'; const loc = await libOpenCOR(); test.describe('Solver Heun tests', () => { - let solverOdeContentsPtr; - - test.before(() => { - solverOdeContentsPtr = utils.allocateMemory(loc, utils.SOLVER_ODE_CONTENTS); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, solverOdeContentsPtr); - }); - test('Step value with invalid number', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -61,7 +51,7 @@ test.describe('Solver Heun tests', () => { test('Solve', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); diff --git a/tests/bindings/javascript/solver.kinsol.test.js b/tests/bindings/javascript/solver.kinsol.test.js index 3a564823a..fe7913152 100644 --- a/tests/bindings/javascript/solver.kinsol.test.js +++ b/tests/bindings/javascript/solver.kinsol.test.js @@ -24,27 +24,14 @@ import { assertIssues, assertValue } from './utils.js'; const loc = await libOpenCOR(); test.describe('Solver KINSOL tests', () => { - let solverNla1ContentsPtr; - let solverNla2ContentsPtr; - - test.before(() => { - solverNla1ContentsPtr = utils.allocateMemory(loc, utils.SOLVER_NLA1_CONTENTS); - solverNla2ContentsPtr = utils.allocateMemory(loc, utils.SOLVER_NLA2_CONTENTS); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, solverNla1ContentsPtr); - utils.freeMemory(loc, solverNla2ContentsPtr); - }); - test('Maximum number of iterations value with invalid number', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverNla1ContentsPtr, utils.SOLVER_NLA1_CONTENTS.length); + file.setContents(utils.SOLVER_NLA1_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -65,7 +52,7 @@ test.describe('Solver KINSOL tests', () => { test('Banded linear solver and upper half-bandwidth value with number too small', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverNla2ContentsPtr, utils.SOLVER_NLA2_CONTENTS.length); + file.setContents(utils.SOLVER_NLA2_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -87,7 +74,7 @@ test.describe('Solver KINSOL tests', () => { test('Banded linear solver and upper half-bandwidth value with number too big', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverNla1ContentsPtr, utils.SOLVER_NLA1_CONTENTS.length); + file.setContents(utils.SOLVER_NLA1_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -109,7 +96,7 @@ test.describe('Solver KINSOL tests', () => { test('Banded linear solver and lower half-bandwidth value with number too small', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverNla2ContentsPtr, utils.SOLVER_NLA2_CONTENTS.length); + file.setContents(utils.SOLVER_NLA2_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -131,7 +118,7 @@ test.describe('Solver KINSOL tests', () => { test('Banded linear solver and lower half-bandwidth value with number too big', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverNla1ContentsPtr, utils.SOLVER_NLA1_CONTENTS.length); + file.setContents(utils.SOLVER_NLA1_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -176,7 +163,7 @@ test.describe('Solver KINSOL tests', () => { test('Solve', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverNla1ContentsPtr, utils.SOLVER_NLA1_CONTENTS.length); + file.setContents(utils.SOLVER_NLA1_CONTENTS); const document = new loc.SedDocument(file); const instance = document.instantiate(); @@ -189,7 +176,7 @@ test.describe('Solver KINSOL tests', () => { test('Solve with banded linear solver', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverNla2ContentsPtr, utils.SOLVER_NLA2_CONTENTS.length); + file.setContents(utils.SOLVER_NLA2_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -209,7 +196,7 @@ test.describe('Solver KINSOL tests', () => { test('Solve with GMRES linear solver', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverNla1ContentsPtr, utils.SOLVER_NLA1_CONTENTS.length); + file.setContents(utils.SOLVER_NLA1_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -227,7 +214,7 @@ test.describe('Solver KINSOL tests', () => { test('Solve with BiCGStab linear solver', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverNla2ContentsPtr, utils.SOLVER_NLA2_CONTENTS.length); + file.setContents(utils.SOLVER_NLA2_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -245,7 +232,7 @@ test.describe('Solver KINSOL tests', () => { test('Solve with TFQMR linear solver', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverNla1ContentsPtr, utils.SOLVER_NLA1_CONTENTS.length); + file.setContents(utils.SOLVER_NLA1_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); diff --git a/tests/bindings/javascript/solver.secondorderrungekutta.test.js b/tests/bindings/javascript/solver.secondorderrungekutta.test.js index e84e53d6f..353e7e52f 100644 --- a/tests/bindings/javascript/solver.secondorderrungekutta.test.js +++ b/tests/bindings/javascript/solver.secondorderrungekutta.test.js @@ -24,24 +24,14 @@ import { assertIssues } from './utils.js'; const loc = await libOpenCOR(); test.describe('Solver Second-Order Runge-Kutta tests', () => { - let solverOdeContentsPtr; - - test.before(() => { - solverOdeContentsPtr = utils.allocateMemory(loc, utils.SOLVER_ODE_CONTENTS); - }); - test.beforeEach(() => { loc.FileManager.instance().reset(); }); - test.after(() => { - utils.freeMemory(loc, solverOdeContentsPtr); - }); - test('Step value with invalid number', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0); @@ -64,7 +54,7 @@ test.describe('Solver Second-Order Runge-Kutta tests', () => { test('Solve', () => { const file = new loc.File(utils.CELLML_FILE); - file.setContents(solverOdeContentsPtr, utils.SOLVER_ODE_CONTENTS.length); + file.setContents(utils.SOLVER_ODE_CONTENTS); const document = new loc.SedDocument(file); const simulation = document.simulations.get(0);