mirror of
https://github.com/flynx/object.js.git
synced 2025-10-29 10:30:08 +00:00
reworked text testing, still failing some tests, not yet sure if the error is in the test or in code...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2429835d92
commit
43e70f817e
@ -89,8 +89,8 @@ function(text, tab_size, leading_tabs){
|
||||
text = tab != '' ?
|
||||
text.replace(/\t/g, tab)
|
||||
: text
|
||||
// trim the tail and remove leading blank lines...
|
||||
var lines = text.trimEnd().split(/\n/)
|
||||
// remove leading blank lines...
|
||||
while(lines[0].trim() == ''){
|
||||
lines.shift() }
|
||||
// count common indent...
|
||||
|
||||
56
test.js
56
test.js
@ -673,20 +673,52 @@ var cases = test.Cases({
|
||||
},
|
||||
|
||||
text_cases: [
|
||||
[`a
|
||||
b
|
||||
c`,
|
||||
'a\n\tb\nc'],
|
||||
[`a
|
||||
b
|
||||
c`,
|
||||
'a\n\tb\n\tc'],
|
||||
// NOTE: there is no way to know what is the indent of 'a'
|
||||
// relative to the rest of the text...
|
||||
// ...without reading the source file, and that should
|
||||
// be avoided.
|
||||
// XXX FAIL: for some reason the two line case does not work...
|
||||
{ input: `a
|
||||
c`,
|
||||
all: 'a\nc', },
|
||||
{ input: `a
|
||||
c`,
|
||||
all: 'a\nc' },
|
||||
|
||||
{ input: `a
|
||||
b
|
||||
c`,
|
||||
all: 'a\nb\nc' },
|
||||
|
||||
|
||||
{ input: `
|
||||
a
|
||||
c`,
|
||||
all: 'a\n c' },
|
||||
|
||||
{ input: `a
|
||||
b
|
||||
c`,
|
||||
all: `a\n b\nc` },
|
||||
],
|
||||
text: function(assert){
|
||||
this.text_cases.map(function([orig, target]){
|
||||
assert(object.doc([orig]) == target)
|
||||
assert(object.text([orig]) == target)
|
||||
})
|
||||
this.text_cases
|
||||
.map(function({input, doc, text, all}, i){
|
||||
var res
|
||||
|
||||
;(doc || all)
|
||||
&& assert((res = object.doc([input])) == (doc || all),
|
||||
'doc(text_cases['+i+']):\n'
|
||||
+ res
|
||||
+'\n---\n'
|
||||
+ (doc || all))
|
||||
;(text || all)
|
||||
&& assert((res = object.text([input])) == (text || all),
|
||||
'text(text_cases['+i+']):\n'
|
||||
+ res
|
||||
+'\n---\n'
|
||||
+ (text || all))
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user