[KSS-checkins] r50320 - in kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes: . kukit tests

reebalazs at codespeak.net reebalazs at codespeak.net
Fri Jan 4 17:57:29 CET 2008


Author: reebalazs
Date: Fri Jan  4 17:57:28 2008
New Revision: 50320

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/providerreg.js
   kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/resourcedata.js
   kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/runtests.js
   kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/test_kssparser.js
Log:
Add ecma tests to check handling of value provider return types

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	Fri Jan  4 17:57:28 2008
@@ -178,15 +178,15 @@
 ;;;         kukit.E += ' [recurseParents]).';
 ;;;         throw new Error(kukit.E);
 ;;;     }
-;;;     if (args[0].toLowerCase() == 'style') {
+    },
+    eval: function(args, node) {
+        var argname = args[0];
+;;;     if (argname.toLowerCase() == 'style') {
 ;;;         throw new Error('nodeAttr method does not accept [style] as attrname.');
 ;;;     }
-;;;     if (args[0].match(/[ ]/)) {
+;;;     if (argname.match(/[ ]/)) {
 ;;;         throw new Error('attrname parameter in nodeAttr method cannot contain space.');
 ;;;     }
-    },
-    eval: function(args, node) {
-        var argname = args[0];
         var recurseParents = false;
         if (args.length == 2) {
             recurseParents = args[1];

Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/resourcedata.js
==============================================================================
--- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/resourcedata.js	(original)
+++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/resourcedata.js	Fri Jan  4 17:57:28 2008
@@ -186,7 +186,7 @@
 ;;; //Check the provider first.
 ;;; this.pprovider.check(this.args);
     // After checking the provider, we check the args recursively.
-    for(i=0; i < this.args.length; i++){
+    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

Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/runtests.js
==============================================================================
--- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/runtests.js	(original)
+++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/runtests.js	Fri Jan  4 17:57:28 2008
@@ -22,6 +22,7 @@
     testsuite.registerTest(kukit.TokenizerTestCase);
     testsuite.registerTest(kukit.KssParserTestCase);
     testsuite.registerTest(kukit.KssParserSelectorsTestCase);
+    testsuite.registerTest(kukit.KssParserValueProvidersCheckTestCase);
     testsuite.registerTest(kukit.KssParserSelectorTestCase);
     testsuite.runSuite();
 };

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	Fri Jan  4 17:57:28 2008
@@ -226,7 +226,7 @@
         this.assertParsingError(kukit.kssp.PropValue, cursor, null, true,
             'Wrong value : unallowed characters after the property', 17);
     };
-    
+
     this.testEventValueSimple = function() {
         // Parsing event value
         var txt= "b";
@@ -813,6 +813,245 @@
 
 kukit.KssParserTestCase.prototype = new kukit.KssParserTestCaseBase;
 
+kukit.KssParserValueProvidersCheckTestCase = function() {
+    this.name = 'kukit.KssParserValueProvidersCheckTestCase';
+    // Different tests to see if the syntax type check of
+    // the value providers is working correctly.
+    // At the moment we have the following return value types:
+    //     string, selection, formquery
+    // We do not check the actual evaluation here, as we
+    // have no DOM at hand.
+    //
+    // This testcase is added in DEVELOPMENT MODE ONLY.
+    
+    this.testNormalProviderAcceptsString = function() {
+        // normal providers does accept string
+        //
+        // This test can only run in development mode, pass otherwise.
+        if (! kukit.isDevelMode) {return;}
+        //
+        var txt= "nodeAttr('id')";
+        var cursor = new kukit.tk.Cursor(txt);
+        var parser = new kukit.kssp.PropValue(cursor, null, true);
+        var value = parser.value;
+        value.check();
+    };
+
+    this.testNormalProviderRejectsSelection = function() {
+        // normal providers does not accept selection
+        //
+        // This test can only run in development mode, pass otherwise.
+        if (! kukit.isDevelMode) {return;}
+        //
+        var txt= "nodeAttr('id')";
+        var txt= "nodeAttr(htmlid('id'))";
+        var cursor = new kukit.tk.Cursor(txt);
+        var parser = new kukit.kssp.PropValue(cursor, null, true);
+        var value = parser.value;
+        this.assertThrows(function() {
+            value.check();
+            },
+            Error);
+    };
+ 
+    this.testNormalProviderRejectsSelectionFullRule = function() {
+        // normal providers do not accept selection
+        // full rule
+        //
+        // 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(htmlid('id'));\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 : Error: Expected string value and got [selection] in argument #[1] of provider [nodeAttr].., at row 1, column 11');
+    };
+
+    this.testNormalProviderRejectsFormQuery = function() {
+        // normal providers 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= "nodeAttr(form('name'))";
+        var cursor = new kukit.tk.Cursor(txt);
+        var parser = new kukit.kssp.PropValue(cursor, null, true);
+        var value = parser.value;
+        this.assertThrows(function() {
+            value.check();
+            },
+            Error);
+    };
+ 
+    this.testNormalProviderRejectsFormQueryFullRule = function() {
+        // normal providers do not accept form query
+        // full rule
+        //
+        // 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"
+               + "}\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 : Error: Expected string value and got [formquery] in argument #[1] of provider [nodeAttr].., at row 1, column 11');
+    };
+
+    this.testNormalProviderRejectsSelector = function() {
+        // normal parameters do not accept selector
+        //
+        // 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:   htmlid('id');\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
+            'Expected string and got [selection] in the action parameter [message]., at row 1, column 11');
+    };
+
+    this.testNormalProviderRejectsFormQuery = 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"
+               + "}\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
+            'Expected string and got [formquery] in the action parameter [message]., at row 1, column 11');
+    };
+
+    this.testKssSelectorAcceptsSelector = function() {
+        // kssSelector accepts selector
+        //
+        // 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"
+               + "    setAttribute-name:          name;\n"
+               + "    setAttribute-value:          value;\n"
+               + "}\n"
+        var cursor = new kukit.tk.Cursor(txt);
+        var parser = new kukit.kssp.Document(cursor, null, true);
+        this.assertEquals(parser.finished, true);
+    };
+
+    this.testKssSelectorAcceptsString = function() {
+        // kssSelector accepts string
+        // (it will evaluate as css(xxx), but we can't check that without a dom)
+        //
+        // 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"
+               + "    setAttribute-name:          name;\n"
+               + "    setAttribute-value:          value;\n"
+               + "}\n"
+        var cursor = new kukit.tk.Cursor(txt);
+        var parser = new kukit.kssp.Document(cursor, null, true);
+        this.assertEquals(parser.finished, true);
+    };
+
+    this.testKssSelectorRejectsFormQuery = function() {
+        // kssSelector rejects 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:              setAttribute;\n"
+               + "    setAttribute-kssSelector:   form('name');\n"
+               + "    setAttribute-name:          name;\n"
+               + "    setAttribute-value:          value;\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
+            'Expected string or a selection result and got [formquery] in the kss action parameter [kssSelector]., at row 1, column 11');
+    };
+
+    this.testKssSubmitFormAcceptsFormQuery = function() {
+        // kssSubmitForm accepts 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-server:              doIt;\n"
+               + "    doIt-kssSubmitForm:         form('name');\n"
+               + "}\n"
+        var cursor = new kukit.tk.Cursor(txt);
+        var parser = new kukit.kssp.Document(cursor, null, true);
+        this.assertEquals(parser.finished, true);
+    };
+
+    this.testKssSubmitFormAcceptsString = function() {
+        // kssSubmitForm accepts string
+        // (it will evaluate as form(xxx), but we can't check that without a dom)
+        //
+        // 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"
+               + "}\n"
+        var cursor = new kukit.tk.Cursor(txt);
+        var parser = new kukit.kssp.Document(cursor, null, true);
+        this.assertEquals(parser.finished, true);
+    };
+
+    this.testKssSubmitFormRejectsSelection = function() {
+        // kssSubmitForm rejects selection
+        //
+        // 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"
+               + "}\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
+            'Expected string or a formquery result and got [selection] in the kss action parameter [kssSubmitForm]., at row 1, column 11');
+    };
+
+}; 
+
+kukit.KssParserValueProvidersCheckTestCase.prototype = new kukit.KssParserTestCaseBase;
+
+
 kukit.KssParserSelectorTestCase = function() {
     this.name = 'kukit.KssParserSelectorTestCase';
 
@@ -1115,6 +1354,7 @@
         this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true,
             'Error : undefined namespace or event in [dnd-drog].');
     }
+
 }; 
 
 kukit.KssParserSelectorTestCase.prototype = new kukit.KssParserTestCaseBase;
@@ -1476,6 +1716,8 @@
 if (typeof(testcase_registry) != 'undefined') {
     testcase_registry.registerTestCase(kukit.KssParserTestCase,
                                        'kukit.KssParserTestCase');
+    testcase_registry.registerTestCase(kukit.KssParserValueProvidersCheckTestCase,
+                                       'kukit.KssParserValueProvidersCheckTestCase');
     testcase_registry.registerTestCase(kukit.KssParserSelectorTestCase,
                                        'kukit.KssParserSelectorTestCase');
     testcase_registry.registerTestCase(kukit.KssParserSelectorsTestCase,


More information about the Kukit-checkins mailing list