mirror of
https://github.com/flynx/object.js.git
synced 2025-10-30 11:00:08 +00:00
minor fixes, still not done yet...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
d0d87f223f
commit
8a9a62d9f3
@ -67,6 +67,7 @@ module.LEADING_TABS = 1
|
|||||||
// | return a + b } | return a + b
|
// | return a + b } | return a + b
|
||||||
// | |}
|
// | |}
|
||||||
//
|
//
|
||||||
|
//
|
||||||
// NOTE: this will trim out both leading and trailing white-space.
|
// NOTE: this will trim out both leading and trailing white-space.
|
||||||
// NOTE: this is generally code-agnostic with one sigificant
|
// NOTE: this is generally code-agnostic with one sigificant
|
||||||
// exception -- normalizeIndent(..) will break code written
|
// exception -- normalizeIndent(..) will break code written
|
||||||
@ -100,10 +101,12 @@ function(text, tab_size, leading_tabs){
|
|||||||
return e.trim().length == 0
|
return e.trim().length == 0
|
||||||
// ignore 0 indent of first line...
|
// ignore 0 indent of first line...
|
||||||
|| (i == 0 && indent == 0) ?
|
|| (i == 0 && indent == 0) ?
|
||||||
l
|
l || indent
|
||||||
// last line -- ignore leading_tabs if lower indent...
|
// last line -- ignore leading_tabs if lower indent...
|
||||||
: i == lines.length-1 && indent > l ?
|
// XXX BUG this does messes things up for 2 liners...
|
||||||
Math.max(l-leading_tabs, 0)
|
: i == lines.length-1
|
||||||
|
&& indent >= l ?
|
||||||
|
Math.max(indent - leading_tabs, 0)
|
||||||
// initial state...
|
// initial state...
|
||||||
: l < 0 ?
|
: l < 0 ?
|
||||||
indent
|
indent
|
||||||
|
|||||||
41
test.js
41
test.js
@ -672,31 +672,34 @@ var cases = test.Cases({
|
|||||||
assert(xx.call(null), 'xx.call(null)')
|
assert(xx.call(null), 'xx.call(null)')
|
||||||
},
|
},
|
||||||
|
|
||||||
// XXX two-liners still not fully passing...
|
|
||||||
text_cases: [
|
text_cases: [
|
||||||
// NOTE: there is no way to know what is the indent of 'a'
|
// NOTE: there is no way to know what is the indent of 'a'
|
||||||
// relative to the rest of the text...
|
// relative to the rest of the text...
|
||||||
// ...without reading the source file, and that should
|
// ...without reading the source file, and that should
|
||||||
// be avoided.
|
// be avoided.
|
||||||
// XXX FAIL: for some reason the two line case does not work...
|
|
||||||
{ input: `a
|
{ input: `a
|
||||||
c`,
|
c`,
|
||||||
all: 'a\nc', },
|
text: 'a\nc',
|
||||||
|
doc: 'a\n c'},
|
||||||
{ input: `a
|
|
||||||
c`,
|
|
||||||
all: 'a\nc' },
|
|
||||||
|
|
||||||
{ input: `a
|
{ input: `a
|
||||||
b
|
b
|
||||||
c`,
|
c`,
|
||||||
all: 'a\nb\nc' },
|
text: 'a\nb\nc',
|
||||||
|
doc: 'a\n b\n c' },
|
||||||
|
|
||||||
|
|
||||||
|
// XXX text(..): c is not indented...
|
||||||
{ input: `
|
{ input: `
|
||||||
a
|
a
|
||||||
c`,
|
c`,
|
||||||
all: 'a\n c' },
|
all: 'a\n c' },
|
||||||
|
// XXX text(..): losing all lines but 0 and -1...
|
||||||
|
// XXX text(..): c is not indented...
|
||||||
|
{ input: `
|
||||||
|
a
|
||||||
|
b
|
||||||
|
c`,
|
||||||
|
all: 'a\nb\n c' },
|
||||||
|
|
||||||
{ input: `a
|
{ input: `a
|
||||||
b
|
b
|
||||||
@ -710,16 +713,24 @@ var cases = test.Cases({
|
|||||||
|
|
||||||
;(doc || all)
|
;(doc || all)
|
||||||
&& assert((res = object.doc([input])) == (doc || all),
|
&& assert((res = object.doc([input])) == (doc || all),
|
||||||
'doc(text_cases['+i+']):\n'
|
'doc(text_cases['+i+']):'
|
||||||
|
+'\n---input---\n'
|
||||||
|
+ input
|
||||||
|
+'\n---Expected---\n'
|
||||||
|
+ (doc || all)
|
||||||
|
+'\n---Got---\n'
|
||||||
+ res
|
+ res
|
||||||
+'\n---\n'
|
+'\n---')
|
||||||
+ (doc || all))
|
|
||||||
;(text || all)
|
;(text || all)
|
||||||
&& assert((res = object.text([input])) == (text || all),
|
&& assert((res = object.text([input])) == (text || all),
|
||||||
'text(text_cases['+i+']):\n'
|
'text(text_cases['+i+']):'
|
||||||
|
+'\n---input---\n'
|
||||||
|
+ input
|
||||||
|
+'\n---Expected---\n'
|
||||||
|
+ (text || all)
|
||||||
|
+'\n---Got---\n'
|
||||||
+ res
|
+ res
|
||||||
+'\n---\n'
|
+'\n---') }) },
|
||||||
+ (text || all)) }) },
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user