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 = tab != '' ?
|
||||||
text.replace(/\t/g, tab)
|
text.replace(/\t/g, tab)
|
||||||
: text
|
: text
|
||||||
|
// trim the tail and remove leading blank lines...
|
||||||
var lines = text.trimEnd().split(/\n/)
|
var lines = text.trimEnd().split(/\n/)
|
||||||
// remove leading blank lines...
|
|
||||||
while(lines[0].trim() == ''){
|
while(lines[0].trim() == ''){
|
||||||
lines.shift() }
|
lines.shift() }
|
||||||
// count common indent...
|
// count common indent...
|
||||||
|
|||||||
56
test.js
56
test.js
@ -673,20 +673,52 @@ var cases = test.Cases({
|
|||||||
},
|
},
|
||||||
|
|
||||||
text_cases: [
|
text_cases: [
|
||||||
[`a
|
// NOTE: there is no way to know what is the indent of 'a'
|
||||||
b
|
// relative to the rest of the text...
|
||||||
c`,
|
// ...without reading the source file, and that should
|
||||||
'a\n\tb\nc'],
|
// be avoided.
|
||||||
[`a
|
// XXX FAIL: for some reason the two line case does not work...
|
||||||
b
|
{ input: `a
|
||||||
c`,
|
c`,
|
||||||
'a\n\tb\n\tc'],
|
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){
|
text: function(assert){
|
||||||
this.text_cases.map(function([orig, target]){
|
this.text_cases
|
||||||
assert(object.doc([orig]) == target)
|
.map(function({input, doc, text, all}, i){
|
||||||
assert(object.text([orig]) == target)
|
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