feat: Instantiate instances of template instantiation need for self-reference
Formerly, when a self-reference like `self(Tuple<number>)` was encountered, but the `Tuple<number>` instance of a `Tuple<T>` implementation for this operation had not yet been instantiated, the reference would be fulfilled with a call to the catchall implementation for `Tuple`. Now the necessary instance is instantiated on the spot and referred to instead. This change is used to complete return-type specification for all of the Tuple functions.
This commit is contained in:
parent
be9794fd4c
commit
d83f2a7f23
8 changed files with 255 additions and 113 deletions
|
@ -54,6 +54,9 @@ describe('tuple', () => {
|
|||
assert.deepStrictEqual(
|
||||
math.subtract(math.tuple(3n,4n,5n), math.tuple(2n,1n,0n)),
|
||||
math.tuple(1n,3n,5n))
|
||||
assert.deepStrictEqual(
|
||||
math.returnTypeOf('subtract', 'Tuple<bigint>,Tuple<bigint>'),
|
||||
'Tuple<bigint>')
|
||||
assert.throws(
|
||||
() => math.subtract(math.tuple(5,6), math.tuple(7)),
|
||||
/RangeError/)
|
||||
|
@ -104,9 +107,16 @@ describe('tuple', () => {
|
|||
})
|
||||
|
||||
it('supports sqrt', () => {
|
||||
const mixedTuple = math.tuple(2, math.complex(0,2), 1.5)
|
||||
assert.deepStrictEqual(
|
||||
math.sqrt(math.tuple(4,-4,2.25)),
|
||||
math.tuple(2, math.complex(0,2), 1.5))
|
||||
mixedTuple,
|
||||
math.tuple(math.complex(2), math.complex(0,2), math.complex(1.5)))
|
||||
assert.strictEqual(
|
||||
math.returnTypeOf('tuple', 'NumInt, Complex<NumInt>, number'),
|
||||
'Tuple<Complex<number>>')
|
||||
assert.deepStrictEqual(math.sqrt(math.tuple(4,-4,2.25)), mixedTuple)
|
||||
assert.strictEqual(
|
||||
math.returnTypeOf('sqrt', 'Tuple<NumInt>'), 'Tuple<Complex<number>>')
|
||||
})
|
||||
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue