diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-02-13 09:26:36 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-02-13 09:26:36 +0000 |
| commit | a1035d1cd657d4b47dd8edfd31d1cfd6078cef61 (patch) | |
| tree | 9e7118ebb19cdee4e8b1d8ba37c4052061df7455 | |
| parent | no more @registry juggling (diff) | |
| download | alive-a1035d1cd657d4b47dd8edfd31d1cfd6078cef61.tar.gz alive-a1035d1cd657d4b47dd8edfd31d1cfd6078cef61.zip | |
remove outdated tests
| -rw-r--r-- | core/init.moon | 5 | ||||
| -rw-r--r-- | spec/cell_spec.moon | 73 | ||||
| -rw-r--r-- | spec/parsing_spec.moon | 4 | ||||
| -rw-r--r-- | spec/registry_spec.moon | 60 |
4 files changed, 16 insertions, 126 deletions
diff --git a/core/init.moon b/core/init.moon index f9a3b9e..1d9e191 100644 --- a/core/init.moon +++ b/core/init.moon @@ -7,6 +7,7 @@ import Scope from require 'core.scope' load_! import Registry from require 'core.registry' +import Tag from require 'core.tag' import Cell, RootCell from require 'core.cell' import cell, program from require 'core.parsing' @@ -18,9 +19,9 @@ globals = Scope.from_table require 'core.builtin' :Op, :Action, :FnDef :Scope - :Registry - :globals + :Registry, :Tag + :globals parse: program\match eval: (str, inject) -> scope = Scope nil, globals diff --git a/spec/cell_spec.moon b/spec/cell_spec.moon index f55ab4d..b31ef99 100644 --- a/spec/cell_spec.moon +++ b/spec/cell_spec.moon @@ -1,5 +1,5 @@ import Cell, RootCell, Const, Scope, globals from require 'core' -import Registry from require 'registry' +import Registry from require 'core.registry' import Logger from require 'logger' Logger.init 'silent' @@ -7,70 +7,17 @@ hello_world = Cell nil, { (Const.sym 'hello'), (Const.str 'world') } two_plus_two = Cell nil, { (Const.sym '+'), (Const.num 2), (Const.num 2) } describe 'Cell', -> - describe 'quoting', -> - it 'quotes children', -> - reg = mock register: => - with hello_world\quote nil, reg - assert.is.equal Cell, .__class - assert.is.equal (Const.sym 'hello'), \head! - assert.is.same { Const.str 'world' }, \tail! + it 'supports quoting', -> + with hello_world\quote! + assert.is.equal Cell, .__class + assert.is.equal (Const.sym 'hello'), \head! + assert.is.same { Const.str 'world' }, \tail! - with two_plus_two\quote nil, reg - assert.is.equal Cell, .__class - assert.is.equal (Const.sym '+'), \head! - assert.is.same { (Const.num 2), (Const.num 2) }, \tail! + with two_plus_two\quote! + assert.is.equal Cell, .__class + assert.is.equal (Const.sym '+'), \head! + assert.is.same { (Const.num 2), (Const.num 2) }, \tail! - it 'registers recursively', -> - root = Cell nil, { (Const.sym 'out'), hello_world, two_plus_two } - - reg = mock register: => - root\quote nil, reg - - (assert.spy reg.register).was.called_with reg, root, nil - (assert.spy reg.register).was.called_with reg, hello_world, nil - (assert.spy reg.register).was.called_with reg, two_plus_two, nil - - it 'passes parsed tag', -> - root = Cell (Const.num 2), { (Const.sym 'out'), hello_world, two_plus_two } - - reg = mock register: => - root\quote nil, reg - - (assert.spy reg.register).was.called! - (assert.spy reg.register).was.called_with reg, match._, Const.num 2 - - describe 'evaluation', -> - globals\use Scope.from_table require 'lib.math' - registry = Registry! - - local op, action - - it 'instantiates the op + action', -> - op = two_plus_two\eval globals, registry - action = registry.map[two_plus_two.tag.value] - - assert.is.equal 'add', op.__class.__name - assert.is.equal 'op_invoke', action.__class.__name - registry\step! - - it 'calls :setup() when parameters change', -> - two_plus_two.children[3] = Const.num 3 - - s = spy.on op, 'setup' - assert.is.equal op, two_plus_two\eval globals, registry - assert.is.equal action, registry.map[two_plus_two.tag.value] - (assert.spy s).was.called_with (match.is_ref op), (Const.num 2), (Const.num 3) - registry\step! - - it 'calls :destroy() when opdef changes', -> - two_plus_two.children[1] = Const.sym 'sub' - two_plus_two.children[2] = Const.num 6 - - s = spy.on op, 'destroy' - assert.not.equal op, two_plus_two\eval globals, registry - assert.is.equal action, registry.map[two_plus_two.tag.value] - assert.is.equal 'sub', action.op.__class.__name - (assert.spy s).was.called_with match.is_ref op describe 'RootCell', -> test 'head is always "do"', -> diff --git a/spec/parsing_spec.moon b/spec/parsing_spec.moon index 445c2c9..2e7da7f 100644 --- a/spec/parsing_spec.moon +++ b/spec/parsing_spec.moon @@ -73,14 +73,14 @@ describe 'Cell', -> node = verify_parse cell, '([42]tagged 2)' assert.is.equal 2, #node.children - assert.is.equal (Const.num 42), node.tag + assert.is.equal 42, node.tag.value test 'tag parsing with whitespace', -> node = verify_parse cell, '([42] tagged 2)' assert.is.equal 2, #node.children - assert.is.equal (Const.num 42), node.tag + assert.is.equal 42, node.tag.value describe 'RootCell parsing', -> describe 'handles whitespace', -> diff --git a/spec/registry_spec.moon b/spec/registry_spec.moon index 8fdfdb9..6fe2e3a 100644 --- a/spec/registry_spec.moon +++ b/spec/registry_spec.moon @@ -1,5 +1,4 @@ -import Registry from require 'registry' -import Const from require 'core' +import Registry, Tag from require 'core.registry' import Logger from require 'logger' Logger.init 'silent' @@ -7,60 +6,3 @@ mk = -> mock destroy: => describe 'registry', -> - registry = Registry! - - a, b, c = mk!, mk!, mk! - - it 'registers new items', -> - assert.is.equal (Const.num 1), registry\register a, nil - assert.is.equal (Const.num 2), registry\register b, nil - - it 'is empty until stepped', -> - assert.is.nil registry\prev Const.num 1 - assert.is.nil registry\prev Const.num 2 - assert.is.nil registry\prev Const.num 3 - - registry\step! - - it 'memorizes items', -> - assert.is.equal a, registry\prev Const.num 1 - assert.is.equal b, registry\prev Const.num 2 - assert.is.nil registry\prev Const.num 3 - - it 'destroyes lost items', -> - assert.is.equal (Const.num 2), registry\register b, Const.num 2 - assert.is.equal (Const.num 3), registry\register c, nil - - assert.is.equal a, registry\prev Const.num 1 - assert.is.equal b, registry\prev Const.num 2 - assert.is.nil registry\prev Const.num 3 - - assert.stub(a.destroy).was.not_called! - assert.stub(b.destroy).was.not_called! - assert.stub(c.destroy).was.not_called! - - registry\step! - - assert.stub(a.destroy).was.called_with a - assert.stub(b.destroy).was.not_called! - assert.stub(c.destroy).was.not_called! - - assert.is.nil registry\prev Const.num 1 - assert.is.equal b, registry\prev Const.num 2 - assert.is.equal c, registry\prev Const.num 3 - - it 'fills holes', -> - assert.is.equal (Const.num 1), registry\register a, nil - assert.is.equal (Const.num 2), registry\register b, Const.num 2 - assert.is.equal (Const.num 3), registry\register c, Const.num 3 - - assert.is.nil registry\prev Const.num 1 - assert.is.equal b, registry\prev Const.num 2 - assert.is.equal c, registry\prev Const.num 3 - - registry\step! - - assert.is.equal a, registry\prev Const.num 1 - assert.is.equal b, registry\prev Const.num 2 - assert.is.equal c, registry\prev Const.num 3 - |
