var test = require('tape')

var CHR = require('../../src/index')

test('a ==> 1 < 2 | b', function (t) {
  var chr = new CHR()
  chr('a ==> 1 < 2 | b')

  chr.a()
  t.equal(chr.Store.length, 2)

  t.end()
})

test('a ==> 1 > 2 | b', function (t) {
  var chr = new CHR()
  chr('a ==> 1 > 2 | b')

  chr.a()
  t.equal(chr.Store.length, 1)

  t.end()
})

test('a ==> ${ () => 1 < 2 } | b', function (t) {
  var chr = new CHR()
  chr('a ==>', function () { return 1 < 2 }, '| b')

  chr.a()
  t.equal(chr.Store.length, 2)

  t.end()
})

test('a ==> ${ () => 1 > 2 } | b', function (t) {
  var chr = new CHR()
  chr('a ==>', function () { return 1 > 2 }, '| b')

  chr.a()
  t.equal(chr.Store.length, 1)

  t.end()
})

@@ -686,28 +686,513 @@
 re.length, 1)%0A%0A  t.end()%0A%7D)%0A
+%0Atest('Scope', function (t) %7B%0A  var chr = new CHR()%0A  chr('a(N) ==%3E', function (N) %7B return N %3E 10 %7D, '%7C b')%0A%0A  chr.a(1)%0A  t.equal(chr.Store.length, 1)%0A%0A  chr.a(20)%0A  t.equal(chr.Store.length, 3)%0A%0A  t.end()%0A%7D)%0A%0Atest('Guard with used-defined predicate', function (t) %7B%0A  function greaterThan10 (N) %7B%0A    return N %3E 10%0A  %7D%0A%0A  var chr = new CHR()%0A  chr('a(N) ==%3E', greaterThan10, '%7C b')%0A%0A  chr.a(1)%0A  t.equal(chr.Store.length, 1)%0A%0A  chr.a(20)%0A  t.equal(chr.Store.length, 3)%0A%0A  t.end()%0A%7D)%0A

Add guard tests for usage with user-defined predicates