35612c519f7720def4c64d70aad335b8a0195e22.svn-base
1.29 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
'use strict'
/* eslint-disable no-template-curly-in-string */
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('upcoming syntax: rest and spread properties', function(t) {
t.test('\n# Punctuator', function(t) {
var punctuator = { 'Punctuator': { _default: '$:%' } }
t.assertSurrounds('{a,...b} = c', punctuator, '${%a$,%$...%b$}% $=% c')
t.assertSurrounds('x={y,...z}', punctuator, 'x$=%${%y$,%$...%z$}%')
t.assertSurrounds('x ** y', punctuator, 'x $**% y')
t.assertSurrounds('x **= y', punctuator, 'x $**=% y')
t.end()
})
t.test('\n# Identifier', function(t) {
var identifier = { 'Identifier': { _default: '$:%' } }
t.assertSurrounds('{a,...b} = c', identifier, '{$a%,...$b%} = $c%')
t.assertSurrounds('x={y,...z}', identifier, '$x%={$y%,...$z%}')
t.end()
})
t.end()
})