mirror of
https://github.com/flynx/object.js.git
synced 2025-10-30 02:50:10 +00:00
bugfix...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
dce24493ff
commit
d6d8492cd6
@ -92,7 +92,8 @@ function(text, tab_size, leading_tabs){
|
|||||||
: text
|
: text
|
||||||
// trim the tail and remove leading blank lines...
|
// trim the tail and remove leading blank lines...
|
||||||
var lines = text.trimEnd().split(/\n/)
|
var lines = text.trimEnd().split(/\n/)
|
||||||
while(lines[0].trim() == ''){
|
while(lines.length > 0
|
||||||
|
&& lines[0].trim() == ''){
|
||||||
// XXX we have two options here:
|
// XXX we have two options here:
|
||||||
// - indent everyline including the first non-blank
|
// - indent everyline including the first non-blank
|
||||||
// - do not indent anything (current)
|
// - do not indent anything (current)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ig-object",
|
"name": "ig-object",
|
||||||
"version": "5.2.7",
|
"version": "5.2.8",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "object.js",
|
"main": "object.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
41
test.js
41
test.js
@ -673,6 +673,8 @@ var cases = test.Cases({
|
|||||||
// XXX still need to test tab_size values (0, ...)
|
// XXX still need to test tab_size values (0, ...)
|
||||||
text_cases: [
|
text_cases: [
|
||||||
// sanity checks...
|
// sanity checks...
|
||||||
|
{ input: '',
|
||||||
|
all: ''},
|
||||||
{ input: 'abc',
|
{ input: 'abc',
|
||||||
all: 'abc'},
|
all: 'abc'},
|
||||||
{ input: '\n\t\tabc',
|
{ input: '\n\t\tabc',
|
||||||
@ -758,28 +760,33 @@ var cases = test.Cases({
|
|||||||
text: function(assert){
|
text: function(assert){
|
||||||
this.text_cases
|
this.text_cases
|
||||||
.map(function({input, doc, text, all}, i){
|
.map(function({input, doc, text, all}, i){
|
||||||
var res
|
doc = doc != null ?
|
||||||
|
doc
|
||||||
|
: all
|
||||||
|
text = text != null ?
|
||||||
|
text
|
||||||
|
: all
|
||||||
|
|
||||||
;(doc || all)
|
var test = function(func, input, expect){
|
||||||
&& assert((res = object.doc([input])) == (doc || all),
|
var res
|
||||||
'doc(text_cases['+i+']):'
|
return assert((res = object[func](input)) == expect,
|
||||||
|
func +'(text_cases['+i+']):'
|
||||||
+'\n---input---\n'
|
+'\n---input---\n'
|
||||||
+ input
|
+ (input instanceof Array ?
|
||||||
|
input[0]
|
||||||
|
: input)
|
||||||
+'\n---Expected---\n'
|
+'\n---Expected---\n'
|
||||||
+ (doc || all)
|
+ expect
|
||||||
+'\n---Got---\n'
|
+'\n---Got---\n'
|
||||||
+ res
|
+ res
|
||||||
+'\n---')
|
+'\n---') }
|
||||||
;(text || all)
|
|
||||||
&& assert((res = object.text([input])) == (text || all),
|
doc != null
|
||||||
'text(text_cases['+i+']):'
|
&& test('normalizeIndent', input, doc)
|
||||||
+'\n---input---\n'
|
&& test('doc', [input], doc)
|
||||||
+ input
|
text != null
|
||||||
+'\n---Expected---\n'
|
&& test('normalizeTextIndent', input, text)
|
||||||
+ (text || all)
|
&& test('text', [input], text) }) },
|
||||||
+'\n---Got---\n'
|
|
||||||
+ res
|
|
||||||
+'\n---') }) },
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user