Author: jfroche
Date: Tue Aug 28 21:24:52 2007
New Revision: 46106
Added:
kukit/kukit.js/branch/commas-in-selectors/tests/browserstub.js
- copied unchanged from r46103, kukit/kukit.js/trunk/tests/browserstub.js
kukit/kukit.js/branch/commas-in-selectors/tests/develui.css
- copied unchanged from r46103, kukit/kukit.js/trunk/tests/develui.css
Modified:
kukit/kukit.js/branch/commas-in-selectors/kukit/kssparser.js
kukit/kukit.js/branch/commas-in-selectors/kukit/plugin.js
kukit/kukit.js/branch/commas-in-selectors/kukit/resourcedata.js
kukit/kukit.js/branch/commas-in-selectors/tests/runner.html
kukit/kukit.js/branch/commas-in-selectors/tests/runtests.sh
kukit/kukit.js/branch/commas-in-selectors/tests/test_kssparser.js
Log:
merge r46034:r46103 from trunk
Modified: kukit/kukit.js/branch/commas-in-selectors/kukit/kssparser.js
==============================================================================
--- kukit/kukit.js/branch/commas-in-selectors/kukit/kssparser.js
(original)
+++ kukit/kukit.js/branch/commas-in-selectors/kukit/kssparser.js Tue Aug
28 21:24:52 2007
@@ -508,6 +508,7 @@
'"': 'new kukit.kssp.String2(this.cursor, kukit.kssp.dquote)',
",": 'new kukit.kssp.comma(this.cursor)',
")": 'this.emitAndReturn(new kukit.kssp.closeParent(this.cursor))',
+ "(": 'new kukit.kssp.MethodArgs(this.cursor, kukit.kssp.openParent)',
"\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)'
});
kukit.kssp.MethodArgs.prototype.process = function() {
@@ -532,7 +533,21 @@
this.emitError(kukit.E);
}
}
- this.args.push(value);
+ var valueClass;
+ var args;
+ var providedValue;
+ if (this.notInTokens(context, kukit.kssp.MethodArgs)){
+ this.expectToken(context, kukit.kssp.MethodArgs);
+ valueClass = kukit.rd.KssMethodValue;
+ args = context.token.args;
+ providedValue = new valueClass(value, args);
+ } else {
+ // XXX This should be wrapped too !
+ //valueClass = kukit.rd.KssTextValue;
+ //providedValue = new valueClass(value);
+ providedValue = value;
+ }
+ this.args.push(providedValue);
if (context.nextTokenIndex == this.result.length-1) break;
this.expectToken(context, kukit.kssp.comma);
}
Modified: kukit/kukit.js/branch/commas-in-selectors/kukit/plugin.js
==============================================================================
--- kukit/kukit.js/branch/commas-in-selectors/kukit/plugin.js (original)
+++ kukit/kukit.js/branch/commas-in-selectors/kukit/plugin.js Tue Aug 28
21:24:52 2007
@@ -83,7 +83,7 @@
if (! eventName)
eventName = oper.getEventName();
var func = function(e) {
- target = kukit.pl.getTargetForBrowserEvent(e);
+ var target = kukit.pl.getTargetForBrowserEvent(e);
if (oper.parms.allowbubbling || target == oper.node) {
// Execute the action, provide browserevent on oper
// ... however, do it protected. We want the preventdefault
Modified: kukit/kukit.js/branch/commas-in-selectors/kukit/resourcedata.js
==============================================================================
--- kukit/kukit.js/branch/commas-in-selectors/kukit/resourcedata.js
(original)
+++ kukit/kukit.js/branch/commas-in-selectors/kukit/resourcedata.js Tue Aug
28 21:24:52 2007
@@ -111,12 +111,11 @@
};
kukit.rd.KssTextValue.prototype.evaluate =
- function(parms, key, node, defaultParameters) {
-
+ function(node, defaultParameters) {
// For normal string parms, this would return the string itself.
// In other execution contexts (like kssSelector, for example) this can
// do something else.
- parms[key] = this.pprovider.eval([this.txt], node, defaultParameters);
+ return this.pprovider.eval([this.txt], node, defaultParameters);
};
/*
@@ -135,14 +134,37 @@
// Check syntax
var f = registry.get(this.methodName);
this.pprovider = new f();
+ for(i=0; i < this.args.length; i++){
+ // XXX We treat text values separetly because
+ // they are now currently wrapped as KssTextValue
+ // (as they should). TODO
+ var arg = this.args[i];
+ if(arg.check){
+ // With the recursion we always use the global
+ // provider registry
+ arg.check(kukit.pprovidersGlobalRegistry);
+ }
+ }
;;; this.pprovider.check(this.args);
};
kukit.rd.KssMethodValue.prototype.evaluate =
- function(parms, key, node, defaultParameters) {
-
- // Evaluate into parms.
- parms[key] = this.pprovider.eval(this.args, node, defaultParameters);
+ function(node, defaultParameters) {
+ // First recursivly evaluate all arguments
+ var newArgs = [];
+ for(var i=0; i < this.args.length; i++){
+ // XXX We treat text values separetly because
+ // they are now currently wrapped as KssTextValue
+ // (as they should). TODO
+ var arg = this.args[i];
+ if(arg.evaluate){
+ newArgs.push(arg.evaluate(node, defaultParameters));
+ } else {
+ newArgs.push(arg);
+ }
+ }
+ // return the value
+ return this.pprovider.eval(newArgs, node, defaultParameters);
};
/*
@@ -521,11 +543,11 @@
var kssvalue = this.parms[key];
if (key.match(/^kss/)) {
// kssXxx parms are separated to kssParms.
- kssvalue.evaluate(kssParms, key, oper.node,
+ kssParms[key] = kssvalue.evaluate(oper.node,
oper.defaultParameters);
} else {
// evaluate the method parms into parms
- kssvalue.evaluate(parms, key, oper.node,
+ parms[key] = kssvalue.evaluate(oper.node,
oper.defaultParameters);
}
}
Modified: kukit/kukit.js/branch/commas-in-selectors/tests/runner.html
==============================================================================
--- kukit/kukit.js/branch/commas-in-selectors/tests/runner.html (original)
+++ kukit/kukit.js/branch/commas-in-selectors/tests/runner.html Tue Aug 28
21:24:52 2007
@@ -21,16 +21,27 @@
</style>
<link rel="stylesheet" type="text/css"
- tal:attributes="href
string:${context/@@absolute_url}/@@kss_devel_mode/ui_css"/>
+ tal:attributes="href
string:${context/@@absolute_url}/@@kss_devel_mode/ui_css"
+ href="develui.css"/>
<script type="text/javascript" src="ecmaunit.js"> </script>
<script type="text/javascript" src="unittestUtilities.js"> </script>
-
+ <script type="text/javascript"
+ tal:attributes="src
+
string:${context/@@absolute_url}/++resource++firebuglite/firebug.js;"
+ src="../3rd_party/firebuglite/firebug.js">
+ </script>
+
+ <script type="text/javascript"
+ tal:attributes="src
string:${context/@@absolute_url}/++resource++base2-dom-fp.js;"
+ src="../3rd_party/base2-dom-fp.js">
+ </script>
<script tal:define="kss_devel_mode nocall:context/@@kss_devel_mode |
nothing"
tal:condition="python: not kss_devel_mode or
kss_devel_mode.isoff()" type="text/javascript"
tal:attributes="src
string:${context/@@absolute_url}/++resource++kukit.js;"
src="../kukit/utils.js">
- </script>
+ </script>
+
<script tal:define="kss_devel_mode nocall:context/@@kss_devel_mode |
nothing"
tal:condition="python: kss_devel_mode and
kss_devel_mode.ison()" type="text/javascript"
tal:attributes="src
string:${context/@@absolute_url}/++resource++kukit-devel.js;"
@@ -82,8 +93,10 @@
KSS ECMAScript Unit Tests
</h1>
- <p tal:define="kss_devel_mode nocall:context/@@kss_devel_mode | nothing;
- devel_mode python: kss_devel_mode and
kss_devel_mode.ison()">
+ <p style="display:none;"
+ tal:define="kss_devel_mode nocall:context/@@kss_devel_mode | nothing;
+ devel_mode python: kss_devel_mode and
kss_devel_mode.ison()"
+ tal:attributes="style string:display:block;;;">
Kss is in <b>
<span class="green" tal:condition="devel_mode">development</span>
<span class="red" tal:condition="not: devel_mode">production</span>
@@ -97,7 +110,8 @@
</p>
<p class="documentInfo" tal:content="string:Tests are running with the
kukit.js provided by kss.">
- Tests are running from the filesystem.
+ Tests are running from the filesystem.<br/>
+ KSS is running in development (uncooked) mode.
</p>
<div>
Modified: kukit/kukit.js/branch/commas-in-selectors/tests/runtests.sh
==============================================================================
--- kukit/kukit.js/branch/commas-in-selectors/tests/runtests.sh (original)
+++ kukit/kukit.js/branch/commas-in-selectors/tests/runtests.sh Tue Aug 28
21:24:52 2007
@@ -1,26 +1,28 @@
js \
- -f ecmaunit.js \
- -f unittestUtilities.js \
- -f ../kukit/utils.js \
- -f ../kukit/errors.js \
- -f ../kukit/oper.js \
- -f ../kukit/kukit.js \
- -f ../kukit/tokenizer.js \
- -f ../kukit/providerreg.js \
- -f ../kukit/resourcedata.js \
- -f ../kukit/kssparser.js \
- -f ../kukit/eventreg.js \
- -f ../kukit/actionreg.js \
- -f ../kukit/dom.js \
- -f ../kukit/commandreg.js \
- -f ../kukit/serveraction.js \
- -f ../kukit/requestmanager.js \
- -f ../kukit/commandprocessor.js \
- -f ../kukit/selectorreg.js \
- -f ../kukit/forms.js \
- -f ../kukit/plugin.js \
- -f test_utils.js \
- -f test_requestmanager.js \
- -f test_tokenizer.js \
- -f test_kssparser.js \
- runtests.js
+ -f ecmaunit.js \
+ -f unittestUtilities.js \
+ -f browserstub.js \
+ -f ../3rd_party/base2-dom-fp.js \
+ -f ../kukit/utils.js \
+ -f ../kukit/errors.js \
+ -f ../kukit/oper.js \
+ -f ../kukit/kukit.js \
+ -f ../kukit/tokenizer.js \
+ -f ../kukit/providerreg.js \
+ -f ../kukit/resourcedata.js \
+ -f ../kukit/kssparser.js \
+ -f ../kukit/eventreg.js \
+ -f ../kukit/actionreg.js \
+ -f ../kukit/dom.js \
+ -f ../kukit/commandreg.js \
+ -f ../kukit/serveraction.js \
+ -f ../kukit/requestmanager.js \
+ -f ../kukit/commandprocessor.js \
+ -f ../kukit/selectorreg.js \
+ -f ../kukit/forms.js \
+ -f ../kukit/plugin.js \
+ -f test_utils.js \
+ -f test_requestmanager.js \
+ -f test_tokenizer.js \
+ -f test_kssparser.js \
+ runtests.js
Modified: kukit/kukit.js/branch/commas-in-selectors/tests/test_kssparser.js
==============================================================================
--- kukit/kukit.js/branch/commas-in-selectors/tests/test_kssparser.js
(original)
+++ kukit/kukit.js/branch/commas-in-selectors/tests/test_kssparser.js Tue Aug
28 21:24:52 2007
@@ -68,82 +68,82 @@
this.testPropvalueInMethod = function() {
// Parsing prop values (no methods allowed)
var txt= "apple;";
- var src = new kukit.tk.Cursor(txt);
- var parser = new kukit.kssp.PropValueInMethod(src, null, true);
+ var cursor = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.PropValueInMethod(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.txt, 'apple');
txt= "'a string';";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.PropValueInMethod(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.PropValueInMethod(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.txt, 'a string');
txt= '"a string";';
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.PropValueInMethod(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.PropValueInMethod(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.txt, 'a string');
txt= '"a \\"string";';
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.PropValueInMethod(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.PropValueInMethod(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.txt, 'a "string');
txt= " /* valid */ 'a string' /* here*/ /*and*/ /*there*/;";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.PropValueInMethod(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.PropValueInMethod(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.txt, 'a string');
txt= " in /* valid */ 'a string';";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.PropValueInMethod, src, null, true,
'Wrong value : unallowed characters [in] before a string.');
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null,
true, 'Wrong value : unallowed characters [in] before a string.');
txt= " 'a string' trashy;";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.PropValueInMethod, src, null, true,
'Wrong value : unallowed characters after the property.');
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null,
true, 'Wrong value : unallowed characters after the property.');
txt= " 'a string' trashy \"trishy\";";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.PropValueInMethod, src, null, true,
'Wrong value : unallowed characters after the property.');
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null,
true, 'Wrong value : unallowed characters after the property.');
// multiword not ok
txt= "b c";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.PropValueInMethod, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null,
true,
'Wrong value : [b c] cannot have spaces.', 5);
txt= " apples and oranges ;";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.PropValueInMethod, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null,
true,
'Wrong value : [apples and oranges] cannot have spaces.', 25);
txt= " /* comments; */ apples and /* more comments and*/ oranges ;";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.PropValueInMethod, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null,
true,
//'Wrong value : [/* comments; */ apples and /* more comments
and*/ oranges ;] cannot have spaces.', 62);
'Wrong value : [apples and oranges] cannot have spaces.', 62);
// in string, multiword ok even in method
txt= "'b c' ";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.PropValueInMethod(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.PropValueInMethod(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.txt, 'b c');
this.assertEquals(parser.parms, null);
// Not ok
txt= "a'b c'";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.PropValueInMethod, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null,
true,
'Wrong value : unallowed characters [a] before a string', 6);
// Not ok
txt= "'a''b c'";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.PropValueInMethod, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null,
true,
'Wrong value : unallowed characters after the property.', 6);
};
@@ -152,38 +152,38 @@
// Parsing property values
var txt= "b";
- var src = new kukit.tk.Cursor(txt);
- var parser = new kukit.kssp.PropValue(src, null, true);
+ var cursor = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.PropValue(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.value.isMethod, false);
this.assertEquals(parser.value.txt, 'b');
// multiword ok
txt= "b c";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.PropValue(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.PropValue(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.value.isMethod, false);
this.assertEquals(parser.value.txt, 'b c');
txt= " apples and oranges ;";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.PropValue(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.PropValue(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.value.isMethod, false);
this.assertEquals(parser.value.txt, 'apples and oranges');
txt= " /* comments; */ apples and /* more comments and*/ oranges ;";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.PropValue(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.PropValue(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.value.isMethod, false);
this.assertEquals(parser.value.txt, 'apples and oranges');
// params ok
txt= "formVar(x, y) ";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.PropValue(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.PropValue(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.value.isMethod, true);
this.assertEquals(parser.value.methodName, 'formVar');
@@ -191,8 +191,8 @@
// params ok
txt= "formVar(x, y)";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.PropValue(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.PropValue(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.value.isMethod, true);
this.assertEquals(parser.value.methodName, 'formVar');
@@ -200,26 +200,26 @@
//ok
txt= " formVar (x, y)";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.PropValue(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.PropValue(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.value.isMethod, true);
this.assertEquals(parser.value.methodName, 'formVar');
this.assertListEquals(parser.value.args, ['x', 'y']);
txt= " a formVar(x, y)";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.PropValue, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.PropValue, cursor, null, true,
'Wrong value : method name [a formVar] cannot have spaces.', 16);
txt= " 'formVar'(x, y)";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.PropValue, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.PropValue, cursor, null, true,
'Wrong value : unallowed characters after the property', 16);
txt= "formVar(x, y) xxx";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.PropValue, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.PropValue, cursor, null, true,
'Wrong value : unallowed characters after the property', 17);
};
@@ -227,51 +227,51 @@
// Parsing prop values in pseudo (no methods allowed)
var txt= "b";
- var src = new kukit.tk.Cursor(txt);
- var parser = new kukit.kssp.EventValue(src, null, true);
+ var cursor = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.EventValue(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.value.methodName, 'b');
// multiword ok but does not finish
txt= "b c";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.EventValue(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.EventValue(cursor, null, true);
this.assertEquals(parser.finished, true);
- this.assertEquals(src.pos, 1);
+ this.assertEquals(cursor.pos, 1);
this.assertEquals(parser.value.methodName, 'b');
// space ok but does not finish
txt= " b";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.EventValue(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.EventValue(cursor, null, true);
this.assertEquals(parser.finished, true);
- this.assertEquals(src.pos, 0);
+ this.assertEquals(cursor.pos, 0);
this.assertEquals(parser.value.methodName, '');
// ok, does not finish
txt= "apples/* more comments and*/";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.EventValue(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.EventValue(cursor, null, true);
this.assertEquals(parser.finished, true);
- this.assertEquals(src.pos, 6);
+ this.assertEquals(cursor.pos, 6);
this.assertEquals(parser.value.methodName, 'apples');
// params ok
txt= "click(x)";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.EventValue(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.EventValue(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.value.methodName, 'click');
this.assertListEquals(parser.value.args, ['x']);
// more then 1 args not ok (but we check it only from kss selector)
//txt= "drag(x, y)";
- //src = new kukit.tk.Cursor(txt);
+ //cursor = new kukit.tk.Cursor(txt);
// not ok but we don't parse an error
//txt= "'drag'(x)";
- //src = new kukit.tk.Cursor(txt);
- //this.assertParsingError(kukit.kssp.EventValue, src, null, true,
+ //cursor = new kukit.tk.Cursor(txt);
+ //this.assertParsingError(kukit.kssp.EventValue, cursor, null, true,
// 'Excess characters after the property value', 16);
};
@@ -279,60 +279,72 @@
this.testMethodArgs = function() {
// Parsing method args
var txt= "(a, b)";
- var src = new kukit.tk.Cursor(txt);
- var parser = new kukit.kssp.MethodArgs(src, kukit.kssp.openParent,
true);
+ var cursor = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.MethodArgs(cursor, kukit.kssp.openParent,
true);
this.assertEquals(parser.finished, true);
this.assertListEquals(parser.args, ['a', 'b']);
txt= "('a', /* to annoy you */ \"b\")";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.MethodArgs(src, kukit.kssp.openParent, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.MethodArgs(cursor, kukit.kssp.openParent,
true);
this.assertEquals(parser.finished, true);
this.assertListEquals(parser.args, ['a', 'b']);
txt= "(' a multi', /* to annoy you */ \"b multi \")";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.MethodArgs(src, kukit.kssp.openParent, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.MethodArgs(cursor, kukit.kssp.openParent,
true);
this.assertEquals(parser.finished, true);
this.assertListEquals(parser.args, [' a multi','b multi ']);
txt= "('a', /*comment*/ /* to annoy you */ \"b\")";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.MethodArgs(src, kukit.kssp.openParent, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.MethodArgs(cursor, kukit.kssp.openParent,
true);
this.assertEquals(parser.finished, true);
this.assertListEquals(parser.args, ['a', 'b']);
txt= "(a, b, )";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.MethodArgs(src, kukit.kssp.openParent, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.MethodArgs(cursor, kukit.kssp.openParent,
true);
this.assertEquals(parser.finished, true);
this.assertListEquals(parser.args, ['a', 'b']);
txt= "(a, b c )";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.MethodArgs, src,
kukit.kssp.openParent, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.MethodArgs, cursor,
kukit.kssp.openParent, true,
'Wrong method argument [b c] : value cannot have spaces', 9);
txt= "(a, b 'x' )";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.MethodArgs, src,
kukit.kssp.openParent, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.MethodArgs, cursor,
kukit.kssp.openParent, true,
'Unexpected token : [string] found, [comma] was expected.', 11);
};
+ this.testMethodArgsRecursive = function() {
+ var txt= "(a, b(c, d))";
+ var cursor = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.MethodArgs(cursor, kukit.kssp.openParent,
true);
+ this.assertEquals(parser.finished, true);
+ this.assertEquals(parser.args.length, 2);
+ this.assertEquals(parser.args[0], 'a');
+ this.assertEquals(parser.args[1].isMethod, true);
+ this.assertEquals(parser.args[1].methodName, 'b');
+ this.assertListEquals(parser.args[1].args, ['c', 'd']);
+ };
+
this.testEmptyDoc = function() {
// unexpected eof handling
var txt= "";
- var src = new kukit.tk.Cursor(txt);
- var parser = new kukit.kssp.Document(src, null, true);
+ var cursor = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.Document(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.eventRules.length, 0);
// In particular, this should not raise unexpected eof.
var txt= "/*xxx*/";
- var src = new kukit.tk.Cursor(txt);
- var parser = new kukit.kssp.Document(src, null, true);
+ var cursor = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.Document(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.eventRules.length, 0);
};
@@ -397,15 +409,19 @@
+'setStyle-kssSelector: "#button_4";\n'
+'setStyle-name: /* comment blabla */ backgroundColor;\n'
+'setStyle-value: #FFa0a0;\n'
+ +'}\n'
+ +"#calendar-previous a:click {\n"
+ +" action-server : kukitGetPreviousMonth /* place comment
here*/;\n"
+ +" kukitGetPreviousMonth-member: formVar(edit, kssAttr(foo));\n"
+"}\n";
- var src = new kukit.tk.Cursor(txt);
+ var cursor = new kukit.tk.Cursor(txt);
// XXX TODO change comments
- var parser = new kukit.kssp.Document(src, null, true);
+ var parser = new kukit.kssp.Document(cursor, null, true);
this.assertEquals(parser.finished, true);
- this.assertEquals(parser.eventRules.length, 12);
+ this.assertEquals(parser.eventRules.length, 13);
var rule;
var action;
@@ -633,7 +649,7 @@
'kssSelector': new kukit.rd.KssMethodValue('htmlid',
['button_2'])
});
- // rule 10
+ // rule 12
//#button_3:click {
// action-client: setStyle;
// setStyle-kssSelector: "#button_4";
@@ -659,8 +675,28 @@
'kssSelector': new kukit.rd.KssTextValue('#button_4')
});
-
-
+ // rule 13
+ // #calendar-previous a:click {
+ // kss-action : 'kukitresponse/kukitGetPreviousMonth' /* place
comment here*/;
+ // member: formVar(edit, kssAttr(foo));
+ // }
+ rule = parser.eventRules[12];
+ this.assertDictEquals(rule.parms, {});
+ this.assertEquals(rule.kssSelector.css, '#calendar-previous a');
+ this.assertEquals(rule.kssSelector.isEventSelector, true);
+ this.assertEquals(rule.kssSelector.name, 'click');
+ this.assertEquals(rule.kssSelector.namespace, null);
+ this.assertEquals(rule.kssSelector.id, null);
+ action = rule.actions.content['kukitGetPreviousMonth'];
+ this.assertEquals(action.type, 'S');
+ this.assertEquals(action.name, 'kukitGetPreviousMonth');
+ this.assertEquals(action.error, null);
+ var formVar = action.parms.member;
+ this.assertEquals(formVar.methodName, 'formVar');
+ this.assertEquals(formVar.args[0], 'edit');
+ var kssAttr = formVar.args[1];
+ this.assertEquals(kssAttr.methodName, 'kssAttr');
+ this.assertListEquals(kssAttr.args, ['foo']);
};
};
@@ -675,8 +711,8 @@
this.testSelectorWithBinderId = function() {
// Parsing event selector params
var txt= "a:drag(hello)";
- var src = new kukit.tk.Cursor(txt);
- var parser = new kukit.kssp.KssSelector(src, null, true);
+ var cursor = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.kssSelector.isEventSelector, true);
this.assertEquals(parser.kssSelector.css, 'a');
@@ -687,8 +723,8 @@
this.testKssSelector = function() {
var txt= "a:dnd-drag(hello)";
- var src = new kukit.tk.Cursor(txt);
- var parser = new kukit.kssp.KssSelector(src, null, true);
+ var cursor = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.kssSelector.isEventSelector, true);
this.assertEquals(parser.kssSelector.css, 'a');
@@ -697,16 +733,16 @@
this.assertEquals(parser.kssSelector.id, 'hello');
var txt= "a:dnd-drag-toomuch(hello)";
- var src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ var cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector [dnd-drag-toomuch] : qualifier should be
:<EVENTNAME> or :<NAMESPACE>'
, 25);
// maybe in std css space is not allowed in the parents,
// but we tolerate it
txt= " a div#id:drag( hello)";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.kssSelector.isEventSelector, true);
this.assertEquals(parser.kssSelector.css, ' a div#id');
this.assertEquals(parser.kssSelector.name, 'drag');
@@ -715,19 +751,19 @@
// We do not allow space here
txt= " a div#id:drag (hello)";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector : missing event qualifier :<EVENTNAME> or
:<EVENTNAME>(<ID>).', 25);
// We do not allow space here
txt= " a div#id: drag(hello)";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector : missing event qualifier :<EVENTNAME> or
:<EVENTNAME>(<ID>).', 23);
txt= "a div#id:drop ";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.kssSelector.isEventSelector, true);
this.assertEquals(parser.kssSelector.css, 'a div#id');
this.assertEquals(parser.kssSelector.name, 'drop');
@@ -735,8 +771,8 @@
this.assertEquals(parser.kssSelector.id, null);
txt= "a div.class:drop ";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.kssSelector.isEventSelector, true);
this.assertEquals(parser.kssSelector.css, 'a div.class');
@@ -745,8 +781,8 @@
this.assertEquals(parser.kssSelector.id, null);
txt= "a:click ";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.kssSelector.isEventSelector, true);
this.assertEquals(parser.kssSelector.css, 'a');
@@ -756,41 +792,41 @@
// two params: not allowed
txt= "a:drop('hello', bello)";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector ::<EVENTNAME>(<ID>) can have only one
parameter.', 22);
// zero params: not std css but tolerated
txt= "a:drop()";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector : missing event qualifier :<EVENTNAME> or
:<EVENTNAME>(<ID>).', 8);
txt= " (hello)";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector : missing event qualifier :<EVENTNAME> or
:<EVENTNAME>(<ID>).', 10);
txt= "hello ('bello')";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector : missing event qualifier :<EVENTNAME> or
:<EVENTNAME>(<ID>).', 16);
txt= "a:lang(hu) (hello)";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector : missing event qualifier :<EVENTNAME> or
:<EVENTNAME>(<ID>).', 19);
txt= "a:lang(hu) b (hello)";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector : missing event qualifier :<EVENTNAME> or
:<EVENTNAME>(<ID>).', 20);
// A valid attr selector in the css selector part.
txt= "a[href=hello].class:lang(hu) div#id:click ";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.kssSelector.isEventSelector, true);
this.assertEquals(parser.kssSelector.css,
"a[href=hello].class:lang(hu) div#id");
this.assertEquals(parser.kssSelector.name, 'click');
@@ -798,8 +834,8 @@
this.assertEquals(parser.kssSelector.id, null);
txt= "a[href=hello].class:lang(hu) div#id:drop(hello) ";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.kssSelector.isEventSelector, true);
this.assertEquals(parser.kssSelector.css,
"a[href=hello].class:lang(hu) div#id");
@@ -808,14 +844,14 @@
this.assertEquals(parser.kssSelector.id, 'hello');
txt= " a:lang(hu) click ";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector : missing event qualifier :<EVENTNAME> or
:<EVENTNAME>(<ID>).', 20);
// Spaces in the end
txt= " a:lang(hu, uh) b:click ";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.kssSelector.isEventSelector, true);
this.assertEquals(parser.kssSelector.css, " a:lang(hu, uh) b");
@@ -825,8 +861,8 @@
// Comment in the end
txt= " a:lang(hu, uh) b:click/*comment here*/";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.kssSelector.isEventSelector, true);
this.assertEquals(parser.kssSelector.css, " a:lang(hu, uh) b");
@@ -836,8 +872,8 @@
// Should be ok.
txt= "a:lang(hu)/*comment here*/b:click ";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.kssSelector.isEventSelector, true);
this.assertEquals(parser.kssSelector.css, "a:lang(hu)/*comment
here*/b");
this.assertEquals(parser.kssSelector.name, 'click');
@@ -846,8 +882,8 @@
// Should be ok.
txt= "a:lang(hu) click/*comment here*/b:clack ";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.kssSelector.isEventSelector, true);
this.assertEquals(parser.kssSelector.css, "a:lang(hu) click/*comment
here*/b");
@@ -856,32 +892,32 @@
this.assertEquals(parser.kssSelector.id, null);
txt= "a:click:clack ";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector : missing event qualifier :<EVENTNAME> or
:<EVENTNAME>(<ID>).', 14);
txt= "a:click :clack ";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector : space before the colon. at row', 18);
txt= "a:click/*comment */:clack ";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector : missing event qualifier :<EVENTNAME> or
:<EVENTNAME>(<ID>).', 26);
txt= "click/*comment here*/:clack ";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector : missing event qualifier :<EVENTNAME> or
:<EVENTNAME>(<ID>).', 28);
txt= "/*comment here*/click:clack ";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
txt= " no-document:click(hello)";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.kssSelector.isEventSelector, true);
this.assertEquals(parser.kssSelector.css, " no-document");
@@ -893,8 +929,8 @@
// Event method selectors
txt= " document:click(hello) ";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.kssSelector.isMethodSelector, true);
this.assertEquals(parser.kssSelector.css, 'document');
@@ -903,8 +939,8 @@
this.assertEquals(parser.kssSelector.id, 'hello');
txt= " document:native-click(hello) ";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.kssSelector.isMethodSelector, true);
this.assertEquals(parser.kssSelector.css, 'document');
@@ -913,19 +949,19 @@
this.assertEquals(parser.kssSelector.id, 'hello');
txt= "document";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector : missing event qualifier :<EVENTNAME> or
:<EVENTNAME>(<ID>).', 8);
txt= "document: ";
- src = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
'Wrong event selector : event name cannot have spaces. at row',
10);
// also, "behaviour:" works
txt= " behaviour:click(hello) ";
- src = new kukit.tk.Cursor(txt);
- parser = new kukit.kssp.KssSelector(src, null, true);
+ cursor = new kukit.tk.Cursor(txt);
+ parser = new kukit.kssp.KssSelector(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.kssSelector.isMethodSelector, true);
this.assertEquals(parser.kssSelector.css, 'behaviour');
@@ -946,8 +982,8 @@
this.testSingleSelector = function() {
var txt= "a:drag(hello)";
- var src = new kukit.tk.Cursor(txt);
- var parser = new kukit.kssp.KssSelectors(src, null, true);
+ var cursor = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.KssSelectors(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.selectors.length, 1);
var kssSelector = parser.selectors[0];
@@ -960,8 +996,8 @@
this.testMultipleSelectors = function() {
var txt= "a:drag(hello), div a:click";
- var src = new kukit.tk.Cursor(txt);
- var parser = new kukit.kssp.KssSelectors(src, null, true);
+ var cursor = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.KssSelectors(cursor, null, true);
this.assertEquals(parser.finished, true);
this.assertEquals(parser.selectors.length, 2);
var kssSelector = parser.selectors[0];
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins