mirror of
https://github.com/flynx/object.js.git
synced 2025-10-29 10:30:08 +00:00
tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
89121f306c
commit
c2d2afc398
81
test.js
81
test.js
@ -61,10 +61,28 @@ var instances = function(obj){
|
|||||||
&& k[0] == k[0].toLowerCase()
|
&& k[0] == k[0].toLowerCase()
|
||||||
&& o.constructor }) }
|
&& o.constructor }) }
|
||||||
|
|
||||||
|
// data wrapper...
|
||||||
|
var data = function(d){ return d }
|
||||||
|
|
||||||
|
// text test runner...
|
||||||
|
var testText = function(assert, func, input, expect){
|
||||||
|
var res
|
||||||
|
return assert((res = object[func](input)) == expect,
|
||||||
|
func +'(..):'
|
||||||
|
+'\n---input---\n'
|
||||||
|
+ (input instanceof Array ?
|
||||||
|
input[0]
|
||||||
|
: input)
|
||||||
|
+'\n---Expected---\n'
|
||||||
|
+ expect
|
||||||
|
+'\n---Got---\n'
|
||||||
|
+ res
|
||||||
|
+'\n---') }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// Tests...
|
// General tests...
|
||||||
|
|
||||||
var setups = test.Setups({
|
var setups = test.Setups({
|
||||||
// basic constructor and inheritance...
|
// basic constructor and inheritance...
|
||||||
@ -674,14 +692,10 @@ var cases = test.Cases({
|
|||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// text utils...
|
// Text util tests...
|
||||||
// XXX should we split this out???
|
|
||||||
|
|
||||||
var text = test.TestSet()
|
var text = test.TestSet()
|
||||||
|
test.Case('text', text)
|
||||||
|
|
||||||
// helper...
|
|
||||||
var t = function(d){ return d }
|
|
||||||
|
|
||||||
// XXX still need to test tab_size values (0, ...)
|
// XXX still need to test tab_size values (0, ...)
|
||||||
// ...a good candidate for modifiers...
|
// ...a good candidate for modifiers...
|
||||||
@ -689,100 +703,100 @@ var t = function(d){ return d }
|
|||||||
// XXX still need to test tab_size values (0, ...)
|
// XXX still need to test tab_size values (0, ...)
|
||||||
text.setups({
|
text.setups({
|
||||||
// sanity checks...
|
// sanity checks...
|
||||||
'""': t({
|
'""': data({
|
||||||
input: '',
|
input: '',
|
||||||
all: '', }),
|
all: '', }),
|
||||||
'"abc"': t({
|
'"abc"': data({
|
||||||
input: 'abc',
|
input: 'abc',
|
||||||
all: 'abc'}),
|
all: 'abc'}),
|
||||||
'leading whitespace': t({
|
'leading whitespace': data({
|
||||||
input: '\n\t\tabc',
|
input: '\n\t\tabc',
|
||||||
all: 'abc'}),
|
all: 'abc'}),
|
||||||
|
|
||||||
// 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...
|
||||||
text_04: t({
|
text_04: data({
|
||||||
input: `a
|
input: `a
|
||||||
c`,
|
c`,
|
||||||
text: 'a\nc',
|
text: 'a\nc',
|
||||||
doc: 'a\n c'}),
|
doc: 'a\n c'}),
|
||||||
text_05: t({
|
text_05: data({
|
||||||
input: `a\nc`,
|
input: `a\nc`,
|
||||||
text: 'a\nc',
|
text: 'a\nc',
|
||||||
doc: 'a\nc'}),
|
doc: 'a\nc'}),
|
||||||
text_06: t({
|
text_06: data({
|
||||||
input: `\
|
input: `\
|
||||||
a
|
a
|
||||||
c`,
|
c`,
|
||||||
all: 'a\n c'}),
|
all: 'a\n c'}),
|
||||||
text_07: t({
|
text_07: data({
|
||||||
input: `
|
input: `
|
||||||
a
|
a
|
||||||
c`,
|
c`,
|
||||||
all: 'a\n c'}),
|
all: 'a\n c'}),
|
||||||
text_08: t({
|
text_08: data({
|
||||||
input: `
|
input: `
|
||||||
a
|
a
|
||||||
c`,
|
c`,
|
||||||
all: 'a\n c' }),
|
all: 'a\n c' }),
|
||||||
|
|
||||||
text_09: t({
|
text_09: data({
|
||||||
input: `a
|
input: `a
|
||||||
b
|
b
|
||||||
c`,
|
c`,
|
||||||
text: 'a\nb\nc',
|
text: 'a\nb\nc',
|
||||||
doc: 'a\n b\n c' }),
|
doc: 'a\n b\n c' }),
|
||||||
|
|
||||||
text_10: t({
|
text_10: data({
|
||||||
input: `
|
input: `
|
||||||
a
|
a
|
||||||
b
|
b
|
||||||
c`,
|
c`,
|
||||||
all: 'a\nb\n c' }),
|
all: 'a\nb\n c' }),
|
||||||
text_11: t({
|
text_11: data({
|
||||||
input: `
|
input: `
|
||||||
a
|
a
|
||||||
b
|
b
|
||||||
c`,
|
c`,
|
||||||
all: 'a\n b\n c' }),
|
all: 'a\n b\n c' }),
|
||||||
|
|
||||||
text_12: t({
|
text_12: data({
|
||||||
input: `a
|
input: `a
|
||||||
b
|
b
|
||||||
c`,
|
c`,
|
||||||
all: `a\n b\nc` }),
|
all: `a\n b\nc` }),
|
||||||
text_13: t({
|
text_13: data({
|
||||||
input: `a
|
input: `a
|
||||||
b
|
b
|
||||||
c`,
|
c`,
|
||||||
all: `a\nb\n c` }),
|
all: `a\nb\n c` }),
|
||||||
text_14: t({
|
text_14: data({
|
||||||
input: `
|
input: `
|
||||||
a
|
a
|
||||||
b
|
b
|
||||||
c`,
|
c`,
|
||||||
all: `a\n b\n c` }),
|
all: `a\n b\n c` }),
|
||||||
text_15: t({
|
text_15: data({
|
||||||
input: `a
|
input: `a
|
||||||
b
|
b
|
||||||
b
|
b
|
||||||
b
|
b
|
||||||
c`,
|
c`,
|
||||||
all: `a\n b\n b\n b\nc` }),
|
all: `a\n b\n b\n b\nc` }),
|
||||||
text_16: t({
|
text_16: data({
|
||||||
input: `a
|
input: `a
|
||||||
b
|
b
|
||||||
b
|
b
|
||||||
b
|
b
|
||||||
c`,
|
c`,
|
||||||
all: `a\n b\n b\n b\nc` }),
|
all: `a\n b\n b\n b\nc` }),
|
||||||
text_17: t({
|
text_17: data({
|
||||||
input: `
|
input: `
|
||||||
a
|
a
|
||||||
b
|
b
|
||||||
c`,
|
c`,
|
||||||
all: `a\n b\nc` }),
|
all: `a\n b\nc` }),
|
||||||
text_18: t({
|
text_18: data({
|
||||||
input: `a
|
input: `a
|
||||||
b
|
b
|
||||||
c
|
c
|
||||||
@ -793,20 +807,6 @@ text.setups({
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
var testText = function(assert, func, input, expect){
|
|
||||||
var res
|
|
||||||
return assert((res = object[func](input)) == expect,
|
|
||||||
func +'(..):'
|
|
||||||
+'\n---input---\n'
|
|
||||||
+ (input instanceof Array ?
|
|
||||||
input[0]
|
|
||||||
: input)
|
|
||||||
+'\n---Expected---\n'
|
|
||||||
+ expect
|
|
||||||
+'\n---Got---\n'
|
|
||||||
+ res
|
|
||||||
+'\n---') }
|
|
||||||
|
|
||||||
text.tests({
|
text.tests({
|
||||||
doc: function(assert, data){
|
doc: function(assert, data){
|
||||||
var e = data.doc != null ?
|
var e = data.doc != null ?
|
||||||
@ -825,9 +825,6 @@ text.tests({
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
test.Case('text', text)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user