Skip to content

Commit d43314f

Browse files
committed
remove deprecated ref cells
1 parent 7255ada commit d43314f

File tree

5 files changed

+193
-265
lines changed

5 files changed

+193
-265
lines changed

tests/FsToolkit.ErrorHandling.JobResult.Tests/JobResult.fs

Lines changed: 48 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -500,31 +500,28 @@ let teeTests =
500500
testList "JobResult.tee Tests" [
501501
testCase "tee executes the function for ok"
502502
<| fun _ ->
503-
let foo = ref "foo"
504-
let input = ref 0
503+
let mutable foo = "foo"
504+
let mutable input = 0
505505

506506
let bar x =
507-
input := x
507+
input <- x
508508

509-
foo
510-
:= "bar"
509+
foo <- "bar"
511510

512511
let result = JobResult.tee bar (toJob (Ok 42))
513512
Expect.hasJobOkValueSync 42 result
514-
Expect.equal !foo "bar" ""
515-
Expect.equal !input 42 ""
513+
Expect.equal foo "bar" ""
514+
Expect.equal input 42 ""
516515

517516
testCase "tee ignores the function for Error"
518517
<| fun _ ->
519-
let foo = ref "foo"
518+
let mutable foo = "foo"
520519

521-
let bar _ =
522-
foo
523-
:= "bar"
520+
let bar _ = foo <- "bar"
524521

525522
let result = JobResult.tee bar (toJob (Error err))
526523
Expect.hasJobErrorValueSync err result
527-
Expect.equal !foo "foo" ""
524+
Expect.equal foo "foo" ""
528525
]
529526

530527
let returnTrue _ = true
@@ -535,54 +532,48 @@ let teeIfTests =
535532
testList "JobResult.teeIf Tests" [
536533
testCase "teeIf executes the function for ok and true predicate "
537534
<| fun _ ->
538-
let foo = ref "foo"
539-
let input = ref 0
540-
let pInput = ref 0
535+
let mutable foo = "foo"
536+
let mutable input = 0
537+
let mutable pInput = 0
541538

542539
let returnTrue x =
543-
pInput
544-
:= x
540+
pInput <- x
545541

546542
true
547543

548544
let bar x =
549-
input := x
545+
input <- x
550546

551-
foo
552-
:= "bar"
547+
foo <- "bar"
553548

554549
let result = JobResult.teeIf returnTrue bar (toJob (Ok 42))
555550

556551
Expect.hasJobOkValueSync 42 result
557-
Expect.equal !foo "bar" ""
558-
Expect.equal !input 42 ""
559-
Expect.equal !pInput 42 ""
552+
Expect.equal foo "bar" ""
553+
Expect.equal input 42 ""
554+
Expect.equal pInput 42 ""
560555

561556
testCase "teeIf ignores the function for Ok and false predicate"
562557
<| fun _ ->
563-
let foo = ref "foo"
558+
let mutable foo = "foo"
564559

565-
let bar _ =
566-
foo
567-
:= "bar"
560+
let bar _ = foo <- "bar"
568561

569562
let result = JobResult.teeIf returnFalse bar (toJob (Ok 42))
570563

571564
Expect.hasJobOkValueSync 42 result
572-
Expect.equal !foo "foo" ""
565+
Expect.equal foo "foo" ""
573566

574567
testCase "teeIf ignores the function for Error"
575568
<| fun _ ->
576-
let foo = ref "foo"
569+
let mutable foo = "foo"
577570

578-
let bar _ =
579-
foo
580-
:= "bar"
571+
let bar _ = foo <- "bar"
581572

582573
let result = JobResult.teeIf returnTrue bar (toJob (Error err))
583574

584575
Expect.hasJobErrorValueSync err result
585-
Expect.equal !foo "foo" ""
576+
Expect.equal foo "foo" ""
586577
]
587578

588579
[<Tests>]
@@ -591,32 +582,29 @@ let teeErrorTests =
591582
testList "JobResult.teeError Tests" [
592583
testCase "teeError executes the function for Error"
593584
<| fun _ ->
594-
let foo = ref "foo"
595-
let input = ref ""
585+
let mutable foo = "foo"
586+
let mutable input = ""
596587

597588
let bar x =
598-
input := x
589+
input <- x
599590

600-
foo
601-
:= "bar"
591+
foo <- "bar"
602592

603593
let result = JobResult.teeError bar (toJob (Error err))
604594

605595
Expect.hasJobErrorValueSync err result
606-
Expect.equal !foo "bar" ""
607-
Expect.equal !input err ""
596+
Expect.equal foo "bar" ""
597+
Expect.equal input err ""
608598

609599
testCase "teeError ignores the function for Ok"
610600
<| fun _ ->
611-
let foo = ref "foo"
601+
let mutable foo = "foo"
612602

613-
let bar _ =
614-
foo
615-
:= "bar"
603+
let bar _ = foo <- "bar"
616604

617605
let result = JobResult.teeError bar (toJob (Ok 42))
618606
Expect.hasJobOkValueSync 42 result
619-
Expect.equal !foo "foo" ""
607+
Expect.equal foo "foo" ""
620608
]
621609

622610

@@ -625,54 +613,48 @@ let teeErrorIfTests =
625613
testList "JobResult.teeErrorIf Tests" [
626614
testCase "teeErrorIf executes the function for Error and true predicate "
627615
<| fun _ ->
628-
let foo = ref "foo"
629-
let input = ref ""
630-
let pInput = ref ""
616+
let mutable foo = "foo"
617+
let mutable input = ""
618+
let mutable pInput = ""
631619

632620
let returnTrue x =
633-
pInput
634-
:= x
621+
pInput <- x
635622

636623
true
637624

638625
let bar x =
639-
input := x
626+
input <- x
640627

641-
foo
642-
:= "bar"
628+
foo <- "bar"
643629

644630
let result = JobResult.teeErrorIf returnTrue bar (toJob (Error err))
645631

646632
Expect.hasJobErrorValueSync err result
647-
Expect.equal !foo "bar" ""
648-
Expect.equal !input err ""
649-
Expect.equal !pInput err ""
633+
Expect.equal foo "bar" ""
634+
Expect.equal input err ""
635+
Expect.equal pInput err ""
650636

651637
testCase "teeErrorIf ignores the function for Error and false predicate"
652638
<| fun _ ->
653-
let foo = ref "foo"
639+
let mutable foo = "foo"
654640

655-
let bar _ =
656-
foo
657-
:= "bar"
641+
let bar _ = foo <- "bar"
658642

659643
let result = JobResult.teeErrorIf returnFalse bar (toJob (Error err))
660644

661645
Expect.hasJobErrorValueSync err result
662-
Expect.equal !foo "foo" ""
646+
Expect.equal foo "foo" ""
663647

664648
testCase "teeErrorIf ignores the function for Ok"
665649
<| fun _ ->
666-
let foo = ref "foo"
650+
let mutable foo = "foo"
667651

668-
let bar _ =
669-
foo
670-
:= "bar"
652+
let bar _ = foo <- "bar"
671653

672654
let result = JobResult.teeErrorIf returnTrue bar (toJob (Ok 42))
673655

674656
Expect.hasJobOkValueSync 42 result
675-
Expect.equal !foo "foo" ""
657+
Expect.equal foo "foo" ""
676658
]
677659

678660
[<Tests>]

tests/FsToolkit.ErrorHandling.TaskResult.Tests/Expecto.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ let ftestCaseTask name test =
3636
module Expect =
3737
open Expecto
3838

39-
[<RequiresExplicitTypeArguments>]
4039
/// Expects the passed function to throw `'texn`.
40+
[<RequiresExplicitTypeArguments>]
4141
let throwsTAsync<'a, 'texn when 'texn :> exn> (f: Async<'a>) message = async {
4242
let! thrown = async {
4343
try

0 commit comments

Comments
 (0)