Skip to content

Commit aadd501

Browse files
committed
fix comments test. Use mask lib
1 parent af8e325 commit aadd501

File tree

1 file changed

+97
-141
lines changed

1 file changed

+97
-141
lines changed

test/node/comments.test

+97-141
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,97 @@
1-
// workaround - @TODO atma loader import
2-
io
3-
.File
4-
.getHookHandler()
5-
.register({
6-
regexp: /js$/,
7-
method:'read',
8-
handler: 'importer',
9-
zIndex: 100
10-
});
11-
12-
include
13-
.cfg({
14-
loader: {
15-
js: {
16-
load: function(resource, callback){
17-
18-
callback(resource, io.File.read(resource.url));
19-
},
20-
process: function(source){
21-
return source;
22-
}
23-
}
24-
}
25-
})
26-
.inject(
27-
'/ref-utils/lib/utils.embed.js',
28-
29-
'/src/scope-vars.js',
30-
'/src/util/util.js',
31-
'/src/util/attr.js',
32-
'/src/util/template.js',
33-
'/src/util/string.js',
34-
'/src/util/condition.js',
35-
36-
'/src/util/listeners.js',
37-
'/src/util/reporters.js',
38-
39-
'/src/custom/exports.js',
40-
41-
'/src/dom/exports.js',
42-
'/src/parse/parser.js'
43-
)
44-
.done(function(){
45-
46-
UTest({
47-
48-
'inline-comment': function(){
49-
50-
var ast = Parser.parse(' //some');
51-
52-
eq(ast instanceof Dom.Fragment, true);
53-
eq(ast.nodes, null);
54-
55-
56-
ast = Parser.parse('div; // comment');
57-
eq(ast instanceof Dom.Fragment, false);
58-
eq(ast.tagName, 'div');
59-
eq(ast.nodes, null);
60-
61-
62-
ast = Parser.parse('div; //comment \n\
63-
span;');
64-
65-
assert(ast.nodes != null);
66-
67-
eq(ast.nodes.length, 2);
68-
eq(ast.nodes[1].tagName , 'span');
69-
70-
ast = Parser.parse('div //comment \n\
71-
foo=fvalue // comment \n\
72-
// x \n\
73-
bar=bvalue');
74-
75-
eq(ast.nodes, null);
76-
eq(ast.tagName, 'div');
77-
eq(Object.keys(ast.attr).length, 2);
78-
eq(ast.attr.foo, 'fvalue');
79-
eq(ast.attr.bar, 'bvalue');
80-
},
81-
82-
'block-comment': function(){
83-
84-
var ast = Parser.parse(' /* comment */');
85-
eq(ast instanceof Dom.Fragment, true);
86-
eq(ast.nodes, null);
87-
88-
ast = Parser.parse('div; /* comment */');
89-
eq(ast instanceof Dom.Fragment, false);
90-
eq(ast.tagName, 'div');
91-
eq(ast.nodes, null);
92-
93-
94-
ast = Parser.parse('div; \n\
95-
/* \n\
96-
comment \n\
97-
*/\n\
98-
span;');
99-
100-
assert(ast.nodes != null);
101-
102-
eq(ast.nodes.length, 2);
103-
eq(ast.nodes[1].tagName , 'span');
104-
105-
ast = Parser.parse('div /*\n\
106-
comment \n \
107-
1\n \
108-
2\n \
109-
\n \
110-
*/ \
111-
foo=fvalue /*\n\
112-
comment \n\
113-
*/ \n\
114-
bar=bvalue');
115-
116-
eq(ast.nodes, null);
117-
eq(ast.tagName, 'div');
118-
eq(Object.keys(ast.attr).length, 2);
119-
eq(ast.attr.foo, 'fvalue');
120-
eq(ast.attr.bar, 'bvalue');
121-
122-
ast = Parser.parse(' /*\n\
123-
comment \n \
124-
1\n \
125-
2\n \
126-
\n \
127-
*/ \
128-
div foo=fvalue /*\n\
129-
comment \n\
130-
*/ \n\
131-
bar=bvalue');
132-
133-
eq(ast.nodes, null);
134-
eq(ast.tagName, 'div');
135-
eq(Object.keys(ast.attr).length, 2);
136-
eq(ast.attr.foo, 'fvalue');
137-
eq(ast.attr.bar, 'bvalue');
138-
139-
}
140-
})
141-
})
1+
2+
UTest({
3+
4+
'inline-comment': function(){
5+
6+
var ast = mask.parse(' //some');
7+
8+
eq_(ast instanceof mask.Dom.Fragment, true);
9+
eq_(ast.nodes, null);
10+
11+
12+
ast = mask.parse('div; // comment');
13+
eq_(ast instanceof mask.Dom.Fragment, false);
14+
eq_(ast.tagName, 'div');
15+
eq_(ast.nodes, null);
16+
17+
18+
ast = mask.parse('div; //comment \n\
19+
span;');
20+
21+
assert(ast.nodes != null);
22+
23+
eq_(ast.nodes.length, 2);
24+
eq_(ast.nodes[1].tagName , 'span');
25+
26+
ast = mask.parse('div //comment \n\
27+
foo=fvalue // comment \n\
28+
// x \n\
29+
bar=bvalue');
30+
31+
eq_(ast.nodes, null);
32+
eq_(ast.tagName, 'div');
33+
eq_(Object.keys(ast.attr).length, 2);
34+
eq_(ast.attr.foo, 'fvalue');
35+
eq_(ast.attr.bar, 'bvalue');
36+
},
37+
38+
'block-comment': function(){
39+
40+
var ast = mask.parse(' /* comment */');
41+
eq_(ast instanceof mask.Dom.Fragment, true);
42+
eq_(ast.nodes, null);
43+
44+
ast = mask.parse('div; /* comment */');
45+
eq_(ast instanceof mask.Dom.Fragment, false);
46+
eq_(ast.tagName, 'div');
47+
eq_(ast.nodes, null);
48+
49+
50+
ast = mask.parse('div; \n\
51+
/* \n\
52+
comment \n\
53+
*/\n\
54+
span;');
55+
56+
assert(ast.nodes != null);
57+
58+
eq_(ast.nodes.length, 2);
59+
eq_(ast.nodes[1].tagName , 'span');
60+
61+
ast = mask.parse('div /*\n\
62+
comment \n \
63+
1\n \
64+
2\n \
65+
\n \
66+
*/ \
67+
foo=fvalue /*\n\
68+
comment \n\
69+
*/ \n\
70+
bar=bvalue');
71+
72+
eq_(ast.nodes, null);
73+
eq_(ast.tagName, 'div');
74+
eq_(Object.keys(ast.attr).length, 2);
75+
eq_(ast.attr.foo, 'fvalue');
76+
eq_(ast.attr.bar, 'bvalue');
77+
78+
ast = mask.parse(' /*\n\
79+
comment \n \
80+
1\n \
81+
2\n \
82+
\n \
83+
*/ \
84+
div foo=fvalue /*\n\
85+
comment \n\
86+
*/ \n\
87+
bar=bvalue');
88+
89+
eq_(ast.nodes, null);
90+
eq_(ast.tagName, 'div');
91+
eq_(Object.keys(ast.attr).length, 2);
92+
eq_(ast.attr.foo, 'fvalue');
93+
eq_(ast.attr.bar, 'bvalue');
94+
95+
}
96+
})
97+

0 commit comments

Comments
 (0)