Browse files

therie: improved expectation system

* no more 'should' methods added to Object, no more 'should:' macro
* `a should-be(b)` -> `expect(a) to be(b)`
* `{ a } should-raise(x)` -> `expect { a } to raise(x)`
* RSpec-like 'matcher' system
  * failure messages defined on proper structures
  * bonus: matcher methods are also not globalized; defined on ExpectTo class
  * bonus: no reason we can't have operator methods; same semantics
    * e.g. `expect(a) to == b` would just be an alias for `ExpectTo#be`
  • Loading branch information...
1 parent b0dac9b commit 4f0ee89e305ae15aec8645f2a36de943ef3ec4d1 @vito committed Mar 11, 2013
Showing with 406 additions and 338 deletions.
  1. +8 −0 kernel/data.ay
  2. +76 −22 kernel/therie.ay
  3. +34 −33 test/suite/blocks.ay
  4. +26 −21 test/suite/conditions.ay
  5. +45 −45 test/suite/definitions.ay
  6. +101 −104 test/suite/format.ay
  7. +38 −38 test/suite/macros.ay
  8. +19 −16 test/suite/patterns.ay
  9. +16 −16 test/suite/quotes.ay
  10. +23 −23 test/suite/scope.ay
  11. +12 −12 test/suite/super.ay
  12. +8 −8 test/suite/therie.ay
View
8 kernel/data.ay
@@ -1,3 +1,11 @@
+-- TODO: make this work:
+--
+-- module:
+-- data(A(@x))
+-- A(x) foo := x
+--
+-- right now pattern definitions can only be at the toplevel
+
use("core")
use("define")
use("control-flow")
View
98 kernel/therie.ay
@@ -1,7 +1,6 @@
use("atomy")
io = require("io")
-condition = require("condition")
nesting-level = dynamic(0)
running-stats = dynamic
@@ -102,36 +101,91 @@ it(description) &tests := do:
nil
-macro(~x should ~(check: Block)):
- `(unless(~x onto ~check):
- raise(f"assertion failed for %v" ['~x]))
+data(Actuality(@value = nil, @action = nil))
+expect(value) := Actuality new(value)
+expect &action := Actuality new(nil, action)
-x should-be(y) :=
- unless(x == y):
- raise(f"expected %v, got %v" [y, x])
+Actuality to := ExpectTo new(self)
+Actuality to-not := ExpectTo new(self, true)
-x should-raise(y) :=
- x rescue {
- e ->
- unless(e kind-of(y)?):
- raise(f"expected exception %s, got: %s" [y, e class])
- } else:
- raise("#should-raise - no exception raised")
+data(ExpectTo(@actual, @negated? = false))
+
+ExpectTo(actual, negated) match(matcher) := do:
+ matched = matcher matches?(actual)
+
+ condition:
+ negated and matched ->
+ /raise(matcher negative-failure-message(actual))
+
+ negated and not matched ->
+ true
+
+ not matched ->
+ /raise(matcher failure-message(actual))
+
+ negated -> true
@vito
Owner
vito added a note Mar 11, 2013

Bug; should be 'otherwise'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+data(Matcher)
-x should-error(y) :=
- { with-restarts(errored -> nil):
- x call
- raise("#should-error - no error signaled")
+Matcher matches(actual)? := /error(.not-implemented)
+Matcher failure-message(actual) := /error(.not-implemented)
+Matcher negative-failure-message(actual) := /error(.not-implemented)
+
+Matcher data: EqualityMatcher(@value)
+ExpectTo be(value) := match(EqualityMatcher new(value))
+EqualityMatcher(value) matches(actual)? := actual value == value
+EqualityMatcher(value) failure-message(actual) :=
+ i"expected #{actual value} to be #{value}"
+EqualityMatcher(value) negative-failure-message(actual) :=
+ i"expected #{actual value} to not be #{value}, but it was"
+
+
+Matcher data: RaiseMatcher(@exception, @message = nil)
+ExpectTo raise(exception, message = nil) :=
+ match(RaiseMatcher new(exception, message))
+RaiseMatcher matches(actual)? :=
+ actual action rescue {
+ e:
+ @raised = e
+ @raised is-a(@exception)?
+ } else: false
+RaiseMatcher failure-message(actual) :=
+ if(@raised)
+ then: i"expected #{@exception}, got #{@raised class}: #{@raised}"
+ else: i"expected #{@exception} but nothing was raised"
+RaiseMatcher negative-failure-message(actual) :=
+ i"expected #{@exception} to not be raised, but it was"
+
+
+Matcher data: ErrorMatcher(@error)
+ExpectTo error(error) := match(ErrorMatcher new(error))
+ErrorMatcher matches(actual)? :=
+ { with-restarts(errored(matched?) -> matched?):
+ actual action call
+ false
} bind {
(e: ExceptionError) ->
raise(e exception)
(e: Error):
- when(e kind-of(y)?):
- condition restart(.errored)
-
- raise(f"expected error %s, got: %s" [y, e message])
+ @errored = e
+ /restart(.errored, e kind-of(@error)?)
}
+ErrorMatcher failure-message(actual) :=
+ if(@errored)
+ then: i"expected #{@error}, got #{@errored class}: #{@errored}"
+ else: i"expected #{@error} but nothing was signalled"
+ErrorMatcher negative-failure-message(actual) :=
+ i"expected #{@error} to not be signalled, but it was"
+
+
+Matcher data: KindMatcher(@class)
+ExpectTo be-a(class) := match(KindMatcher new(class))
+KindMatcher matches(actual)? := actual value is-a?(@class)
+KindMatcher failure-message(actual) :=
+ i"expected #{actual value} (#{actual value class}) to be a #{@class}"
+KindMatcher negative-failure-message(actual) :=
+ i"expected #{actual value} (#{actual value class}) to not be a #{@class}, but it was"
View
67 test/suite/blocks.ay
@@ -6,80 +6,81 @@ describe("blocks"):
describe(.call):
it("evaluates with the block's context available"):
a = 1
- { a + 1 } call should-be(2)
+ expect({ a + 1 } call) to be(2)
it("introduces a new locals environment"):
a = 1
- { a = 2, a } call should-be(2)
- a should-be(1)
+ expect({ a = 2, a } call) to be(2)
+ expect(a) to be(1)
it("does not leak argument bindings into the block's context"):
[a] { a + 1 } call(1)
- { a } should-raise(NameError)
+ expect { a } to raise(NameError)
it("is lexically scoped"):
a = 1
foo(b, a) := b call
- foo({ a }, 2) should-be(1)
+ expect(foo({ a }, 2)) to be(1)
describe("arguments"):
it("errors if too few given"):
- { 1 } call should-be(1)
- [a] { a } call(2) should-be(2)
- [a, b] { a + b } call(1, 2) should-be(3)
+ expect({ 1 } call) to be(1)
+ expect([a] { a } call(2)) to be(2)
+ expect([a, b] { a + b } call(1, 2)) to be(3)
- { [a] { a } call } should-raise(ArgumentError)
- { [a, b] { a } call(1) } should-raise(ArgumentError)
+ expect { [a] { a } call } to raise(ArgumentError)
+ expect { [a, b] { a } call(1) } to raise(ArgumentError)
it("errors if too many given"):
- { { 1 } call(2) should-be(1) } should-raise(ArgumentError)
- { { 1 } call(2, 3) should-be(1) } should-raise(ArgumentError)
+ expect { { 1 } call(2) } to raise(ArgumentError)
+ expect { { 1 } call(2, 3) } to raise(ArgumentError)
it("ignores extras if used as a proc-arg"):
caller &x := x call(1)
- caller: 42; should-be(42)
- caller [x]: x + 2; should-be(3)
+ expect(caller: 42) to be(42)
+ expect(caller [x]: x + 2) to be(3)
describe("block"):
it("binds a block argument"):
- &x { x call } call { 1 } should-be(1)
+ expect(&x { x call } call { 1 }) to be(1)
it("binds as nil if no block given"):
- &x { x } call should-be(nil)
+ expect(&x { x } call) to be(nil)
it("works with arguments before it"):
- [a] &x { x call(a) } call(2) [a] { a + 1 } should-be(3)
+ expect([a] &x { x call(a) } call(2) [a] { a + 1 }) to be(3)
it("fails with arguments after it"):
- { [&x, a] { x call(a) } call(2) [a] { a + 1 }
- } should-raise(ArgumentError)
+ expect {
+ [&x, a] { x call(a) } call(2) [a] { a + 1 }
+ } to raise(ArgumentError)
describe("splat"):
it("consumes the rest of the arguments"):
foo = [*xs]: xs
- foo call should-be([])
- foo call(1) should-be([1])
- foo call(1, 2) should-be([1, 2])
+ expect(foo call) to be([])
+ expect(foo call(1)) to be([1])
+ expect(foo call(1, 2)) to be([1, 2])
it("starts after required args"):
foo = [a, *bs]: [a, bs]
- { foo call } should-raise(ArgumentError)
- foo call(1) should-be([1, []])
- foo call(1, 2) should-be([1, [2]])
- foo call(1, 2, 3) should-be([1, [2, 3]])
+ expect { foo call } to raise(ArgumentError)
+ expect(foo call(1)) to be([1, []])
+ expect(foo call(1, 2)) to be([1, [2]])
+ expect(foo call(1, 2, 3)) to be([1, [2, 3]])
it("appears before a block arg"):
foo = [a, *bs] &c: [a, bs, c]
x = {}
- { foo call } should-raise(ArgumentError)
+ expect { foo call } to raise(ArgumentError)
res = foo call(1) &x
- res at(0) should-be(1)
- res at(1) should-be([])
- res at(2) should: kind-of(Proc)?
+ expect(res at(0)) to be(1)
+ expect(res at(1)) to be([])
+ expect(res at(2)) to be-a(Proc)
res = foo call(1, 2, 3) &x
- res at(0) should-be(1)
- res at(1) should-be([2, 3])
- res at(2) should: kind-of(Proc)?
+ expect(res at(0)) to be(1)
+ expect(res at(1)) to be([2, 3])
+ expect(res at(2)) to be-a(Proc)
-- TODO: default, post-args
View
47 test/suite/conditions.ay
@@ -12,12 +12,12 @@ describe("condition"):
it("triggers matching handlers"):
x = 0
{ signal(.foo) } bind: .foo -> (x =! 1)
- x should-be(1)
+ expect(x) to be(1)
it("does not trigger non-matching handlers"):
x = 0
{ signal(.foo) } bind: .bar -> (x =! 1)
- x should-be(0)
+ expect(x) to be(0)
it("goes through all handlers, nearest-first"):
x = []
@@ -26,7 +26,7 @@ describe("condition"):
} bind:
.foo -> x << 2
- x should-be([1, 2])
+ expect(x) to be([1, 2])
it("does not trigger active handlers"):
a = 0
@@ -36,29 +36,34 @@ describe("condition"):
when(a < 2):
signal(.bar)
- a should-be(1)
+ expect(a) to be(1)
describe(.restart):
it("calls a named restart"):
- { with-restarts(ok -> 1):
- signal(.foo)
- 0
- } bind: .foo -> restart(.ok);
- should-be(1)
+ res =
+ { with-restarts(ok -> 1):
+ signal(.foo)
+ 0
+ } bind: .foo -> restart(.ok)
+
+ expect(res) to be(1)
it("fails for an unknown restart name"):
- { { with-restarts(ok -> 1):
+ expect {
+ { with-restarts(ok -> 1):
signal(.foo)
0
} bind: .foo -> restart(.not-ok)
- } should-error(NoRestartError)
+ } to error(NoRestartError)
it("can send arguments to the restart"):
- { with-restarts(ok(x) -> x + 1):
- signal(.foo)
- 0
- } bind: .foo -> restart(.ok, 41);
- should-be(42)
+ res =
+ { with-restarts(ok(x) -> x + 1):
+ signal(.foo)
+ 0
+ } bind: .foo -> restart(.ok, 41)
+
+ expect(res) to be(42)
it("may be nested"):
a = []
@@ -71,17 +76,17 @@ describe("condition"):
raise("outer: should be unreachable")
- a should-be([1, 2])
- r2 should-be(42)
+ expect(a) to be([1, 2])
+ expect(r2) to be(42)
a << 4
5
} bind:
.foo -> do:
a << 1
restart(.use-value, 42)
- a should-be([1, 2, 4])
- r should-be(5)
+ expect(a) to be([1, 2, 4])
+ expect(r) to be(5)
it("calls the nearest restart if more than one have the same name"):
res =
@@ -94,4 +99,4 @@ describe("condition"):
} bind:
.foo -> restart(.a, 0)
- res should-be([0, 2])
+ expect(res) to be([0, 2])
View
90 test/suite/definitions.ay
@@ -14,138 +14,138 @@ describe("definitions"):
Foo = .second
1 fizz := [1, Foo]
- 0 fizz should-be([0, .first])
- 1 fizz should-be([1, .second])
+ expect(0 fizz) to be([0, .first])
+ expect(1 fizz) to be([1, .second])
describe("lexical scope"):
it("captures variables"):
a = 1
capturing-simple := a
- capturing-simple should-be(a)
+ expect(capturing-simple) to be(a)
it("captures variables in loops"):
objects = [Object new, Object new, Object new]
objects each with-index [o, x]:
{ o } foo := x
- objects collect .foo should-be([0, 1, 2])
+ expect(objects collect .foo) to be([0, 1, 2])
describe("arguments"):
describe("required"):
it("accepts N arguments when expecting N"):
r0(a, b) := .ok
- r0(1, 2) should-be(.ok)
+ expect(r0(1, 2)) to be(.ok)
it("rejects too few arguments"):
r1(a, b) := .ok
- { r1(1) } should-raise(Atomy MethodFail)
+ expect { r1(1) } to raise(Atomy MethodFail)
it("rejects too many arguments"):
r2(a, b) := .ok
- { r2(1, 2, 3) } should-raise(Atomy MethodFail)
+ expect { r2(1, 2, 3) } to raise(Atomy MethodFail)
describe("splats"):
it("consumes the rest of the arguments"):
fizz(*args) := args
- fizz() should-be([])
- fizz(1) should-be([1])
- fizz(1, 2) should-be([1, 2])
+ expect(fizz()) to be([])
+ expect(fizz(1)) to be([1])
+ expect(fizz(1, 2)) to be([1, 2])
xs = [1, 2]
- fizz(*xs) should-be([1, 2])
+ expect(fizz(*xs)) to be([1, 2])
it("starts after required args"):
bar(a, *bs) := [a, bs]
- : bar ; should-raise(Atomy MethodFail)
- bar(1) should-be([1, []])
- bar(1, 2) should-be([1, [2]])
- bar(1, 2, 3) should-be([1, [2, 3]])
+ expect { bar } to raise(Atomy MethodFail)
+ expect(bar(1)) to be([1, []])
+ expect(bar(1, 2)) to be([1, [2]])
+ expect(bar(1, 2, 3)) to be([1, [2, 3]])
it("works with an explicit receiver"):
x bar-2(a, *bs) := [x, a, bs]
- : bar-2 ; should-raise(Atomy MethodFail)
- 0 bar-2(1) should-be([0, 1, []])
- 0 bar-2(1, 2) should-be([0, 1, [2]])
- 0 bar-2(1, 2, 3) should-be([0, 1, [2, 3]])
+ expect { bar-2 } to raise(Atomy MethodFail)
+ expect(0 bar-2(1)) to be([0, 1, []])
+ expect(0 bar-2(1, 2)) to be([0, 1, [2]])
+ expect(0 bar-2(1, 2, 3)) to be([0, 1, [2, 3]])
it("appears before a block arg"):
baz(a, *bs) &c := [a, bs, c]
x = :;
- : baz ; should-raise(Atomy MethodFail)
+ expect { baz } to raise(Atomy MethodFail)
res = baz(1) &x
- res at(0) should-be(1)
- res at(1) should-be([])
- res at(2) should: kind-of(Proc)?
+ expect(res at(0)) to be(1)
+ expect(res at(1)) to be([])
+ expect(res at(2)) to be-a(Proc)
res = baz(1, 2, 3) &x
- res at(0) should-be(1)
- res at(1) should-be([2, 3])
- res at(2) should: kind-of(Proc)?
+ expect(res at(0)) to be(1)
+ expect(res at(1)) to be([2, 3])
+ expect(res at(2)) to be-a(Proc)
describe("default"):
it("doesn't have to be passed"):
d0(b = 1) := b
- d0 should-be(1)
+ expect(d0) to be(1)
it("may appear after required args"):
d1(a, b = 1) := [a, b]
- d1(0) should-be([0, 1])
+ expect(d1(0)) to be([0, 1])
it("evaluates an expression as its default"):
d2(a, b = 1 + 1) := [a, b]
- d2(0) should-be([0, 2])
+ expect(d2(0)) to be([0, 2])
it("evaluates its default with other args in scope"):
d3(a, b = a + 1) := [a, b]
- d3(0) should-be([0, 1])
+ expect(d3(0)) to be([0, 1])
it("is overrided by an argument"):
d4(a, b = 3) := [a, b]
- d4(0, 1) should-be([0, 1])
+ expect(d4(0, 1)) to be([0, 1])
it("may appear before a block arg"):
d5(a = 1) &b := [a, b]
- d5 should-be([1, nil])
- d5(2) should-be([2, nil])
+ expect(d5) to be([1, nil])
+ expect(d5(2)) to be([2, nil])
it("may appear before a splat arg"):
d6(a = 1, *b) := [a, b]
- d6 should-be([1, []])
- d6(2) should-be([2, []])
- d6(2, 3) should-be([2, [3]])
+ expect(d6) to be([1, []])
+ expect(d6(2)) to be([2, []])
+ expect(d6(2, 3)) to be([2, [3]])
it("evaluates its default with the method's context in scope"):
x = 7
d7(a, b = x) := [a, b]
- d7(0) should-be([0, 7])
+ expect(d7(0)) to be([0, 7])
it("evaluates its default with the other args and the method's context in scope"):
x = 7
d8(a, b = a * x) := [a, b]
- d8(6) should-be([6, 42])
+ expect(d8(6)) to be([6, 42])
describe("varying argument lengths"):
it("tries higher required argument counts first"):
v0(_) := 1
v0(_, _) := 2
- v0(1) should-be(1)
- v0(1, 2) should-be(2)
+ expect(v0(1)) to be(1)
+ expect(v0(1, 2)) to be(2)
it("does the same when defined in reverse order"):
v1(_, _) := 2
v1(_) := 1
- v1(1) should-be(1)
- v1(1, 2) should-be(2)
+ expect(v1(1)) to be(1)
+ expect(v1(1, 2)) to be(2)
it("does not accept extra arguments for other branches"):
v2(0) := 1
v2 := 2
- v2(0) should-be(1)
- v2 should-be(2)
- { v2(1) } should-raise(Atomy MethodFail)
+ expect(v2(0)) to be(1)
+ expect(v2) to be(2)
+ expect { v2(1) } to raise(Atomy MethodFail)
View
205 test/suite/format.ay
@@ -5,251 +5,248 @@ use("therie")
describe("formatting"):
describe("chunks of text"):
it("formats as the text itself"):
- (f"foo" []) should-be("foo")
+ expect(f"foo" []) to be("foo")
it("has escapes for special format characters"):
- (f"\%\(\)\{\}\[\]" []) should-be("%(){}[]")
+ expect(f"\%\(\)\{\}\[\]" []) to be("%(){}[]")
it("handles other escapes normally"):
- (f"\n\t\123\EOT" []) should-be("\n\t\123\EOT")
+ expect(f"\n\t\123\EOT" []) to be("\n\t\123\EOT")
describe("string (%s)"):
it("formats a string"):
- (f"%s" [1]) should-be("1")
- (f"%s" ["hello"]) should-be("hello")
+ expect(f"%s" [1]) to be("1")
+ expect(f"%s" ["hello"]) to be("hello")
describe("decimal (%d)"):
it("formats an integer in decimal notation"):
- (f"%d" [10]) should-be("10")
+ expect(f"%d" [10]) to be("10")
it("fails with non-integer input"):
- { f"%d" ["hello"] } should-raise(ArgumentError)
+ expect { f"%d" ["hello"] } to raise(ArgumentError)
describe("hexadecimal (%x)"):
it("formats an integer in hexadecimal notation"):
- (f"%x" [10]) should-be("a")
+ expect(f"%x" [10]) to be("a")
it("fails with non-integer input"):
- { f"%x" ["hello"] } should-raise(ArgumentError)
+ expect { f"%x" ["hello"] } to raise(ArgumentError)
describe("octal (%o)"):
it("formats an integer in octal notation"):
- (f"%o" [10]) should-be("12")
+ expect(f"%o" [10]) to be("12")
it("fails with non-integer input"):
- { f"%o" ["hello"] } should-raise(ArgumentError)
+ expect { f"%o" ["hello"] } to raise(ArgumentError)
describe("binary (%b)"):
it("formats an integer in binary notation"):
- (f"%b" [10]) should-be("1010")
+ expect(f"%b" [10]) to be("1010")
it("fails with non-integer input"):
- { f"%b" ["hello"] } should-raise(ArgumentError)
+ expect { f"%b" ["hello"] } to raise(ArgumentError)
describe("radix (%r)"):
it("formats an integer in a given base"):
- (f"%.10r" [10]) should-be("10")
- (f"%.16r" [10]) should-be("a")
- (f"%.8r" [10]) should-be("12")
- (f"%.2r" [10]) should-be("1010")
- (f"%.36r" [35]) should-be("z")
+ expect(f"%.10r" [10]) to be("10")
+ expect(f"%.16r" [10]) to be("a")
+ expect(f"%.8r" [10]) to be("12")
+ expect(f"%.2r" [10]) to be("1010")
+ expect(f"%.36r" [35]) to be("z")
it("fails with non-integer input"):
- { f"%.10r" ["hello"] } should-raise(ArgumentError)
+ expect { f"%.10r" ["hello"] } to raise(ArgumentError)
describe("floating point (%f)"):
it("formats a double in general notation"):
- (f"%f" [10.0]) should-be("10.000000")
- (f"%f" [10.5]) should-be("10.500000")
- (f"%f" [10.54321]) should-be("10.543210")
+ expect(f"%f" [10.0]) to be("10.000000")
+ expect(f"%f" [10.5]) to be("10.500000")
+ expect(f"%f" [10.54321]) to be("10.543210")
it("fails with non-float input"):
- { f"%f" ["hello"] } should-raise(ArgumentError)
+ expect { f"%f" ["hello"] } to raise(ArgumentError)
it("accepts a precision flag"):
- (f"%.2f" [10.54321]) should-be("10.54")
- (f"%.2f" [10.545]) should-be("10.54")
+ expect(f"%.2f" [10.54321]) to be("10.54")
+ expect(f"%.2f" [10.545]) to be("10.54")
describe("exponential (%e)"):
it("formats a double in exponential notation"):
- (f"%e" [10.0]) should-be("1.000000e+01")
- (f"%e" [10.5]) should-be("1.050000e+01")
- (f"%e" [10.54321]) should-be("1.054321e+01")
- (f"%e" [10.12345678901234567890])
- should-be("1.012346e+01")
+ expect(f"%e" [10.0]) to be("1.000000e+01")
+ expect(f"%e" [10.5]) to be("1.050000e+01")
+ expect(f"%e" [10.54321]) to be("1.054321e+01")
+ expect((f"%e" [10.12345678901234567890])) to be("1.012346e+01")
it("fails with non-float input"):
- { f"%e" ["hello"] } should-raise(ArgumentError)
+ expect { f"%e" ["hello"] } to raise(ArgumentError)
it("accepts a precision flag"):
- (f"%.2e" [10.54321]) should-be("1.05e+01")
- (f"%.2e" [10.545]) should-be("1.05e+01")
- (f"%.2e" [10.12345678901234567890]) should-be("1.01e+01")
+ expect(f"%.2e" [10.54321]) to be("1.05e+01")
+ expect(f"%.2e" [10.545]) to be("1.05e+01")
+ expect(f"%.2e" [10.12345678901234567890]) to be("1.01e+01")
describe("general (%g)"):
it("formats a double in general notation"):
- (f"%g" [10.0]) should-be("10")
- (f"%g" [10.5]) should-be("10.5")
- (f"%g" [10.54321]) should-be("10.5432")
- (f"%g" [10000000.12345678901234567890])
- should-be("1e+07")
+ expect(f"%g" [10.0]) to be("10")
+ expect(f"%g" [10.5]) to be("10.5")
+ expect(f"%g" [10.54321]) to be("10.5432")
+ expect((f"%g" [10000000.12345678901234567890])) to be("1e+07")
it("fails with non-float input"):
- { f"%g" ["hello"] } should-raise(ArgumentError)
+ expect { f"%g" ["hello"] } to raise(ArgumentError)
it("accepts a precision flag"):
- (f"%.2g" [10.54321]) should-be("11")
- (f"%.2g" [10.545]) should-be("11")
- (f"%.2g" [10000000.12345678901234567890])
- should-be("1e+07")
+ expect(f"%.2g" [10.54321]) to be("11")
+ expect(f"%.2g" [10.545]) to be("11")
+ expect((f"%.2g" [10000000.12345678901234567890])) to be("1e+07")
describe("character (%c)"):
it("formats a character"):
- (f"%c" [97]) should-be("a")
- (f"%c" ["hi"]) should-be("h")
- (f"%c" [1.5]) should-be("1")
+ expect(f"%c" [97]) to be("a")
+ expect(f"%c" ["hi"]) to be("h")
+ expect(f"%c" [1.5]) to be("1")
describe("value (%v)"):
it("pretty-prints any value"):
- (f"%v" [1]) should-be("1")
- (f"%v" ["hello"]) should-be("\"hello\"")
+ expect(f"%v" [1]) to be("1")
+ expect(f"%v" ["hello"]) to be("\"hello\"")
describe("pluralization (%p)"):
it("pluralizes a word based on integer input"):
- (f"%p(cat)" [1]) should-be("cat")
- (f"%p(cat)" [2]) should-be("cats")
+ expect(f"%p(cat)" [1]) to be("cat")
+ expect(f"%p(cat)" [2]) to be("cats")
it("accepts a second field for a specific plural form"):
- (f"%p(person)(people)" [1]) should-be("person")
- (f"%p(person)(people)" [2]) should-be("people")
+ expect(f"%p(person)(people)" [1]) to be("person")
+ expect(f"%p(person)(people)" [2]) to be("people")
it("accepts a > flag to not consume the number input"):
- (f"%>p(person)(people): %d" [1]) should-be("person: 1")
- (f"%>p(person)(people): %d" [2]) should-be("people: 2")
+ expect(f"%>p(person)(people): %d" [1]) to be("person: 1")
+ expect(f"%>p(person)(people): %d" [2]) to be("people: 2")
describe("lowercase (%l)"):
it("converts its contents to lowercase"):
- (f"%l(%s)" ["HElLo!"]) should-be("hello!")
+ expect(f"%l(%s)" ["HElLo!"]) to be("hello!")
describe("capitalize (%c)"):
it("title-cases its contents"):
- (f"%c(%s)" ["HElLo, mOm!"]) should-be("Hello, Mom!")
+ expect(f"%c(%s)" ["HElLo, mOm!"]) to be("Hello, Mom!")
it("accepts a number flag to title-case a certain amount of words"):
- (f"%1c(%s)" ["HElLo, mOm!"]) should-be("Hello, mOm!")
+ expect(f"%1c(%s)" ["HElLo, mOm!"]) to be("Hello, mOm!")
describe("uppercase (%u)"):
it("converts its contents to uppercase"):
- (f"%u(%s)" ["hElLo!"]) should-be("HELLO!")
+ expect(f"%u(%s)" ["hElLo!"]) to be("HELLO!")
describe("skip (%_)"):
it("skips an input value"):
- (f"%_%d" [1, 2]) should-be("2")
+ expect(f"%_%d" [1, 2]) to be("2")
it("accepts a number flag for skipping a certain amount of inputs"):
- (f"%2_%d" [1, 2, 3]) should-be("3")
+ expect(f"%2_%d" [1, 2, 3]) to be("3")
it("accepts a < flag for skipping backards"):
- (f"%_%<_%d" [1, 2]) should-be("1")
- (f"%2_%2<_%d" [1, 2, 3]) should-be("1")
+ expect(f"%_%<_%d" [1, 2]) to be("1")
+ expect(f"%2_%2<_%d" [1, 2, 3]) to be("1")
describe("indirection (%%)"):
it("uses a given format string, followed by a list of inputs"):
- (f"%%" [f"%d", [1]]) should-be("1")
+ expect(f"%%" [f"%d", [1]]) to be("1")
it("only consumes its own inputs"):
- (f"%%%d" [f"%d", [1], 2]) should-be("12")
+ expect(f"%%%d" [f"%d", [1], 2]) to be("12")
it("only skips its own inputs"):
- (f"%%%d" [f"%_", [1], 2]) should-be("2")
+ expect(f"%%%d" [f"%_", [1], 2]) to be("2")
describe("iteration (%{...})"):
it("executes a format over a list of inputs"):
- (f"%{%d, }" [[1, 2, 3]]) should-be("1, 2, 3, ")
+ expect(f"%{%d, }" [[1, 2, 3]]) to be("1, 2, 3, ")
it("accepts a * flag for acting on the rest of the inputs"):
- (f"%*{%d, }" [1, 2, 3]) should-be("1, 2, 3, ")
+ expect(f"%*{%d, }" [1, 2, 3]) to be("1, 2, 3, ")
describe("number flag"):
it("limits the number of iterations"):
- (f"%2{%d, }" [[1, 2, 3]]) should-be("1, 2, ")
+ expect(f"%2{%d, }" [[1, 2, 3]]) to be("1, 2, ")
it("does not cause %^ to break"):
- (f"%2{%d%^, }" [[1, 2, 3]]) should-be("1, 2, ")
+ expect(f"%2{%d%^, }" [[1, 2, 3]]) to be("1, 2, ")
it("does not iterate with a limit of 0"):
- (f"%0{%d, }" [[1, 2, 3]]) should-be("")
+ expect(f"%0{%d, }" [[1, 2, 3]]) to be("")
describe("+ flag"):
it("causes iteration to always run at least once"):
- (f"%+{hi}" [[]]) should-be("hi")
- (f"%+{%#[hello]}" [[]]) should-be("hello")
+ expect(f"%+{hi}" [[]]) to be("hi")
+ expect(f"%+{%#[hello]}" [[]]) to be("hello")
it("overridden by a limit of 0"):
- (f"%0+{%d, }" [[1, 2, 3]]) should-be("")
+ expect(f"%0+{%d, }" [[1, 2, 3]]) to be("")
it("accepts a . flag for taking lists of inputs"):
- (f"%.{%d: %s\n}" [[[1, "one"], [2, "two"], [3, "three"]]])
- should-be("1: one\n2: two\n3: three\n")
+ expect((f"%.{%d: %s\n}" [[[1, "one"], [2, "two"], [3, "three"]]]))
+ to be("1: one\n2: two\n3: three\n")
describe("break (%^)"):
it("stops an iteration when there are no more inputs"):
- (f"%{%d%^, }" [[1, 2, 3]]) should-be("1, 2, 3")
+ expect(f"%{%d%^, }" [[1, 2, 3]]) to be("1, 2, 3")
it("stops a sublist iteration only based on the sublist"):
- (f"%.{%d%^, }" [[[1], [2, $x], [3]]]) should-be("12, 3")
+ expect(f"%.{%d%^, }" [[[1], [2, $x], [3]]]) to be("12, 3")
describe("conditional formatting (%[...]+(...)?)"):
it("formats the branch at an offset given by the input"):
- (f"%[0][1][2]" [0]) should-be("0")
- (f"%[0][1][2]" [1]) should-be("1")
+ expect(f"%[0][1][2]" [0]) to be("0")
+ expect(f"%[0][1][2]" [1]) to be("1")
it("has an optional default branch"):
- (f"%[0][1](2+)" [0]) should-be("0")
- (f"%[0][1](2+)" [1]) should-be("1")
- (f"%[0][1](2+)" [2]) should-be("2+")
- (f"%[0][1](2+)" [3]) should-be("2+")
+ expect(f"%[0][1](2+)" [0]) to be("0")
+ expect(f"%[0][1](2+)" [1]) to be("1")
+ expect(f"%[0][1](2+)" [2]) to be("2+")
+ expect(f"%[0][1](2+)" [3]) to be("2+")
describe("number flag"):
it("determines which branch gets formatted"):
- (f"%0[0][1][2]" []) should-be("0")
- (f"%1[0][1][2]" []) should-be("1")
+ expect(f"%0[0][1][2]" []) to be("0")
+ expect(f"%1[0][1][2]" []) to be("1")
it("flows into the default branch"):
- (f"%3[0][1][2](3+)" []) should-be("3+")
+ expect(f"%3[0][1][2](3+)" []) to be("3+")
describe("using #"):
it("determines which branch gets formatted"):
- (f"%#[0][1][2]" []) should-be("0")
- (f"%#[0][1][2]" [1]) should-be("1")
- (f"%#[0][1][2]" [1, 2]) should-be("2")
+ expect(f"%#[0][1][2]" []) to be("0")
+ expect(f"%#[0][1][2]" [1]) to be("1")
+ expect(f"%#[0][1][2]" [1, 2]) to be("2")
it("flows into the default branch"):
- (f"%#[0][1][2](3+)" []) should-be("0")
- (f"%#[0][1][2](3+)" [1, 2, 3, 4]) should-be("3+")
+ expect(f"%#[0][1][2](3+)" []) to be("0")
+ expect(f"%#[0][1][2](3+)" [1, 2, 3, 4]) to be("3+")
describe("? flag"):
describe("one branch"):
it("consumes a boolean, formatting if it's true"):
- (f"%?[yes]" [true]) should-be("yes")
- (f"%?[yes]" [false]) should-be("")
+ expect(f"%?[yes]" [true]) to be("yes")
+ expect(f"%?[yes]" [false]) to be("")
describe("two or more branches"):
it("consumes a boolean, formatting the first branch if true, and the second if false"):
- (f"%?[yes][no]" [true]) should-be("yes")
- (f"%?[yes][no]" [false]) should-be("no")
- (f"%?[yes][no][maybe so]" [true]) should-be("yes")
- (f"%?[yes][no][maybe so]" [false]) should-be("no")
+ expect(f"%?[yes][no]" [true]) to be("yes")
+ expect(f"%?[yes][no]" [false]) to be("no")
+ expect(f"%?[yes][no][maybe so]" [true]) to be("yes")
+ expect(f"%?[yes][no][maybe so]" [false]) to be("no")
describe("justification (%j(...)+)"):
it("justifies one segment to the right side"):
- (f"%20j(one)" []) should-be(" one")
- (f"%20j(one)" []) length should-be(20)
+ expect(f"%20j(one)" []) to be(" one")
+ expect((f"%20j(one)" []) length) to be(20)
it("justifies two segments to left and right sides"):
- (f"%20j(one)(two)" []) should-be("one two")
- (f"%20j(one)(two)" []) length should-be(20)
+ expect(f"%20j(one)(two)" []) to be("one two")
+ expect((f"%20j(one)(two)" []) length) to be(20)
it("attempts to space more than two segments evenly"):
- (f"%20j(one)(two)(three)" []) should-be("one two three")
- (f"%20j(one)(two)(three)" []) length should-be(20)
+ expect(f"%20j(one)(two)(three)" []) to be("one two three")
+ expect((f"%20j(one)(two)(three)" []) length) to be(20)
View
76 test/suite/macros.ay
@@ -46,104 +46,104 @@ describe("macros"):
it("creates names via #names"):
var-1 = 1 m-foo-1
var-2 = 2 m-foo-1
- var-1 should-be(var-1)
- var-1 should: != var-2
+ expect(var-1) to be(var-1)
+ expect(var-1) to-not be(var-2)
it("decorates through block patterns"):
var-1 = 1 m-foo-2
- var-1 should-be(var-1)
- 1 m-foo-2 should: != 2 m-foo-2
+ expect(var-1) to be(var-1)
+ expect(1 m-foo-2) to-not be(2 m-foo-2)
it("decorates through definition patterns"):
var-1 = 1 m-foo-3
- var-1 should-be(var-1)
- 1 m-foo-3 should: != 2 m-foo-3
+ expect(var-1) to be(var-1)
+ expect(1 m-foo-3) to-not be(2 m-foo-3)
-- TODO: change these to spec #node instead
describe("line information"):
it("is provided during macroexpansion via #line"):
- 1 m-foo-4 should-be(_LINE)
- 2 m-foo-4 should-be(_LINE)
+ expect(1 m-foo-4) to be(_LINE)
+ expect(2 m-foo-4) to be(_LINE)
-- TODO: investigate proper behaviour; this isn't worth implementing atm
-- it("retains the original line through multiple expansions"):
-- macro(a m-foo-5): line
-- macro(a m-foo-6): `(~a m-foo-5)
- -- 1 m-foo-6 should-be(_LINE)
+ -- expect(1 m-foo-6) to be(_LINE)
describe("macro definition"):
it("can pattern-match node types via constants"):
- : 1 ; m-foo-7 should-be(1)
- x m-foo-7 should-be(2)
- 1 m-foo-7 should-be(3)
+ expect(: 1 ; m-foo-7) to be(1)
+ expect(x m-foo-7) to be(2)
+ expect(1 m-foo-7) to be(3)
it("can destructurually pattern-match expressions"):
- (2 + 1) m-foo-8 should-be([2, 1])
+ expect((2 + 1) m-foo-8) to be([2, 1])
it("matches destructuring before constants"):
- (2 + 1) m-foo-9 should-be(1)
- (2 + 1) m-foo-10 should-be(1)
+ expect((2 + 1) m-foo-9) to be(1)
+ expect((2 + 1) m-foo-10) to be(1)
it("can specify defaults for arguments"):
- default-having() should-be(42)
- default-having(41) should-be(41)
+ expect(default-having()) to be(42)
+ expect(default-having(41)) to be(41)
it("can define macros in their expansion"):
- 1 m-foo-110 should-be(42)
- : 2 m-foo-110 ; should-raise(NoMethodError)
+ expect(1 m-foo-110) to be(42)
+ expect { 2 m-foo-110 } to raise(NoMethodError)
it("can define macros that define macros in their expansion in their expansion"):
- 1 m-foo-121 should-be(42)
- : 2 m-foo-121 ; should-raise(NoMethodError)
+ expect(1 m-foo-121) to be(42)
+ expect { 2 m-foo-121 } to raise(NoMethodError)
describe("varying argument lengths"):
it("tries higher required argument counts first"):
- m-foo-18(1) should-be(1)
- m-foo-18(1, 2) should-be(2)
+ expect(m-foo-18(1)) to be(1)
+ expect(m-foo-18(1, 2)) to be(2)
- m-foo-19(1) should-be(1)
- m-foo-19(1, 2) should-be(2)
+ expect(m-foo-19(1)) to be(1)
+ expect(m-foo-19(1, 2)) to be(2)
describe("let-macro"):
it("defines a macro for only its body"):
m-foo-20 = 0
let-macro(m-foo-20 = '1):
- m-foo-20 should-be(1)
+ expect(m-foo-20) to be(1)
- m-foo-20 should-be(0)
+ expect(m-foo-20) to be(0)
it("can be nested"):
m-foo-21 = 0
let-macro(m-foo-21 = '1):
let-macro(m-foo-21 = '2):
- m-foo-21 should-be(2)
+ expect(m-foo-21) to be(2)
- m-foo-21 should-be(1)
+ expect(m-foo-21) to be(1)
- m-foo-21 should-be(0)
+ expect(m-foo-21) to be(0)
it("can define multiple macros"):
m-foo-22 = 0
let-macro(m-foo-22 = '1, fizzbuzz = '2):
- (m-foo-22 + fizzbuzz) should-be(3)
+ expect((m-foo-22 + fizzbuzz)) to be(3)
- m-foo-22 should-be(0)
- { fizzbuzz } should-raise(NameError)
+ expect(m-foo-22) to be(0)
+ expect { fizzbuzz } to raise(NameError)
it("lets later macros refer to earlier ones"):
let-macro(m-foo-23 = '1,
m-foo-24 = '[0, m-foo-23]):
- m-foo-23 should-be(1)
- m-foo-24 should-be([0, 1])
+ expect(m-foo-23) to be(1)
+ expect(m-foo-24) to be([0, 1])
it("overrides non-let'd macros"):
let-macro(m-foo-25 = '2):
- m-foo-25 should-be(2)
+ expect(m-foo-25) to be(2)
- m-foo-25 should-be(1)
+ expect(m-foo-25) to be(1)
it("is available for its own expansion"):
when-compiling:
@@ -152,4 +152,4 @@ describe("macros"):
let-macro(foo = if($expanded < 5)
then: $expanded += 1, 'foo
else: $expanded):
- foo should-be(5)
+ expect(foo) to be(5)
View
35 test/suite/patterns.ay
@@ -6,34 +6,37 @@ describe("pattern-matching"):
describe("expressions"):
describe("quote"):
it("does basic expression equality check"):
- ('abc match: 'abc -> true) should-be(true)
- ('(1 + 2) match: '(1 + 2) -> true) should-be(true)
- ('(1 * 2) match: '(1 + 2) -> true) should-be(nil)
+ expect('abc match: 'abc -> true) to be(true)
+ expect('(1 + 2) match: '(1 + 2) -> true) to be(true)
+ expect('(1 * 2) match: '(1 + 2) -> true) to be(nil)
describe("quasi-quote"):
it("matches expressions like quote"):
- ('abc match: `abc -> true) should-be(true)
+ expect('abc match: `abc -> true) to be(true)
it("fails for expressions of different type"):
- ('abc match: `(1 + 1) -> true) should-be(nil)
+ expect('abc match: `(1 + 1) -> true) to be(nil)
it("allows destructural binding via unquote"):
- ('(1 + 2) match: `(1 + ~x) -> x) should-be('2)
+ expect('(1 + 2) match: `(1 + ~x) -> x) to be('2)
it("matches expression attributes like method names"):
- ('(1 + 2) match: `(1 + 2) -> true) should-be(true)
- ('(1 + 2) match: `(1 * 2) -> true) should-be(nil)
+ expect('(1 + 2) match: `(1 + 2) -> true) to be(true)
+ expect('(1 + 2) match: `(1 * 2) -> true) to be(nil)
it("has the same quote/unquote semantics as a quasiquote"):
- ('(1 + `(2 + ~x)) match:
- `(1 + `(2 + ~~y)) -> y) should-be('x)
+ expect(
+ '(1 + `(2 + ~x)) match:
+ `(1 + `(2 + ~~y)) -> y) to be('x)
- ('(1 + `(~x + ~x)) match:
- `(1 + `(~x + ~~y)) -> y) should-be('x)
+ expect(
+ '(1 + `(~x + ~x)) match:
+ `(1 + `(~x + ~~y)) -> y) to be('x)
- ('(1 + `(~x + ~x)) match:
- `(1 + `(~y + ~~y)) -> y) should-be(nil)
+ expect(
+ '(1 + `(~x + ~x)) match:
+ `(1 + `(~y + ~~y)) -> y) to be(nil)
it("allows arbitrary patterns in an unquote"):
- ('(1 + 2) match: `(1 + ~('2)) -> true) should-be(true)
- ('(1 + 2) match: `(1 + ~('3)) -> true) should-be(nil)
+ expect('(1 + 2) match: `(1 + ~('2)) -> true) to be(true)
+ expect('(1 + 2) match: `(1 + ~('3)) -> true) to be(nil)
View
32 test/suite/quotes.ay
@@ -7,38 +7,38 @@ macro(q-foo-1): '['2, '3]
describe("quasiquotation"):
it("constructs an expression"):
- `1 should-be('1)
- `(1 + 1) should-be('(1 + 1))
+ expect(`1) to be('1)
+ expect(`(1 + 1)) to be('(1 + 1))
it("expands through unquotes"):
- `(1 + ~q-foo-0) should-be('(1 + 42))
+ expect(`(1 + ~q-foo-0)) to be('(1 + 42))
it("expands through splice unquotes"):
- `[1, ~*q-foo-1] should-be('[1, 2, 3])
+ expect(`[1, ~*q-foo-1]) to be('[1, 2, 3])
describe("unquotes"):
it("brings an expression into a quasiquotation"):
- `(1 + ~'3) should-be('(1 + 3))
+ expect(`(1 + ~'3)) to be('(1 + 3))
a = '2
- `(1 + ~a) should-be('(1 + 2))
+ expect(`(1 + ~a)) to be('(1 + 2))
it("unquotes through nested quasiquotation"):
a = '3
- `(1 + `(2 * ~~'4)) should-be('(1 + `(2 * ~4)))
- `(1 + `(2 * ~~a)) should-be('(1 + `(2 * ~3)))
- ``(1 + `(2 * ~~~'4)) should-be('`(1 + `(2 * ~~4)))
- ``(1 + `(2 * ~~~a)) should-be('`(1 + `(2 * ~~3)))
+ expect(`(1 + `(2 * ~~'4))) to be('(1 + `(2 * ~4)))
+ expect(`(1 + `(2 * ~~a))) to be('(1 + `(2 * ~3)))
+ expect(``(1 + `(2 * ~~~'4))) to be('`(1 + `(2 * ~~4)))
+ expect(``(1 + `(2 * ~~~a))) to be('`(1 + `(2 * ~~3)))
describe("splice-quotes"):
it("unquotes a list of expressions, merging into a 'many' part"):
a = ['3, '4]
- `[1, 2, ~*['3, '4]] should-be('[1, 2, 3, 4])
- `[1, 2, ~*a] should-be('[1, 2, 3, 4])
+ expect(`[1, 2, ~*['3, '4]]) to be('[1, 2, 3, 4])
+ expect(`[1, 2, ~*a]) to be('[1, 2, 3, 4])
it("splices through nested quasiquotation"):
a = ['3, '4]
- ``[1, 2, ~~*['3, '4]] should-be('`[1, 2, ~*['3, '4]])
- ``[1, 2, ~~*a] should-be('`[1, 2, ~*['3, '4]])
- ```[1, 2, ~~~*['3, '4]] should-be('``[1, 2, ~~*['3, '4]])
- ```[1, 2, ~~~*a] should-be('``[1, 2, ~~*['3, '4]])
+ expect(``[1, 2, ~~*['3, '4]]) to be('`[1, 2, ~*['3, '4]])
+ expect(``[1, 2, ~~*a]) to be('`[1, 2, ~*['3, '4]])
+ expect(```[1, 2, ~~~*['3, '4]]) to be('``[1, 2, ~~*['3, '4]])
+ expect(```[1, 2, ~~~*a]) to be('``[1, 2, ~~*['3, '4]])
View
46 test/suite/scope.ay
@@ -7,20 +7,20 @@ describe("assignment"):
describe("="):
it("introduces a new local"):
a = 0
- a should-be(0)
- { a = 1, a } call should-be(1)
- a should-be(0)
+ expect(a) to be(0)
+ expect({ a = 1, a } call) to be(1)
+ expect(a) to be(0)
describe("=!"):
it("overwrites an existing local"):
a = 0
- a should-be(0)
- { a =! 1, a } call should-be(1)
- a should-be(1)
+ expect(a) to be(0)
+ expect({ a =! 1, a } call) to be(1)
+ expect(a) to be(1)
it("introduces a new local if not defined"):
- { a =! 1, a } call should-be(1)
- { a } should-raise(NameError)
+ expect({ a =! 1, a } call) to be(1)
+ expect { a } to raise(NameError)
describe("with-variables-of"):
it("redirects instance variable access to the target"):
@@ -29,45 +29,45 @@ describe("with-variables-of"):
get-x := @x
with-variables-of(InstanceVariableUser new(42)):
- @x should-be(42)
+ expect(@x) to be(42)
it("redirects instance variable assignment to the target"):
x = InstanceVariableUser new(42)
with-variables-of(x):
@x = 43
- x get-x should-be(43)
+ expect(x get-x) to be(43)
it("redirects class variable access to the target"):
ClassVariableUser = class:
@@x = 42
get-x := @@x
with-variables-of(ClassVariableUser new):
- @@x should-be(42)
+ expect(@@x) to be(42)
it("redirects class variable assignment to the target"):
with-variables-of(ClassVariableUser new):
@@x = 43
- ClassVariableUser new get-x should-be(43)
+ expect(ClassVariableUser new get-x) to be(43)
describe("onto"):
it("replaces the receiver of private message sends"):
- 1 onto { inspect } should-be("1")
- 1 onto { inspect() } should-be("1")
- 1 onto { + 2 } should-be(3)
+ expect(1 onto { inspect }) to be("1")
+ expect(1 onto { inspect() }) to be("1")
+ expect(1 onto { + 2 }) to be(3)
- 1 onto { 3 inspect } should-be("3")
- 1 onto { 3 inspect() } should-be("3")
- 1 onto { 3 + 2 } should-be(5)
+ expect(1 onto { 3 inspect }) to be("3")
+ expect(1 onto { 3 inspect() }) to be("3")
+ expect(1 onto { 3 + 2 }) to be(5)
it("treats 'self' as the original 'self'"):
OntoWithSelf = class:
go := 1 onto: [self, + 2]
x = OntoWithSelf new
- x go should-be([x, 3])
+ expect(x go) to be([x, 3])
it("treats instance variables as belonging to the original 'self'"):
OntoWithInstanceVariable = class:
@@ -76,9 +76,9 @@ describe("onto"):
set := 1 onto: @x = 43
x = OntoWithInstanceVariable new(42)
- x go should-be(42)
+ expect(x go) to be(42)
x set
- x go should-be(43)
+ expect(x go) to be(43)
it("treats class variables as belonging to the original 'self'"):
OntoWithClassVariable = class:
@@ -87,6 +87,6 @@ describe("onto"):
set := 1 onto: @@foo = 43
x = OntoWithClassVariable new
- x go should-be(42)
+ expect(x go) to be(42)
x set
- x go should-be(43)
+ expect(x go) to be(43)
View
24 test/suite/super.ay
@@ -25,30 +25,30 @@ SuperB = SuperA class:
describe("super"):
it("resends the message to the superclass"):
- SuperB new test-1 should-be(.super)
+ expect(SuperB new test-1) to be(.super)
it("passes the same arguments to the superclass method"):
- SuperB new test-2(1) should-be([.super, 2])
+ expect(SuperB new test-2(1)) to be([.super, 2])
it("passes the block to the superclass method"):
- SuperB new test-3: 1; should-be([.super, 1])
- SuperB new test-4: 1; should-be([.super, 2])
+ expect(SuperB new test-3: 1;) to be([.super, 1])
+ expect(SuperB new test-4: 1;) to be([.super, 2])
it("passes a &block to the superclass method"):
a = { 1 }
- SuperB new test-3 &a should-be([.super, 1])
- SuperB new test-4 &a should-be([.super, 2])
+ expect(SuperB new test-3 &a) to be([.super, 1])
+ expect(SuperB new test-4 &a) to be([.super, 2])
it("sends with the subclass method's defaults"):
- SuperB new test-5(2) should-be([.super, 3])
- SuperB new test-5 should-be([.super, 1])
+ expect(SuperB new test-5(2)) to be([.super, 3])
+ expect(SuperB new test-5) to be([.super, 1])
it("assumes superclass's defaults"):
- SuperB new test-6 should-be([.super, 1])
+ expect(SuperB new test-6) to be([.super, 1])
it("handles both defaults and blocks"):
- SuperB new test-7(3): 2; should-be([.super, 4, 2])
- SuperB new test-7: 2; should-be([.super, 1, 2])
+ expect(SuperB new test-7(3): 2;) to be([.super, 4, 2])
+ expect(SuperB new test-7: 2;) to be([.super, 1, 2])
it("works from inside of a block"):
- SuperB new test-8(0) should-be([.super, 1])
+ expect(SuperB new test-8(0)) to be([.super, 1])
View
16 test/suite/therie.ay
@@ -7,39 +7,39 @@ describe(.let):
let(.falsy): signal(.called), nil
it("defines a value"):
- abc should-be(42)
+ expect(abc) to be(42)
it("is the same value repeatedly"):
- abc should-be(42)
- abc should-be(42)
+ expect(abc) to be(42)
+ expect(abc) to be(42)
it("is memoized per-it"):
called = 0
{ memoized } bind: .called: called += 1
{ memoized } bind: .called: called += 1
- called should-be(1)
+ expect(called) to be(1)
it("does not leak memoization into other its"):
called = 0
{ memoized } bind: .called: called += 1
- called should-be(1)
+ expect(called) to be(1)
it("memoizes things that return a falsy value"):
called = 0
{ falsy } bind: .called: called += 1
{ falsy } bind: .called: called += 1
- called should-be(1)
+ expect(called) to be(1)
describe("nested lets"):
let(.abc): 43
let(.outer-let): [.outer, abc]
it("shadows outer lets"):
- abc should-be(43)
+ expect(abc) to be(43)
context("when used by outer lets"):
let(.abc): 44
it("uses them for the outer let's body"):
- outer-let should-be([.outer, 44])
+ expect(outer-let) to be([.outer, 44])

0 comments on commit 4f0ee89

Please sign in to comment.