Skip to content

BUG: Comparison between Symbol and number causes uncaught exception #251

@Mitsunee

Description

@Mitsunee

A comparison between a Symbol and a number causes the following uncaught exception:

Cannot convert a Symbol value to a string

at direct (file:///home/mitsu/Dev/REDACTED/node_modules/uvu/diff/index.mjs:136:29)
    at compare (file:///home/mitsu/Dev/REDACTED/node_modules/uvu/diff/index.mjs:218:9)
    at assert (file:///home/mitsu/Dev/REDACTED/node_modules/uvu/assert/index.mjs:32:28)
    at Module.equal (file:///home/mitsu/Dev/REDACTED/node_modules/uvu/assert/index.mjs:45:2)
    at Object.handler (/home/mitsu/Dev/REDACTED/packages/REDACTED_PKG/tests/some.test.ts:118:10)
    at Number.runner (file:///home/mitsu/Dev/REDACTED/node_modules/uvu/dist/index.mjs:78:16)
    at async Timeout.exec [as _onTimeout] (file:///home/mitsu/Dev/REDACTED/node_modules/uvu/dist/index.mjs:141:33)

It doesn't appear to matter whether assert.is or assert.equal was used.

My proposed change would be to first compare the values using typeof (i.e. what assert.type does) and potentially give a failure result based on that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions