Author: reebalazs
Date: Fri Dec 28 12:42:00 2007
New Revision: 50153
Modified:
kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed)
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js
Log:
Fix for the case of zero or more then 1 event binder ids in the kss selector
This should be prohibited. There must be a single binder id value.
Modified:
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js
==============================================================================
--- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js
(original)
+++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js
Fri Dec 28 12:42:00 2007
@@ -468,8 +468,9 @@
"\r": 'this.emitAndReturn()',
"\/\*": 'this.emitAndReturn()',
":": 'this.emitAndReturn()',
- "(": '[new kukit.kssp.openParent(this.cursor), new
kukit.kssp.PropValue(this.cursor)]',
- ")": 'this.emitAndReturn(new kukit.kssp.closeParent(this.cursor))'
+ // Hint for merging: next two lines changed
+ "(": "this.emitAndReturn([new kukit.kssp.openParent(this.cursor), new
kukit.kssp.PropValue(this.cursor), new kukit.kssp.closeParent(this.cursor)])",
+ ")": 'this.emitAndReturn()'
});
kukit.kssp.EventValue.prototype.multiword_allowed = false;
kukit.kssp.EventValue.prototype.process = function() {
@@ -491,21 +492,20 @@
} else if (this.notInTokens(context, kukit.kssp.openParent)) {
this.expectToken(context, kukit.kssp.openParent);
this.expectToken(context, kukit.kssp.PropValue);
+ // Specifically handle the case of zero parameter, () here. In this
+ // case PropValue evaluates to '', Do not allow this.
+ var value = context.token.value;
+ if (! value.isMethod && value.txt == '') {
+;;; kukit.E = 'Event binder id must be specified in the parenthesis.';
+ this.emitError(kukit.E);
+ }
// Create the event binder id
// as a method value with a single parameter
// to be evaluated later
// At this moment context.token.value contains an object with
// check and evaluate methods.
- this.value = new kukit.rd.KssMethodValue(txt, [context.token.value]);
+ this.value = new kukit.rd.KssMethodValue(txt, [value]);
this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment);
- // we have to be at the end and have no text after
- if (context.txt) {
-;;; kukit.E = 'Wrong event selector : [' + context.txt;
-;;; kukit.E += '] is not expected before the closing';
-;;; kukit.E += ' parenthesis. :<EVENTNAME>(<ID>) can have';
-;;; kukit.E += ' only one parameter.';
- this.emitError(kukit.E);
- }
// eat up everything before the closing parent
this.expectToken(context, kukit.kssp.closeParent);
} else {
@@ -803,7 +803,8 @@
if (pseudotoken.value.isMethod) {
eventName = pseudotoken.value.methodName;
var args = pseudotoken.value.args;
- // XXX TODO check that there is only 1 arg? Should already be checked.
+ // We do not need to check that argss has exactly one element,
+ // since this is already assured by the parser syntax.
var arg = args[0];
;;; // We annotate the error, to give parsing information to it.
;;; try {
Modified:
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js
==============================================================================
---
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js
(original)
+++
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js
Fri Dec 28 12:42:00 2007
@@ -370,9 +370,7 @@
var txt= "click(kssAttr(x), aaa)";
var cursor = new kukit.tk.Cursor(txt);
this.assertParsingError(kukit.kssp.EventValue, cursor, null, true,
- 'Wrong event selector : [,] is not expected before the closing
parenthesis. :<EVENTNAME>(<ID>) can have only one parameter.', 000);
-
- // XXX add more failing cases, maybe?
+ 'Unexpected token : [,] found, [)] was expected.');
};
this.testMethodArgs = function() {
@@ -978,14 +976,14 @@
txt= "a:click('hello', bello)";
cursor = new kukit.tk.Cursor(txt);
this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
- 'Wrong event selector : [,] is not expected before the closing
parenthesis. :<EVENTNAME>(<ID>) can have only one parameter.', 22);
+ 'Unexpected token : [,] found, [)] was expected.');
- // zero params: not std css but tolerated
+ // zero params: is not tolerated now. There must be exactly 1
parameter.
txt= "a:click()";
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);
+ 'Event binder id must be specified in the parenthesis.');
+ //'Wrong event selector : missing event qualifier :<EVENTNAME> or
:<EVENTNAME>(<ID>).', 8);
txt= " (hello)";
cursor = new kukit.tk.Cursor(txt);
@@ -1481,7 +1479,25 @@
var cursor = new kukit.tk.Cursor(txt);
this.assertParsingError(kukit.kssp.Document, cursor, null, true,
'Wrong value for evt-[<NAMESPACE>-]<EVENTNAME>
[dnd-drag] : <NAMESPACE>-<EVENTNAME> should exist in the event of the
selectors.', 6);
- }
+ };
+
+ this.testEventIdentificationHasOneParameter = function() {
+ // The event identification stands as a single parameter.
+ // No list of ids is allowed.
+ var txt= "a:click(hello, true)";
+ var src = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ 'Unexpected token : [,] found, [)] was expected.');
+ };
+
+ this.testEventIdentificationHasOneParameter2 = function() {
+ // The event identification stands as a single parameter.
+ // Zero parameter is not allowed..
+ var txt= "a:click()";
+ var src = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
+ 'Event binder id must be specified in the parenthesis.');
+ };
this.testValueProvidersInEventIdentification = function() {
// Param providers within the event identification
@@ -1525,7 +1541,7 @@
var txt= "a:drag(kssAttr(hello), xxx)";
var src = new kukit.tk.Cursor(txt);
this.assertParsingError(kukit.kssp.KssSelector, src, null, true,
- 'Wrong event selector : [,] is not expected before the closing
parenthesis. :<EVENTNAME>(<ID>) can have only one parameter.', 000);
+ 'Unexpected token : [,] found, [)] was expected.');
};
this.testValueProvidersInEventIdentificationCannotStandWithSpecialSelectors =
function() {
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins