Skip to content

Commit

Permalink
fix a typo in the vector(list) function
Browse files Browse the repository at this point in the history
  • Loading branch information
christianp committed Mar 8, 2024
1 parent 60531fd commit c4ca777
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions runtime/scripts/jme-builtins.js
Original file line number Diff line number Diff line change
Expand Up @@ -2216,8 +2216,8 @@ newBuiltin('vector',[sig.listof(sig.type('number'))],TVector, null, {
var list = args[0];
var value = list.value.map(function(x){return x.value});
var t = new TVector(value);
if(args.length>0) {
var tn = args[0].value[0];
if(list.value.length>0) {
var tn = list.value[0];
t.precisionType = tn.precisionType;
t.precision = tn.precision;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/jme-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -16045,8 +16045,8 @@ newBuiltin('vector',[sig.listof(sig.type('number'))],TVector, null, {
var list = args[0];
var value = list.value.map(function(x){return x.value});
var t = new TVector(value);
if(args.length>0) {
var tn = args[0].value[0];
if(list.value.length>0) {
var tn = list.value[0];
t.precisionType = tn.precisionType;
t.precision = tn.precision;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/jme/jme-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,10 @@ Numbas.queueScript('jme_tests',['qunit','jme','jme-rules','jme-display','jme-cal
raisesNumbasError(assert, function() { new jme.types.TVector(1); }, 'jme.vector.value not an array of numbers');
raisesNumbasError(assert, function() { new jme.types.TVector([1,[2],[3]]); }, 'jme.vector.value not an array of numbers');
assert.ok(evaluate('matrix([i])'), 'complex values in matrices are OK');
assert.ok(evaluate('vector()'), 'empty vector');
assert.ok(evaluate('vector([])'), 'empty vector created with a list');
assert.ok(evaluate('matrix([])'), '0×0 matrix');
assert.ok(evaluate('matrix([[]])'), '1×0 matrix');
assert.ok(evaluate('vector(i)'), 'complex values in vectors are OK');
closeEqual(assert, evaluate('dot(vector(1,2),vector(2,3))').value,8,'dot(vector(1,2),vector(2,3))');
closeEqual(assert, evaluate('dot(matrix([1],[2],[3]),vector(6,5,4))').value,28,'dot(matrix([1],[2],[3]),vector(6,5,4))');
Expand Down
4 changes: 2 additions & 2 deletions tests/numbas-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -15636,8 +15636,8 @@ newBuiltin('vector',[sig.listof(sig.type('number'))],TVector, null, {
var list = args[0];
var value = list.value.map(function(x){return x.value});
var t = new TVector(value);
if(args.length>0) {
var tn = args[0].value[0];
if(list.value.length>0) {
var tn = list.value[0];
t.precisionType = tn.precisionType;
t.precision = tn.precision;
}
Expand Down

0 comments on commit c4ca777

Please sign in to comment.