stacktrace test

This commit is contained in:
Vyacheslav Matyukhin 2022-10-05 18:07:37 +04:00
parent 2d0e6432cd
commit 8cbbdf5489
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C

View File

@ -78,3 +78,33 @@ describe("test exceptions", () => {
// "Error(TODO: unhandled rescript exception)", // "Error(TODO: unhandled rescript exception)",
// ) // )
}) })
describe("stacktraces", () => {
test("nested calls", () => {
open Expect
let error =
Expression.BackCompatible.evaluateString(`
f(x) = {
y = "a"
x + y
}
g = {|x| f(x)}
h(x) = g(x)
h(5)
`)
->E.R.getError
->E.O2.toExn("oops")
->SqError.toStringWithStackTrace
expect(
error,
)->toBe(`Error: There are function matches for add(), but with different arguments: [add(number, number)]; [add(distribution, number)]; [add(number, distribution)]; [add(distribution, distribution)]; [add(date, duration)]; [add(duration, duration)]
Stack trace:
f at line 4, column 5
<anonymous> at line 6, column 12
h at line 7, column 10
<top> at line 8, column 3
`)
})
})