Skip to content

Commit

Permalink
test: reflect language changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sockmaster27 committed Nov 21, 2024
1 parent 5583124 commit 7e04baa
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions test/testWorkspaces/codeActions/src/Dividable.flix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ trait Dividable[t] {

mod Dividable {
// Unused effect
eff DivByZero{
pub def throw(): Void
eff DivByZero {
def raise(): Void
}
}
4 changes: 2 additions & 2 deletions test/testWorkspaces/findReferences/src/Dividable.flix.old
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Blank line
eff DivByZero {
pub def throw(): Void
def raise(): Void
}

trait Dividable[t] {
Expand All @@ -13,5 +13,5 @@ trait Dividable[t] {
instance Dividable[Int32] {
type Aef = DivByZero
pub def div(x: Int32, y: Int32): Int32 \ DivByZero =
if (y == 0) do DivByZero.throw() else x / y
if (y == 0) DivByZero.raise() else x / y
}
25 changes: 13 additions & 12 deletions test/testWorkspaces/goto/src/Rewind.flix
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Blank line

eff Rewind {
pub def save(label: String): Unit
def save(label: String): Unit
/// If you rewind to a non-saved label, it is like throwing an exception.
pub def rewind(label: String): Unit
def rewind(label: String): Unit
}

/// We want to find a number that is:
Expand All @@ -13,14 +13,15 @@ eff Rewind {
/// 4. not divisible by 3 (so not 0, 3, 6, 9, ...)
/// And we will this by guessing and retrying
def search(k: Int32): Int32 \ Rewind + IO = {
println("Beginning to search!");
let random = Random.freshWithSeed(123i64);
do Rewind.save("start");
let guess = Random.nextNatWithMax(random, k);
// 1. and 2. hold automatically
if (Int32.modulo(guess, 2) == 0) {println("retry for ${guess}"); do Rewind.rewind("start"); ?unreachable}
// now 3. holds
else if (Int32.modulo(guess, 3) == 0) {println("retry for ${guess}"); do Rewind.rewind("start"); ?unreachable}
// now 4. holds and we can return
else guess
Random.runWithSeed(123i64, _ -> {
println("Beginning to search!");
Rewind.save("start");
let guess = Int32.remainder(Random.randomInt32(), 5);
// 1. and 2. hold automatically
if (Int32.modulo(guess, 2) == 0) {println("retry for ${guess}"); Rewind.rewind("start"); ?unreachable}
// now 3. holds
else if (Int32.modulo(guess, 3) == 0) {println("retry for ${guess}"); Rewind.rewind("start"); ?unreachable}
// now 4. holds and we can return
else guess
})
}
4 changes: 2 additions & 2 deletions test/testWorkspaces/highlight/src/Dividable.flix.old
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Blank line
eff DivByZero {
pub def throw(): Void
def raise(): Void
}

trait Dividable[t] {
Expand All @@ -13,5 +13,5 @@ trait Dividable[t] {
instance Dividable[Int32] {
type Aef = DivByZero
pub def div(x: Int32, y: Int32): Int32 \ DivByZero =
if (y == 0) do DivByZero.throw() else x / y
if (y == 0) DivByZero.raise() else x / y
}
4 changes: 2 additions & 2 deletions test/testWorkspaces/implementation/src/Dividable.flix.old
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Blank line
eff DivByZero {
pub def throw(): Void
def raise(): Void
}

trait Dividable[t] {
Expand All @@ -13,5 +13,5 @@ trait Dividable[t] {
instance Dividable[Int32] {
type Aef = DivByZero
pub def div(x: Int32, y: Int32): Int32 \ DivByZero =
if (y == 0) do DivByZero.throw() else x / y
if (y == 0) DivByZero.raise() else x / y
}

0 comments on commit 7e04baa

Please sign in to comment.