Commits

Alex Suraci committed 8dbfce4

style updates
Ignore-this: 92bb096a0ff18a02f1b74b37579cb9d4

Comments (0)

Files changed (1)

-nesting-level = Parameter new: 0
-stats = Object clone do: {
-    failed = 0
-    passed = 0
-}
+define: *nesting-level* as: 0
 
-(super) theorize: as := {
-    stats do: {
-        failed = 0
+stats =
+  Object clone do:
+    { failed = 0
+      passed = 0
+    }
+
+(super) theorize: as :=
+  { stats do:
+      { failed = 0
         passed = 0
-    }
+      }
 
     as call
     "" print
 
     stats do: {
-        [
-            "total of", (failed + passed) show, "tests",
+      [ "total of", (failed + passed) show, "tests",
 
-            "(" .. (passed show ansi-colored: @green), "passed,",
+        "(" .. (passed show ansi-colored: @green), "passed,",
 
-            if: (failed == 0)
-                then: { "0" }
-                else: { failed show ansi-colored: @red}
-            
-            "failed)"
-        ] unwords print
+        if: (failed == 0)
+          then: { "0" }
+          else: { failed show ansi-colored: @red}
+        
+        "failed)"
+      ] unwords print
     }
-} call
+  } call
 
 o should: (check: Particle) :=
-    when: (check call: [o]) not
-        do: { raise: @(assertion-failed: check on: o) }
+  when: (check call: [o]) not
+    do: { raise: @(assertion-failed: check on: o) }
 
 o should: (check: Block) :=
-    when: (o join: check with: [o]) not
-        do: { raise: @(assertion-failed: check on: o) }
+  when: (o join: check with: [o]) not
+    do: { raise: @(assertion-failed: check on: o) }
 
 x should-be: y := x should: @(== y)
 
 x exception-match: y := x == y
 x exception-match: (p: Particle) :=
-    [e type, p type] match: {
-        [@single, @single] ->
-            x name == p name
+  [e type, p type] match: {
+    [@single, @single] ->
+      x name == p name
 
-        [@keyword, @keyword] ->
-            x names == p names
-    }
+    [@keyword, @keyword] ->
+      x names == p names
+  }
 
-x should-raise: y := {
-    succeeded? = False
+x should-raise: y :=
+  { succeeded? = False
 
     ok = {
-        x call
-        succeeded? = True
+      x call
+      succeeded? = True
     } catch: { e |
-        thrown = e
-        x exception-match: y
+      thrown = e
+      x exception-match: y
     }
 
     condition: {
-        succeeded? ->
-            raise: @(assertion-failed: @(should-raise: p) on: x)
+      succeeded? ->
+        raise: @(assertion-failed: @(should-raise: p) on: x)
 
-        ok -> @ok
+      ok -> @ok
 
-        otherwise ->
-            raise: @(expected: p got: thrown)
+      otherwise ->
+        raise: @(expected: p got: thrown)
     }
-}
+  }
 
 
-(super) describe: x as: body := {
-    (indentation .. "- " .. x (as: String)) print
+(super) describe: x as: body :=
+  { (indentation .. "- " .. x (as: String)) print
 
-    with: nesting-level as: (nesting-level _? + 1) do: body
-} call
+    with: *nesting-level* as: (*nesting-level* _? + 1) do: body
+  } call
 
-(super) it: description so: checks := {
-    {
-        checks call
-        stats passed = stats passed + 1
-        (indentation .. "✓ " .. description) (ansi-colored: @green) print
+(super) it: description so: checks :=
+  { { checks call
+      stats passed = stats passed + 1
+      (indentation .. "✓ " .. description) (ansi-colored: @green) print
     } catch: { e |
-        stats failed = stats failed + 1
-        (indentation .. "✗ " .. description) (ansi-colored: @red) print
-        (indentation .. "  ` " .. e show) (ansi-colored: @yellow) print
+      stats failed = stats failed + 1
+      (indentation .. "✗ " .. description) (ansi-colored: @red) print
+      (indentation .. "  ` " .. e show) (ansi-colored: @yellow) print
     }
-} call
+  } call
 
-indentation := ' ' repeat: (nesting-level _? * 2)
+indentation := ' ' repeat: (*nesting-level* _? * 2)
 
-(s: String) ansi-colored: color := {
-    codes = [
-        @black
+(s: String) ansi-colored: color :=
+  { codes =
+      [ @black
         @red
         @green
         @yellow
         @magenta
         @cyan
         @white
-    ] zip: (0 .. 7)
+      ] zip: (0 .. 7)
 
     (codes lookup: color) match: {
-        @none -> raise: @(invalid-color: color needed: codes (map: @from))
-        @(ok: code) ->
-            "\ESC[9" .. code show .. "m" .. s .. "\ESC[0m"
+      @none -> raise: @(invalid-color: color needed: codes (map: @from))
+      @(ok: code) ->
+        "\ESC[9" .. code show .. "m" .. s .. "\ESC[0m"
     }
-} call
+  } call