15 lines
562 B
JavaScript
15 lines
562 B
JavaScript
'use strict'
|
|||
|
|
|
||
|
|
const assert = require('assert')
|
||
|
|
const { quote, parse } = require('./cable_hyperswarm')
|
||
|
|
|
||
|
|
for (const value of [
|
||
|
|
'', 'plain text', 'quote " slash \\', 'line one\nline two',
|
||
|
|
'tabs\tand\bbackspace\f formfeed\r', 'Unicode: 媒腻㐤┖ꈳ埳 🐬'
|
||
|
|
]) {
|
||
|
|
assert.deepStrictEqual(parse('(send "general" ' + quote(value) + ')'), ['send', 'general', value])
|
||
|
|
}
|
||
|
|
|
||
|
|
assert.throws(() => parse('(send "unterminated)'), /unterminated/)
|
||
|
|
assert.throws(() => parse('(send "bad\\q")'), /unsupported S-expression escape/)
|
||
|
|
console.log('Cable S-expression IPC: PASS')
|