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
37 changes: 25 additions & 12 deletions __tests__/expect_vitest.res
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,32 @@ let () = {
test("expectFn", () => expectFn(throw, Invalid_argument("foo"))->toThrow)
})

// describe("Expect.Operators", () => {
// open Expect
// open! Expect.Operators
describe("Expect.Operators", () => {
open Expect
open! Expect.Operators

let r1 = {"foo": "bar"}

// test("==", () => expect(1 + 2) === 3)
// test(">", () => expect(4) > 3)
// test(">=", () => expect(4) >= 4)
// test("<", () => expect(4) < 5)
// test("<=", () => expect(4) <= 4)
// test("=", () => expect(1 + 2) == 3)
// test("<>", () => expect(1 + 2) != 4)
// test("!=", () => expect(1 + 2) !== 4)
// })
"==="->describe(() => {
test("int", () => expect(1 + 2) === 3)
test("string", () => expect("foo") === "foo")
test("same record", () => expect(r1) === r1)
})
"!=="->describe(() => {
test("int", () => expect(1 + 2) !== 4)
test("equal record", () => expect(r1) !== {"foo": "bar"})
})
"=="->describe(() => {
test("int", () => expect(1 + 2) == 3)
test("string", () => expect("foo") == "foo")
test("record", () => expect(r1) == {"foo": "bar"})
})
test(">", () => expect(4) > 3)
test(">=", () => expect(4) >= 4)
test("<", () => expect(4) < 5)
test("<=", () => expect(4) <= 4)
test("!=", () => expect(1 + 2) != 4)
})

describe("ExpectJs", () => {
open ExpectJs
Expand Down
29 changes: 12 additions & 17 deletions src/Vitest.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@send external then: (promise<'a>, @uncurry 'a => promise<'b>) => promise<'b> = "then"
@send external then: (promise<'a>, @uncurry ('a => promise<'b>)) => promise<'b> = "then"
module Promise = Js.Promise

type modifier<'a> = [
Expand All @@ -15,7 +15,6 @@ let mapMod = (f, x) =>
type rec assertion =
| Ok: assertion
| Fail(string): assertion

| ArrayContains(modifier<(array<'a>, 'a)>): assertion
| ArrayContainsEqual(modifier<(array<'a>, 'a)>): assertion
| ArrayLength(modifier<(array<'a>, int)>): assertion
Expand All @@ -30,14 +29,11 @@ type rec assertion =
| LessThanOrEqual(modifier<('a, 'a)>): assertion
| StringContains(modifier<(string, string)>): assertion
| StringMatch(modifier<(string, Js.Re.t)>): assertion

| Throws(modifier<unit => _>): assertion

| MatchInlineSnapshot(_, string): assertion
| MatchSnapshot(_): assertion
| MatchSnapshotName(_, string): assertion
| ThrowsMatchSnapshot(unit => _): assertion

/* JS */
| Defined(modifier<Js.undefined<'a>>): assertion
| Falsy(modifier<'a>): assertion
Expand Down Expand Up @@ -343,18 +339,17 @@ module Expect = {
let not_ = (#Just(a)) => #Not(a)
let not__ = not_ /* For Reason syntax compatibility. TODO: deprecate and remove */

// module Operators = {
// @@ocaml.text(" experimental ")

// let \"==" = (a, b) => toBe(a, b)
// let \">" = (a, b) => toBeGreaterThan(a, b)
// let \">=" = (a, b) => toBeGreaterThanOrEqual(a, b)
// let \"<" = (a, b) => toBeLessThan(a, b)
// let \"<=" = (a, b) => toBeLessThanOrEqual(a, b)
// let \"=" = (a, b) => toEqual(a, b)
// let \"<>" = (a, b) => a->not_->toEqual(b)
// let \"!=" = (a, b) => a->not_->toBe(b)
// }
module Operators = {
let \"===" = (a, b) => a->toBe(b)
let \">" = (a, b) => toBeGreaterThan(a, b)
let \">=" = (a, b) => toBeGreaterThanOrEqual(a, b)
let \"<" = (a, b) => toBeLessThan(a, b)
let \"<=" = (a, b) => toBeLessThanOrEqual(a, b)
let \"==" = (a, b) => toEqual(a, b)
let \"<>" = (a, b) => a->not_->toEqual(b)
let \"!=" = (a, b) => a->not_->toEqual(b)
let \"!==" = (a, b) => a->not_->toBe(b)
}
}

module ExpectJs = {
Expand Down
25 changes: 13 additions & 12 deletions src/Vitest.resi
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,19 @@ module Expect: {
let not_: plainPartial<'a> => invertedPartial<'a>
let not__: plainPartial<'a> => invertedPartial<'a>

// module Operators: {
// @@ocaml.text(" experimental ")

// let \"==": ([< partial<'a>], 'a) => assertion
// let \">": ([< partial<'a>], 'a) => assertion
// let \">=": ([< partial<'a>], 'a) => assertion
// let \"<": ([< partial<'a>], 'a) => assertion
// let \"<=": ([< partial<'a>], 'a) => assertion
// let \"=": ([< partial<'a>], 'a) => assertion
// let \"<>": (plainPartial<'a>, 'a) => assertion
// let \"!=": (plainPartial<'a>, 'a) => assertion
// }
module Operators: {
@@ocaml.text(" experimental ")

let \"===": ([< partial<'a>], 'a) => assertion
let \">": ([< partial<'a>], 'a) => assertion
let \">=": ([< partial<'a>], 'a) => assertion
let \"<": ([< partial<'a>], 'a) => assertion
let \"<=": ([< partial<'a>], 'a) => assertion
let \"==": ([< partial<'a>], 'a) => assertion
let \"<>": (plainPartial<'a>, 'a) => assertion
let \"!=": (plainPartial<'a>, 'a) => assertion
let \"!==": (plainPartial<'a>, 'a) => assertion
}
}

module ExpectJs: {
Expand Down