Skip to content

Numeric literal symbols (! # &) are removed from transpiled params #320

@luis-j-soares

Description

@luis-j-soares

This test fails:

@it("matches a numeric value")
@params(10.23!, "Float")
@params(10.23#, "Double")
@params(10&, "LongInteger")
sub _(number as Dynamic, expectedType as String)
    m.assertEqual(rooibos.common.getSafeType(number), expectedType)
end sub
    ✔ matches a numeric value 0 [10.23,"Float"]
    ✖ matches a numeric value 1 [10.23,"Double"]
    ✖ matches a numeric value 2 [10,"LongInteger"]

           matches a numeric value 1:

    AssertionError: expected ""Float"" to equal ""Double""
      + expected - actual

      -"Float"
      +"Double"

            matches a numeric value 2:

    AssertionError: expected ""Integer"" to equal ""LongInteger""
      + expected - actual

      -"Integer"
      +"LongInteger"

This is because the symbols get stripped from the literals when generating rawParams:

[
    {
        isSolo: false
        noCatch: false
        funcName: "FullColdStartWithProfilesMatcher_matches_a_numeric_value"
        isIgnored: false
        isAsync: false
        asyncTimeout: 2000
        slow: 75
        isParamTest: true
        name: "matches a numeric value"
        lineNumber: 14
        paramLineNumber: 11
        assertIndex: 0
        rawParams: [
            10.23 ' <-- missing !
            "Float"
        ]
        paramTestIndex: 0
        expectedNumberOfParams: 2
        isParamsValid: true
    }
    {
        isSolo: false
        noCatch: false
        funcName: "FullColdStartWithProfilesMatcher_matches_a_numeric_value"
        isIgnored: false
        isAsync: false
        asyncTimeout: 2000
        slow: 75
        isParamTest: true
        name: "matches a numeric value"
        lineNumber: 14
        paramLineNumber: 12
        assertIndex: 0
        rawParams: [
            10.23 ' <-- missing #
            "Double"
        ]
        paramTestIndex: 1
        expectedNumberOfParams: 2
        isParamsValid: true
    }
    {
        isSolo: false
        noCatch: false
        funcName: "FullColdStartWithProfilesMatcher_matches_a_numeric_value"
        isIgnored: false
        isAsync: false
        asyncTimeout: 2000
        slow: 75
        isParamTest: true
        name: "matches a numeric value"
        lineNumber: 14
        paramLineNumber: 13
        assertIndex: 0
        rawParams: [
            10 ' <-- missing &
            "LongInteger"
        ]
        paramTestIndex: 2
        expectedNumberOfParams: 2
        isParamsValid: true
    }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions