diff --git a/src/bindings/javascript/analyserequation.cpp b/src/bindings/javascript/analyserequation.cpp index d7579751f8..c7a9daf695 100644 --- a/src/bindings/javascript/analyserequation.cpp +++ b/src/bindings/javascript/analyserequation.cpp @@ -45,9 +45,12 @@ EMSCRIPTEN_BINDINGS(libcellml_analyserequation) .function("nlaSiblings", &libcellml::AnalyserEquation::nlaSiblings) .function("nlaSibling", &libcellml::AnalyserEquation::nlaSibling) .function("isStateRateBased", &libcellml::AnalyserEquation::isStateRateBased) - .function("variableCount", &libcellml::AnalyserEquation::variableCount) - .function("variables", &libcellml::AnalyserEquation::variables) - .function("variable", &libcellml::AnalyserEquation::variable) + .function("computedConstantCount", &libcellml::AnalyserEquation::computedConstantCount) + .function("computedConstants", &libcellml::AnalyserEquation::computedConstants) + .function("computedConstant", &libcellml::AnalyserEquation::computedConstant) + .function("algebraicCount", &libcellml::AnalyserEquation::algebraicCount) + .function("algebraicVariables", select_overload() const>(&libcellml::AnalyserEquation::algebraic)) + .function("algebraicVariable", select_overload(&libcellml::AnalyserEquation::algebraic)) ; EM_ASM( diff --git a/src/bindings/javascript/analysermodel.cpp b/src/bindings/javascript/analysermodel.cpp index 87a74085f5..3103e413a7 100644 --- a/src/bindings/javascript/analysermodel.cpp +++ b/src/bindings/javascript/analysermodel.cpp @@ -45,9 +45,15 @@ EMSCRIPTEN_BINDINGS(libcellml_analysermodel) .function("stateCount", &libcellml::AnalyserModel::stateCount) .function("states", &libcellml::AnalyserModel::states) .function("state", &libcellml::AnalyserModel::state) - .function("variableCount", &libcellml::AnalyserModel::variableCount) - .function("variables", &libcellml::AnalyserModel::variables) - .function("variable", &libcellml::AnalyserModel::variable) + .function("constantCount", &libcellml::AnalyserModel::constantCount) + .function("constants", &libcellml::AnalyserModel::constants) + .function("constant", &libcellml::AnalyserModel::constant) + .function("computedConstantCount", &libcellml::AnalyserModel::computedConstantCount) + .function("computedConstants", &libcellml::AnalyserModel::computedConstants) + .function("computedConstant", &libcellml::AnalyserModel::computedConstant) + .function("algebraicCount", &libcellml::AnalyserModel::algebraicCount) + .function("algebraicVariables", select_overload() const>(&libcellml::AnalyserModel::algebraic)) + .function("algebraicVariable", select_overload(&libcellml::AnalyserModel::algebraic)) .function("equationCount", &libcellml::AnalyserModel::equationCount) .function("equations", &libcellml::AnalyserModel::equations) .function("equation", &libcellml::AnalyserModel::equation) diff --git a/tests/bindings/javascript/analyserequation.test.js b/tests/bindings/javascript/analyserequation.test.js index 4f1a5cc317..7619bdebdc 100644 --- a/tests/bindings/javascript/analyserequation.test.js +++ b/tests/bindings/javascript/analyserequation.test.js @@ -56,7 +56,7 @@ describe("Analyser Equation tests", () => { expect(eqn.dependencies().size()).toBe(0) }); test('Checking Analyser Equation dependency.', () => { - expect(eqn.dependency(0)).toBe(null) + expect(eqn.dependency(0)).toBeNull() }); test('Checking Analyser Equation nlaSystemIndex.', () => { expect(eqn.nlaSystemIndex()).toBe(4294967295) @@ -68,16 +68,25 @@ describe("Analyser Equation tests", () => { expect(eqn.nlaSiblings().size()).toBe(0) }); test('Checking Analyser Equation nlaSibling.', () => { - expect(eqn.nlaSibling(0)).toBe(null) + expect(eqn.nlaSibling(0)).toBeNull() }); - test('Checking Analyser Equation variableCount.', () => { - expect(eqn.variableCount()).toBe(1) + test('Checking Analyser Equation computedConstantCount.', () => { + expect(eqn.computedConstantCount()).toBe(0) }); - test('Checking Analyser Equation variables.', () => { - expect(eqn.variables().size()).toBe(1) + test('Checking Analyser Equation computedConstants.', () => { + expect(eqn.computedConstants().size()).toBe(0) }); - test('Checking Analyser Equation variable.', () => { - expect(eqn.variable(0).variable().name()).toBe("x") + test('Checking Analyser Equation computedConstant.', () => { + expect(eqn.computedConstant(0)).toBeNull() + }); + test('Checking Analyser Equation algebraicCount.', () => { + expect(eqn.algebraicCount()).toBe(1) + }); + test('Checking Analyser Equation algebraicVariables.', () => { + expect(eqn.algebraicVariables().size()).toBe(1) + }); + test('Checking Analyser Equation algebraicVariable.', () => { + expect(eqn.algebraicVariable(0).variable().name()).toBe("x") }); test('Checking Analyser Equation AST.', () => { expect(eqn.ast().value()).toBe("") diff --git a/tests/bindings/javascript/analysermodel.test.js b/tests/bindings/javascript/analysermodel.test.js index a84ad5e3d2..c709d93684 100644 --- a/tests/bindings/javascript/analysermodel.test.js +++ b/tests/bindings/javascript/analysermodel.test.js @@ -61,10 +61,20 @@ describe("Analyser Model tests", () => { expect(am.states().size()).toBe(4) expect(am.state(2).variable().name()).toBe("m") }); - test('Checking Analyser Model variables related API.', () => { - expect(am.variableCount()).toBe(18) - expect(am.variables().size()).toBe(18) - expect(am.variable(2).variable().name()).toBe("i_K") + test('Checking Analyser Model constants related API.', () => { + expect(am.constantCount()).toBe(0) + expect(am.constants().size()).toBe(0) + expect(am.constant(2)).toBeNull() + }); + test('Checking Analyser Model computed constants related API.', () => { + expect(am.computedConstantCount()).toBe(0) + expect(am.computedConstants().size()).toBe(0) + expect(am.computedConstant(2)).toBeNull() + }); + test('Checking Analyser Model algebraic variables related API.', () => { + expect(am.algebraicCount()).toBe(18) + expect(am.algebraicVariables().size()).toBe(18) + expect(am.algebraicVariable(2).variable().name()).toBe("i_K") }); test('Checking Analyser Model need* API.', () => { expect(am.needEqFunction()).toBe(false) @@ -93,6 +103,6 @@ describe("Analyser Model tests", () => { expect(am.needAcothFunction()).toBe(false) }); test('Checking Analyser Model are equivalent variables.', () => { - expect(am.areEquivalentVariables(am.variable(2).variable(), am.variable(7).variable())).toBe(false) + expect(am.areEquivalentVariables(am.algebraicVariable(2).variable(), am.algebraicVariable(7).variable())).toBe(false) }); }) diff --git a/tests/bindings/javascript/analyservariable.test.js b/tests/bindings/javascript/analyservariable.test.js index 52b5ef7496..6aa1f4f8d1 100644 --- a/tests/bindings/javascript/analyservariable.test.js +++ b/tests/bindings/javascript/analyservariable.test.js @@ -37,35 +37,37 @@ describe("Analyser Variable tests", () => { am = a.model() - expect(am.variableCount()).toBe(18) + expect(am.constantCount()).toBe(0) + expect(am.computedConstantCount()).toBe(0) + expect(am.algebraicCount()).toBe(18) }); test('Checking Analyser Variable type.', () => { - const av = am.variable(0) + const av = am.algebraicVariable(0) expect(av.type().value).toBe(libcellml.AnalyserVariable.Type.ALGEBRAIC.value) expect(libcellml.AnalyserVariable.typeAsString(av.type())).toBe("algebraic") }); test('Checking Analyser Variable index.', () => { - const av = am.variable(7) + const av = am.algebraicVariable(7) expect(av.index()).toBe(7) }); test('Checking Analyser Variable initialising variable.', () => { - const av = am.variable(15) + const av = am.algebraicVariable(15) expect(av.initialisingVariable().name()).toBe("g_K") }); test('Checking Analyser Variable variable.', () => { - const av = am.variable(10) + const av = am.algebraicVariable(10) expect(av.variable().name()).toBe("alpha_m") }); test('Checking Analyser Equation equationCount.', () => { - const av = am.variable(14) + const av = am.algebraicVariable(14) expect(av.equationCount()).toBe(1) }); test('Checking Analyser Variable equations.', () => { - const av = am.variable(14) + const av = am.algebraicVariable(14) expect(av.equations().size()).toBe(1) }); test('Checking Analyser Variable equation.', () => { - const av = am.variable(14) + const av = am.algebraicVariable(14) expect(av.equation(0).type().value).toBe(libcellml.AnalyserEquation.Type.VARIABLE_BASED_CONSTANT.value) }); }) diff --git a/tests/bindings/javascript/generator.test.js b/tests/bindings/javascript/generator.test.js index 0fd13e18a5..bd854e65f8 100644 --- a/tests/bindings/javascript/generator.test.js +++ b/tests/bindings/javascript/generator.test.js @@ -43,7 +43,7 @@ describe("Generator tests", () => { a.analyseModel(m) - expect(g.model()).toBe(null) + expect(g.model()).toBeNull() g.setModel(a.model()) @@ -62,10 +62,10 @@ describe("Generator tests", () => { g.setModel(a.model()) const interface_lines = g.interfaceCode().split('\n') - expect(interface_lines.length).toBe(40) + expect(interface_lines.length).toBe(42) const implementation_lines = g.implementationCode().split('\n') - expect(implementation_lines.length).toBe(67) + expect(implementation_lines.length).toBe(69) const equation_line_1 = libcellml.Generator.equationCode(a.model().equation(0).ast()) expect(equation_line_1.length).toBe(14) diff --git a/tests/bindings/javascript/generatorprofile.test.js b/tests/bindings/javascript/generatorprofile.test.js index be6ff9f397..7c5bd368e6 100644 --- a/tests/bindings/javascript/generatorprofile.test.js +++ b/tests/bindings/javascript/generatorprofile.test.js @@ -684,17 +684,41 @@ describe("GeneratorProfile tests", () => { x.setImplementationStateCountString("something") expect(x.implementationStateCountString()).toBe("something") }); - test("Checking GeneratorProfile.interfaceVariableCountString.", () => { + test("Checking GeneratorProfile.interfaceConstantCountString.", () => { const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) - x.setInterfaceVariableCountString("something") - expect(x.interfaceVariableCountString()).toBe("something") + x.setInterfaceConstantCountString("something") + expect(x.interfaceConstantCountString()).toBe("something") }); - test("Checking GeneratorProfile.implementationVariableCountString.", () => { + test("Checking GeneratorProfile.implementationConstantCountString.", () => { const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) - x.setImplementationVariableCountString("something") - expect(x.implementationVariableCountString()).toBe("something") + x.setImplementationConstantCountString("something") + expect(x.implementationConstantCountString()).toBe("something") + }); + test("Checking GeneratorProfile.interfaceComputedConstantCountString.", () => { + const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) + + x.setInterfaceComputedConstantCountString("something") + expect(x.interfaceComputedConstantCountString()).toBe("something") + }); + test("Checking GeneratorProfile.implementationComputedConstantCountString.", () => { + const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) + + x.setImplementationComputedConstantCountString("something") + expect(x.implementationComputedConstantCountString()).toBe("something") + }); + test("Checking GeneratorProfile.interfaceAlgebraicCountString.", () => { + const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) + + x.setInterfaceAlgebraicCountString("something") + expect(x.interfaceAlgebraicCountString()).toBe("something") + }); + test("Checking GeneratorProfile.implementationAlgebraicCountString.", () => { + const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) + + x.setImplementationAlgebraicCountString("something") + expect(x.implementationAlgebraicCountString()).toBe("something") }); test("Checking GeneratorProfile.variableTypeObjectString.", () => { const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) diff --git a/tests/bindings/javascript/importsource.test.js b/tests/bindings/javascript/importsource.test.js index e349be0880..f3b48c307a 100644 --- a/tests/bindings/javascript/importsource.test.js +++ b/tests/bindings/javascript/importsource.test.js @@ -34,7 +34,7 @@ describe("Import Source tests", () => { const iS = new libcellml.ImportSource() const m = new libcellml.Model() - expect(iS.model()).toBe(null) + expect(iS.model()).toBeNull() iS.setModel(m) diff --git a/tests/bindings/javascript/reset.test.js b/tests/bindings/javascript/reset.test.js index ab70a879bc..72a905f3f6 100644 --- a/tests/bindings/javascript/reset.test.js +++ b/tests/bindings/javascript/reset.test.js @@ -41,7 +41,7 @@ describe("Reset tests", () => { const r = new libcellml.Reset() const v = new libcellml.Variable() - expect(r.variable()).toBe(null) + expect(r.variable()).toBeNull() r.setVariable(v) expect(r.variable()).toStrictEqual(v) @@ -50,7 +50,7 @@ describe("Reset tests", () => { const r = new libcellml.Reset() const v = new libcellml.Variable() - expect(r.testVariable()).toBe(null) + expect(r.testVariable()).toBeNull() r.setTestVariable(v) expect(r.testVariable()).toStrictEqual(v) diff --git a/tests/bindings/javascript/variable.test.js b/tests/bindings/javascript/variable.test.js index 9dbc06c2fb..a3d863b0da 100644 --- a/tests/bindings/javascript/variable.test.js +++ b/tests/bindings/javascript/variable.test.js @@ -70,7 +70,7 @@ describe("Variable tests", () => { const v = new libcellml.Variable("V") const u = new libcellml.Units("mV") - expect(v.units()).toBe(null) + expect(v.units()).toBeNull() v.setUnitsByName("A") @@ -82,7 +82,7 @@ describe("Variable tests", () => { v.removeUnits() - expect(v.units()).toBe(null) + expect(v.units()).toBeNull() v.delete() u.delete()