Let Equals match a number against a typed number like 130 (#224)
The float tolerance from the last commit never reached the case it was built for. The inputs of Equals are of type any, and their inline field is a text field. A typed 130 therefore arrives as the string "130", and the tolerance only applied when both sides were real numbers. The node fell back to comparing "129.99999999999997" with "130" as text. - A number against a text that parses as a number now uses the same 1e-9 rule as two numbers. - An empty text does not count as 0. - Two texts are still compared as text, so "1.0" and "1" stay different. - Compare was not affected, its inputs are real number fields. Tests: - 3 new cases in node-catalog.test.ts: 129.99999999999997 vs "130" is equal, 0 vs "" is not, "1.0" vs "1" is not. - Counter-check: with the old rule (two real numbers only) exactly the "130" case fails. Original restored and compared with cmp. - ./check.sh: 156 files, 2314 tests, CHECK EXIT 0 (before 2311). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9d6a0aebd3
commit
5bf1ee7a4e
2 files changed
+23
-3
No files matched your search
@@ -691,6 +691,14 @@ const CASES: Record<string, Case[]> = {
|
||||
outputs: { result: true },
|
||||
},
|
||||
{ name: 'two numbers still tell 6.001 from 6', inputs: { a: 6.001, b: 6 }, outputs: { result: false } },
|
||||
// The inline field of an `any` pin is text: a typed 130 against time - late at 130 s.
|
||||
{
|
||||
name: 'a noisy number equals the typed text 130',
|
||||
inputs: { a: 129.99999999999997, b: '130' },
|
||||
outputs: { result: true },
|
||||
},
|
||||
{ name: 'empty text is not 0', inputs: { a: 0, b: '' }, outputs: { result: false } },
|
||||
{ name: 'two texts still compare as text', inputs: { a: '1.0', b: '1' }, outputs: { result: false } },
|
||||
],
|
||||
Compare: [
|
||||
{ name: 'less than', inputs: { a: 1, b: 2 }, params: { op: '<' }, outputs: { result: true } },
|
||||
|
||||
Reference in new issue
Block a user