Skip to content

Instantly share code, notes, and snippets.

@pocketberserker
Created May 18, 2016 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pocketberserker/68a53c3d45103abee9d989333985b224 to your computer and use it in GitHub Desktop.
Save pocketberserker/68a53c3d45103abee9d989333985b224 to your computer and use it in GitHub Desktop.
module AssertionTest
open Persimmon
open UseTestNameByReflection
type TestRecord = {
A: string
}
type TestDU =
| A
| B of int
| C of int * int
| D of value : string
let ``fail primitive value`` = test {
do!
Assert.equals 0 1
}
let ``fail diff string`` = test {
do!
Assert.equals "a" "b"
}
let ``fail diff record value`` = test {
do!
Assert.equals { A = "a" } { A = "b" }
}
let ``fail diff list`` = parameterize {
source [
([], [0])
([0], [2])
([0; 1; 3], [0; 2; 3])
]
run (fun (expected, actual) -> test {
do!
Assert.equals expected actual
})
}
let ``fail diff DU`` = parameterize {
source [
(A, B 0)
(B 0, B 1)
(C(0, 1), C(0, 2))
(D "a", D "b")
]
run (fun (expected, actual) -> test {
do!
Assert.equals expected actual
})
}
Assertion Violated: fail primitive value
1. /
- 0
+ 1
Assertion Violated: fail diff string
1. /
- a
+ b
Assertion Violated: fail diff record value
1. /A
- a
+ b
Assertion Violated: fail diff list([], [0])
1. /[0]
+ 0
Assertion Violated: fail diff list([0], [2])
1. /[2]
+ 2
/[0]
- 0
Assertion Violated: fail diff list([0; 1; 3], [0; 2; 3])
1. /[2]
+ 2
/[1]
- 1
Assertion Violated: fail diff DU(A, B(0))
1. /Tag
- 0
+ 1
/IsA
- True
+ False
/IsB
- False
+ True
Assertion Violated: fail diff DU(B(0), B(1))
1. /Item
- 0
+ 1
Assertion Violated: fail diff DU(C(0, 1), C(0, 2))
1. /Item2
- 1
+ 2
Assertion Violated: fail diff DU(D("a"), D("b"))
1. /value
- a
+ b
@pocketberserker
Copy link
Author

  • コレクション
    • 要素はパスでは[要素]と表示される。indexではないので注意。
  • 判別共用体
    • コンストラクタ不一致の場合はTagプロパティが差分となる
    • アイテムに名前を付けない場合はItemプロパティがdiff表示になる

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment