Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:

- name: Set up PureScript toolchain
uses: purescript-contrib/setup-purescript@main
with:
purs-tidy: "latest"

- name: Cache PureScript dependencies
uses: actions/cache@v2
Expand All @@ -25,9 +27,9 @@ jobs:
output

- name: Set up Node toolchain
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: "12.x"
node-version: "14.x"

- name: Cache NPM dependencies
uses: actions/cache@v2
Expand All @@ -49,3 +51,6 @@ jobs:

- name: Run tests
run: npm run test

- name: Check formatting
run: purs-tidy check src test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
!.gitignore
!.github
!.editorconfig
!.tidyrc.json
!.eslintrc.json

output
Expand Down
10 changes: 10 additions & 0 deletions .tidyrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"importSort": "source",
"importWrap": "source",
"indent": 2,
"operatorsFile": null,
"ribbon": 1,
"typeArrowPlacement": "first",
"unicode": "never",
"width": null
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ New features:
Bugfixes:

Other improvements:
- Added `purs-tidy` formatter (#25 by @thomashoneyman)

## [v5.0.0](https://github.com/purescript-contrib/purescript-js-timers/releases/tag/v5.0.0) - 2021-02-26

Expand Down
102 changes: 51 additions & 51 deletions test/Main.purs
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
module Test.Main where
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I...don't really know what's going on with this diff. As far as I can tell nothing changed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just ignored these when I've seen them.


import Prelude

import Effect (Effect)
import Effect.Console as C
import Effect.Ref as R
import Effect.Timer as T
import Test.Assert (assert)

main :: Effect Unit
main = do
counter <- R.new 0

void $ T.setTimeout 10 do
C.log "timeout increment counter"
void $ R.modify (_ + 1) counter

void $ T.setTimeout 50 do
C.log "timeout check counter"
n <- R.read counter
assert $ n == 1

void $ T.setTimeout 100 do

t <- T.setTimeout 20 do
void $ R.modify (_ + 1) counter

T.clearTimeout t

void $ T.setTimeout 50 do
C.log "check timeout never ran"
n <- R.read counter
assert $ n == 1

void $ T.setTimeout 200 do

i <- T.setInterval 20 do
C.log "interval increment counter"
void $ R.modify (_ + 1) counter

void $ T.setTimeout 90 do
T.clearInterval i
C.log "interval check counter"
n <- R.read counter
assert $ n == 5

void $ T.setTimeout 150 do
C.log "check interval has stopped"
n <- R.read counter
assert $ n == 5
module Test.Main where

import Prelude

import Effect (Effect)
import Effect.Console as C
import Effect.Ref as R
import Effect.Timer as T
import Test.Assert (assert)

main :: Effect Unit
main = do
counter <- R.new 0

void $ T.setTimeout 10 do
C.log "timeout increment counter"
void $ R.modify (_ + 1) counter

void $ T.setTimeout 50 do
C.log "timeout check counter"
n <- R.read counter
assert $ n == 1

void $ T.setTimeout 100 do

t <- T.setTimeout 20 do
void $ R.modify (_ + 1) counter

T.clearTimeout t

void $ T.setTimeout 50 do
C.log "check timeout never ran"
n <- R.read counter
assert $ n == 1

void $ T.setTimeout 200 do

i <- T.setInterval 20 do
C.log "interval increment counter"
void $ R.modify (_ + 1) counter

void $ T.setTimeout 90 do
T.clearInterval i
C.log "interval check counter"
n <- R.read counter
assert $ n == 5

void $ T.setTimeout 150 do
C.log "check interval has stopped"
n <- R.read counter
assert $ n == 5