cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-09-18 15:57:06 +03:00
parent 8f42025fc7
commit 6a69983cc8

120
test.js
View File

@ -702,128 +702,10 @@ var cases = test.Cases({
},
// text utils...
/* XXX might be a good idea to do a separate test suite for this to
// XXX might be a good idea to do a separate test suite for this to
// be able to reference individual cases...
// ...or to re-organize this thing differently....
// XXX still need to test tab_size values (0, ...)
text_cases: [
// sanity checks...
{ input: '',
all: ''},
{ input: 'abc',
all: 'abc'},
{ input: '\n\t\tabc',
all: 'abc'},
// NOTE: there is no way to know what is the indent of 'a'
// relative to the rest of the text...
{ input: `a
c`,
text: 'a\nc',
doc: 'a\n c'},
{ input: `a\nc`,
text: 'a\nc',
doc: 'a\nc'},
{ input: `\
a
c`,
all: 'a\n c'},
{ input: `
a
c`,
all: 'a\n c'},
{ input: `
a
c`,
all: 'a\n c' },
{ input: `a
b
c`,
text: 'a\nb\nc',
doc: 'a\n b\n c' },
{ input: `
a
b
c`,
all: 'a\nb\n c' },
{ input: `
a
b
c`,
all: 'a\n b\n c' },
{ input: `a
b
c`,
all: `a\n b\nc` },
{ input: `a
b
c`,
all: `a\nb\n c` },
{ input: `
a
b
c`,
all: `a\n b\n c` },
{ input: `a
b
b
b
c`,
all: `a\n b\n b\n b\nc` },
{ input: `a
b
b
b
c`,
all: `a\n b\n b\n b\nc` },
{ input: `
a
b
c`,
all: `a\n b\nc` },
{ input: `a
b
c
d`,
text: `a\n b\nc\nd`,
// XXX not sure about this...
doc: `a\n b\n c\n d` },
],
text: function(assert){
this.text_cases
.map(function({input, doc, text, all}, i){
doc = doc != null ?
doc
: all
text = text != null ?
text
: all
var test = function(func, input, expect){
var res
return assert((res = object[func](input)) == expect,
func +'(text_cases['+i+']):'
+'\n---input---\n'
+ (input instanceof Array ?
input[0]
: input)
+'\n---Expected---\n'
+ expect
+'\n---Got---\n'
+ res
+'\n---') }
doc != null
&& test('normalizeIndent', input, doc)
&& test('doc', [input], doc)
text != null
&& test('normalizeTextIndent', input, text)
&& test('text', [input], text) }) },
//*/
// XXX naming is not clear -- should be close to automatic...
// XXX still need to test tab_size values (0, ...)
// sanity checks...