Skip to content

Commit

Permalink
Run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Feb 12, 2024
1 parent e1ec6d0 commit 0350242
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
- uses: actions/checkout@v3
- uses: erlef/setup-beam@v1
with:
otp-version: "26.1"
gleam-version: "0.32.4"
otp-version: "26.2"
gleam-version: "1.0.0-rc1"
rebar3-version: "3"
- run: gleam test
- run: gleam format --check src test
43 changes: 20 additions & 23 deletions test/gleam/otp/actor_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -149,30 +149,27 @@ type ActorMessage {

pub fn replace_selector_test() {
let assert Ok(subject) =
actor.start(
"init",
fn(msg: ActorMessage, state) {
case msg {
UserMessage(string) -> actor.continue("user message: " <> string)
Unknown(val) ->
actor.continue("unknown message: " <> dynamic.classify(val))
SetStringSelector(reply, mapper) -> {
let #(subject, selector) = mapped_selector(mapper)
process.send(reply, subject)

actor.continue(state)
|> actor.with_selector(selector)
}
SetIntSelector(reply, mapper) -> {
let #(subject, selector) = mapped_selector(mapper)
process.send(reply, subject)

actor.continue(state)
|> actor.with_selector(selector)
}
actor.start("init", fn(msg: ActorMessage, state) {
case msg {
UserMessage(string) -> actor.continue("user message: " <> string)
Unknown(val) ->
actor.continue("unknown message: " <> dynamic.classify(val))
SetStringSelector(reply, mapper) -> {
let #(subject, selector) = mapped_selector(mapper)
process.send(reply, subject)

actor.continue(state)
|> actor.with_selector(selector)
}
},
)
SetIntSelector(reply, mapper) -> {
let #(subject, selector) = mapped_selector(mapper)
process.send(reply, subject)

actor.continue(state)
|> actor.with_selector(selector)
}
}
})

// Send initial user message to original subject
process.send(subject, UserMessage("test 1"))
Expand Down
42 changes: 23 additions & 19 deletions test/gleam/otp/supervisor_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,36 @@ pub fn supervisor_test() {
// initialisation so that we can tell they (re)started
let child =
worker(fn(name) {
actor.start_spec(actor.Spec(
init: fn() {
process.send(subject, #(name, process.self()))
actor.Ready(name, process.new_selector())
},
init_timeout: 10,
loop: fn(_msg, state) { actor.continue(state) },
))
actor.start_spec(
actor.Spec(
init: fn() {
process.send(subject, #(name, process.self()))
actor.Ready(name, process.new_selector())
},
init_timeout: 10,
loop: fn(_msg, state) { actor.continue(state) },
),
)
})

// Each child returns the next name, which is their name + 1
let child =
child
|> returning(fn(name, _subject) { name + 1 })

supervisor.start_spec(supervisor.Spec(
argument: 1,
frequency_period: 1,
max_frequency: 5,
init: fn(children) {
children
|> add(child)
|> add(child)
|> add(child)
},
))
supervisor.start_spec(
supervisor.Spec(
argument: 1,
frequency_period: 1,
max_frequency: 5,
init: fn(children) {
children
|> add(child)
|> add(child)
|> add(child)
},
),
)
|> should.be_ok

// Assert children have started
Expand Down

0 comments on commit 0350242

Please sign in to comment.