d438ef923e4f8b37feeebe00cb8c00f7bd5d5f22.svn-base
1.51 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict'
var test = require('tape')
var util = require('util')
var redeyed = require('..')
function inspect(obj) {
return util.inspect(obj, false, 5, true)
}
test('adding custom asserts ... ', function(t) {
t.constructor.prototype.assertSurrounds = function(code, opts, expected) {
var optsi = inspect(opts)
var result = redeyed(code, opts).code
this.equals(result
, expected
, util.format('%s: %s => %s', optsi, inspect(code), inspect(expected))
)
return this
}
t.end()
})
test('\n undefineds only', function(t) {
t.assertSurrounds('1 + 2', { Numeric: { _default: undefined } }, '1 + 2')
t.assertSurrounds('1 + 2', { Numeric: { _default: undefined }, _default: undefined }, '1 + 2')
t.assertSurrounds(
'return true'
, { 'Boolean': { 'true': undefined, 'false': undefined, _default: undefined }, _default: undefined }
, 'return true'
)
t.end()
})
test('\n mixed', function(t) {
t.assertSurrounds(
'return true || false'
, { 'Boolean': { 'true': '&:', 'false': undefined, _default: undefined }, _default: undefined }
, 'return &true || false'
)
t.assertSurrounds(
'return true || false'
, { 'Boolean': { 'true': '&:', 'false': undefined, _default: ':?' }, _default: undefined }
, 'return &true? || false?'
)
t.assertSurrounds(
'return true || false'
, { 'Boolean': { 'true': '&:', 'false': undefined, _default: undefined }, _default: ':?' }
, 'return &true? || false'
)
t.end()
})