main.test.tsimport { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
Deno.test('example', () => {
assertEquals(1, "1")
})
deno test main.test.tsExpected compile error, because number 1 does not equals to string "1" as they have different types.
No compile error, but instead got assertion failed error after test run finished.
assertEquals is a runtime assertion so coercion and unknown types has to be allowed.
@caspervonb So are you saying that there are cases where user will want to use assertEqual on two values that has different types?
I know there are certain cases where user wants to compare value with two different types, for example Uint8Array and number[], but is this really common?
But I believe most of the time user will compare values that have the same types.
Sorry that I beg to differ on this, but having function like this seems to defeat the purpose of having Typescript built into Deno.
If you're looking for example where assertEquals forces user to compare only values of the same type, here is one (http://hackage.haskell.org/package/HUnit-1.6.0.0/docs/Test-HUnit-Base.html#v:-126--63--61-)
@wongjiahau but in both deno and haskell a == b and assertEquals(a, b) are typed consistently, this issue/your PR breaks the consistency.
In fact, having assert(a == b) and assertEquals(a, b) behave differently is surely strictly worse for testing than avoiding a needless comparison of two differently typed things.
@actual-size what do you mean when you say "typed consistently"?
Most helpful comment
assertEquals is a runtime assertion so coercion and unknown types has to be allowed.