[KSS-checkins] r50401 - in kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes: . kukit tests
reebalazs at codespeak.net
reebalazs at codespeak.net
Sun Jan 6 17:19:48 CET 2008
Author: reebalazs
Date: Sun Jan 6 17:19:47 2008
New Revision: 50401
Modified:
kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/ (props changed)
kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/kssparser.js
kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js
kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/test_kssparser.js
Log:
Add url() provider.
Add ecma tests.
Make some error messages more meaningful in some cases.
Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/kssparser.js
==============================================================================
--- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/kssparser.js (original)
+++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/kssparser.js Sun Jan 6 17:19:47 2008
@@ -457,8 +457,10 @@
;;; if (typeof(valuesByReturnType[returnType]) != 'undefined') {
;;; if (returnType == 'string') {
;;; // Give a more sensible message for strings.
-;;; kukit.E = 'Only one string or one value provider with result type ';
-;;; kukit.E += '[string] is allowed in the ' + errInfo + '.';
+;;; // (Do not mention the word "provider" in the message
+;;; // as action-xxx cannot take providers, only real strings.
+;;; kukit.E = 'Only one [string] value ';
+;;; kukit.E += 'is allowed in the ' + errInfo + '.';
;;; } else {
;;; kukit.E = 'Only one provider with result type [' + returnType;
;;; kukit.E += '] is allowed in the ' + errInfo + '.';
@@ -470,8 +472,10 @@
}
;;; // Check we have at least a string type. (unless asked otherwise)
;;; if (! noStringRequired && typeof(valuesByReturnType.string) == 'undefined') {
-;;; kukit.E = 'One string or one value provider with the result type [string] ';
-;;; kukit.E += 'is needed in the ' + errInfo + '.';
+;;; // (Do not mention the word "provider" in the message
+;;; // as action-xxx cannot take providers, only real strings.
+;;; kukit.E = 'Missing [string] value ';
+;;; kukit.E += 'in the ' + errInfo + '.';
;;; this.emitError(kukit.E);
;;; }
return valuesByReturnType;
Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js
==============================================================================
--- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js (original)
+++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js Sun Jan 6 17:19:47 2008
@@ -355,4 +355,18 @@
};
kukit.pprovidersGlobalRegistry.register('kssIdOfValue', kukit.pr.KssIdOfValuePP);
+/* The url() provider just passes the parameters, and is used to have
+ * a different return type. It can be used in the line of action-server.
+ * as an alternative to a separate kssUrl line.
+ */
+kukit.pr.UrlPP = function() {
+ this.check = function(args) {
+;;; if (args.length != 1) {
+;;; throw new Error('url() needs 1 argument');
+;;; }
+ };
+};
+kukit.pr.UrlPP.prototype = kukit.pr.IdentityPP;
+// returnType = 'url'
+kukit.pprovidersGlobalRegistry.register('url', kukit.pr.UrlPP, 'url');
Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/test_kssparser.js
==============================================================================
--- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/test_kssparser.js (original)
+++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/test_kssparser.js Sun Jan 6 17:19:47 2008
@@ -901,7 +901,10 @@
// We also check how these providers can be combined
// on one line.
//
- // This testcase is added in DEVELOPMENT MODE ONLY.
+ // This testcase can run in DEVELOPMENT MODE ONLY,
+ // (because the checks are ignored in production mode)
+ // and all tests will be skipped
+ // and pass GREEN in production mode.
this.testNormalProviderAcceptsString = function() {
// normal providers does accept string
@@ -916,7 +919,7 @@
value.check();
};
- this.testNormalProviderRejectsSelection = function() {
+ this.testNormalProviderRejectsSelectionAsParameter = function() {
// normal providers does not accept selection
//
// This test can only run in development mode, pass otherwise.
@@ -957,9 +960,10 @@
//
var txt= "nodeAttr(form('name'))";
var cursor = new kukit.tk.Cursor(txt);
- this.assertParsingError(kukit.kssp.Document, cursor, null, true,
- // XXX This error message will be fixed in service-layer branch
- 'Error in value for action parameter [message] : Error: Expected string value and got [selection] in argument #[1] of provider [nodeAttr].., at row 1, column 11');
+ this.assertThrows(function() {
+ value.check();
+ },
+ Error);
};
this.testNormalProviderRejectsFormQueryFullRule = function() {
@@ -969,7 +973,6 @@
// This test can only run in development mode, pass otherwise.
if (! kukit.isDevelMode) {return;}
//
- var txt= "nodeAttr('id')";
var txt= "#id:click {\n"
+ " action-client: log;\n"
+ " log-message: nodeAttr(form('name'));\n"
@@ -980,7 +983,7 @@
'Error in value for action parameter [message] : Error: Expected string value and got [formquery] in argument #[1] of provider [nodeAttr].., at row 1, column 11');
};
- this.testNormalProviderRejectsSelector = function() {
+ this.testNormalParameterRejectsSelectorInItself = function() {
// normal parameters do not accept selector (in itself)
//
// This test can only run in development mode, pass otherwise.
@@ -993,16 +996,15 @@
var cursor = new kukit.tk.Cursor(txt);
this.assertParsingError(kukit.kssp.Document, cursor, null, true,
// XXX This error message will be fixed in service-layer branch
- 'One string or one value provider with the result type [string] is needed in the action parameter [message]., at row 1, column 1');
+ 'Missing [string] value in the action parameter [message]., at row 1, column 11');
};
- this.testNormalProviderRejectsFormQuery = function() {
+ this.testNormalParameterRejectsFormQuery = function() {
// normal parameters do not accept form query
//
// This test can only run in development mode, pass otherwise.
if (! kukit.isDevelMode) {return;}
//
- var txt= "nodeAttr('id')";
var txt= "#id:click {\n"
+ " action-client: log;\n"
+ " log-message: form('name');\n"
@@ -1019,7 +1021,6 @@
// This test can only run in development mode, pass otherwise.
if (! kukit.isDevelMode) {return;}
//
- var txt= "nodeAttr('id')";
var txt= "#id:click {\n"
+ " action-client: setAttribute;\n"
+ " setAttribute-kssSelector: htmlid('id');\n"
@@ -1038,7 +1039,6 @@
// This test can only run in development mode, pass otherwise.
if (! kukit.isDevelMode) {return;}
//
- var txt= "nodeAttr('id')";
var txt= "#id:click {\n"
+ " action-client: setAttribute;\n"
+ " setAttribute-kssSelector: htmlid('id');\n"
@@ -1056,7 +1056,6 @@
// This test can only run in development mode, pass otherwise.
if (! kukit.isDevelMode) {return;}
//
- var txt= "nodeAttr('id')";
var txt= "#id:click {\n"
+ " action-client: setAttribute;\n"
+ " setAttribute-kssSelector: form('name');\n"
@@ -1075,7 +1074,6 @@
// This test can only run in development mode, pass otherwise.
if (! kukit.isDevelMode) {return;}
//
- var txt= "nodeAttr('id')";
var txt= "#id:click {\n"
+ " action-server: doIt;\n"
+ " doIt-kssSubmitForm: form('name');\n"
@@ -1092,7 +1090,6 @@
// This test can only run in development mode, pass otherwise.
if (! kukit.isDevelMode) {return;}
//
- var txt= "nodeAttr('id')";
var txt= "#id:click {\n"
+ " action-server: doIt;\n"
+ " doIt-kssSubmitForm: 'name';\n"
@@ -1108,7 +1105,6 @@
// This test can only run in development mode, pass otherwise.
if (! kukit.isDevelMode) {return;}
//
- var txt= "nodeAttr('id')";
var txt= "#id:click {\n"
+ " action-server: doIt;\n"
+ " doIt-kssSubmitForm: htmlid('id');\n"
@@ -1125,7 +1121,6 @@
// This test can only run in development mode, pass otherwise.
if (! kukit.isDevelMode) {return;}
//
- var txt= "nodeAttr('id')";
var txt= "#id:click {\n"
+ " action-client: htmlid(id) doIt;\n"
+ "}\n"
@@ -1140,7 +1135,6 @@
// This test can only run in development mode, pass otherwise.
if (! kukit.isDevelMode) {return;}
//
- var txt= "nodeAttr('id')";
var txt= "#id:click {\n"
+ " action-client: htmlid(id) doIt form();\n"
+ "}\n"
@@ -1156,7 +1150,6 @@
// This test can only run in development mode, pass otherwise.
if (! kukit.isDevelMode) {return;}
//
- var txt= "nodeAttr('id')";
var txt= "#id:click {\n"
+ " action-server: doIt currentForm();\n"
+ "}\n"
@@ -1171,7 +1164,6 @@
// This test can only run in development mode, pass otherwise.
if (! kukit.isDevelMode) {return;}
//
- var txt= "nodeAttr('id')";
var txt= "#id:click {\n"
+ " action-server: doIt currentForm() htmlid(id);\n"
+ "}\n"
@@ -1181,6 +1173,111 @@
'Provider result type [selection] not allowed in the action definition [action-server]., at row 1, column 11');
};
+ this.testCombinedServerActionAcceptsStringAndUrl = function() {
+ // Server action accepts a string and an url.
+ //
+ // This test can only run in development mode, pass otherwise.
+ if (! kukit.isDevelMode) {return;}
+ //
+ var txt= "#id:click {\n"
+ + " action-server: doIt url('http://foo.bar');\n"
+ + "}\n"
+ var cursor = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.Document(cursor, null, true);
+ this.assertEquals(parser.finished, true);
+ };
+
+ this.testCombinedServerActionAcceptsUrlAndString = function() {
+ // Server action accepts a string and an url.
+ //
+ // This test can only run in development mode, pass otherwise.
+ if (! kukit.isDevelMode) {return;}
+ //
+ var txt= "#id:click {\n"
+ + " action-server: doIt url('http://foo.bar');\n"
+ + "}\n"
+ var cursor = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.Document(cursor, null, true);
+ this.assertEquals(parser.finished, true);
+ };
+
+ this.testCombinedServerActionAcceptsStringAndFormAndUrl = function() {
+ // Server action accepts string, form, and url providers together.
+ //
+ // This test can only run in development mode, pass otherwise.
+ if (! kukit.isDevelMode) {return;}
+ //
+ var txt= "#id:click {\n"
+ + " action-server: doIt currentForm() url('http://foo.bar');\n"
+ + "}\n"
+ var cursor = new kukit.tk.Cursor(txt);
+ var parser = new kukit.kssp.Document(cursor, null, true);
+ this.assertEquals(parser.finished, true);
+ };
+
+ this.testCombinedServerActionRejectsUrlInItself = function() {
+ // Server action rejects url() in itself.
+ // It should have a string in any case.
+ //
+ // This test can only run in development mode, pass otherwise.
+ if (! kukit.isDevelMode) {return;}
+ //
+ var txt= "#id:click {\n"
+ + " action-server: url('http://foo.bar');\n"
+ + "}\n"
+ var cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.Document, cursor, null, true,
+ // XXX This error message will be fixed in service-layer branch
+ 'Missing [string] value in the action definition [action-server]., at row 1, column 11');
+ };
+
+ this.testCombinedServerActionRejectsTwoStrings = function() {
+ // Server action rejects two strings.
+ //
+ // This test can only run in development mode, pass otherwise.
+ if (! kukit.isDevelMode) {return;}
+ //
+ var txt= "#id:click {\n"
+ + " action-server: foo 'bar';\n"
+ + "}\n"
+ var cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.Document, cursor, null, true,
+ // XXX This error message will be fixed in service-layer branch
+ 'Only one [string] value is allowed in the action definition [action-server]., at row 1, column 11');
+ };
+
+
+ this.testCombinedServerActionRejectsUrlWithoutParms = function() {
+ // Server action rejects url() if url has no parameter.
+ // It should have a string in any case.
+ //
+ // This test can only run in development mode, pass otherwise.
+ if (! kukit.isDevelMode) {return;}
+ //
+ var txt= "#id:click {\n"
+ + " action-server: doIt url();\n"
+ + "}\n"
+ var cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.Document, cursor, null, true,
+ // XXX This error message will be fixed in service-layer branch
+ 'Error in value for action definition [action-server] : Error: url() needs 1 argument., at row 1, column 11');
+ };
+
+ this.testServerActionRejectsValueProviderForString = function() {
+ // Server action must have a string, no value provider is allowed here.
+ //
+ // This test can only run in development mode, pass otherwise.
+ if (! kukit.isDevelMode) {return;}
+ //
+ var txt= "#id:click {\n"
+ + " action-server: kssAttr(blah);\n"
+ + "}\n"
+ var cursor = new kukit.tk.Cursor(txt);
+ this.assertParsingError(kukit.kssp.Document, cursor, null, true,
+ // XXX This error message will be fixed in service-layer branch
+ 'Wrong value for key [action-server] : value providers are not allowed for action-<QUALIFIER> keys., at row 1, column 11');
+ };
+
this.testNormalProviderAcceptsValueAndSelector = function() {
// normal parameters accepts value and selector
//
More information about the Kukit-checkins
mailing list