aboutsummaryrefslogtreecommitdiffstats
path: root/spec/test_setup.moon
blob: 92bb61ec0e3ee126900efa51d1df9a9cea80705a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import Constant, Scope, Op, Tag from require 'alv'
import Copilot from require 'alv.copilot.base'
import Module from require 'alv.module'
import Logger from require 'alv.logger'
Logger\init 'silent'

class TestPilot extends Copilot
  new: (code) =>
    @T = 0
    @active_module = Module!

  begin_eval: => @active_module.registry\begin_eval!
  end_eval: => @active_module.registry\end_eval!
  next_tick: => @T += 1

  require: =>
    error "not implemented"

export COPILOT

{
  :TestPilot

  do_setup: ->
    COPILOT = TestPilot!
    COPILOT\begin_eval!

  do_teardown: ->
    COPILOT\end_eval!

  invoke_op: (op, tail, scope=Scope!) ->
    import op_invoke from require 'alv.invoke'

    fake_cell =
      head: -> 'test_op'
      tail: -> tail
      tag: Tag.blank!

    op_invoke\eval_cell fake_cell, Scope!, Constant.wrap op
}