roc icon indicating copy to clipboard operation
roc copied to clipboard

roc test and roc dev give different error msgs

Open lukewilliamboswell opened this issue 3 years ago • 0 comments

I'm not sure if this is an issue, but I though I would highlight it as I think it has been something that has tripped me up a few times. The following shows the different error message feedback I get from running roc test vice roc dev. I wonder if roc test should run roc check before running the tests?

The below error is that I have misspelled Str.toScalars which roc dev explains really clearly.

I am still learning the language so I have adopted a workflow where I read the docs to find a function that looks like it does what I need, then I write a smaller unit test to check my understanding, and take the feedback from the compiler errors to adjust.

app "aoc-2021-day-3"
    packages { pf: "cli-platform/main.roc" }
    imports [
        pf.Program.{ Program },
        pf.Stdout,
    ]
    provides [main] to pf

main : Program
main =
    Stdout.line "Hello World"
    |> Program.quick

sampleStr = "001100"
expect Str.toScalar sampleStr == ['0','0','1','1','0','0']
luke@192-168-1-108 roc-aoc-2021 % roc test sample2.roc
── EXPECT PANICKED ─────────────────────────────────────────────── sample2.roc ─

This expectation crashed while running:

15│  expect Str.toScalar sampleStr == ['0','0','1','1','0','0']
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The crash reported this message:

ValueNotExposed { module_name: ModuleName(IdentStr { string: "Str" }), ident: Ident(IdentStr { string: "toScalar" }), region: @266-278, exposed_values: ['isEmpty', 'concat', 'joinWith', 'split', 'countGraphemes', 'startsWith', 'endsWith', 'fromUtf8', 'toUtf8', 'startsWithScalar', 'fromUtf8Range', 'repeat', 'trim', 'trimLeft', 'trimRight', 'toDec', 'toF64', 'toF32', 'toNat', 'toU128', 'toI128', 'toU64', 'toI64', 'toU32', 'toI32', 'toU16', 'toI16', 'toU8', 'toI8', 'toScalars', 'getUnsafe', 'countUtf8Bytes', 'substringUnsafe', 'splitFirst', 'splitLast', 'walkUtf8WithIndex', 'reserve', 'appendScalarUnsafe', 'appendScalar', 'getScalarUnsafe', 'walkScalars', 'walkScalarsUntil', 'strToNum', 'fromUtf8RangeLowlevel', 'capacity', 'replaceEach', 'replaceFirst', 'replaceLast'] }

1 failed and 0 passed in 503 ms.
luke@192-168-1-108 roc-aoc-2021 % roc dev sample2.roc 

── NOT EXPOSED ─────────────────────────────────────────────────── sample2.roc ─

The Str module does not expose `toScalar`:

15│  expect Str.toScalar sampleStr == ['0','0','1','1','0','0']
            ^^^^^^^^^^^^

Did you mean one of these?

    Str.toScalars
    Str.concat
    Str.toNat
    Str.walkScalars

────────────────────────────────────────────────────────────────────────────────

1 error and 0 warnings found in 13 ms.

You can run the program anyway with roc run sample2.roc

lukewilliamboswell avatar Oct 07 '22 23:10 lukewilliamboswell