2021-11-29 14:32:29 +01:00
|
|
|
module promise
|
|
|
|
|
2021-11-25 15:49:53 +01:00
|
|
|
fn test_promise() {
|
|
|
|
// TODO: For some reason compiler errors: "error: unknown function: js.promise.new", fix this
|
|
|
|
/*
|
2021-11-29 14:32:29 +01:00
|
|
|
p := new<int, f64>(fn (resolve_ fn (x int), reject_ fn (x f64)) {
|
2021-11-25 15:49:53 +01:00
|
|
|
println('Promise code')
|
|
|
|
assert true
|
|
|
|
resolve_(42)
|
|
|
|
})
|
|
|
|
p.then(fn (val int) {
|
|
|
|
println('resolved')
|
|
|
|
assert val == 42
|
|
|
|
}, fn (fail f64) {
|
|
|
|
println('rejected')
|
|
|
|
assert false
|
|
|
|
})*/
|
|
|
|
}
|