You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2011/06/29 02:36:40 UTC

svn commit: r1140922 - /tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.tml

Author: hlship
Date: Wed Jun 29 00:36:39 2011
New Revision: 1140922

URL: http://svn.apache.org/viewvc?rev=1140922&view=rev
Log:
TAP5-999: Fill in more unit tests for client-side JavaScript functions

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.tml

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.tml?rev=1140922&r1=1140921&r2=1140922&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.tml Wed Jun 29 00:36:39 2011
@@ -8,6 +8,8 @@
 
   <div id="tests">
 
+    <h2>Arrays</h2>
+
     <div>
       <p> Checks for T5.arrays.isEmpty()
         </p>
@@ -139,6 +141,76 @@
     </div>
 
     <div>
+      <p>filter() a list.</p>
+      <pre>
+        assertEqual(filter(function(value) {
+        return value % 2 === 0;
+        }, [1, 2, 3, 4, 5, 6, 7, 8, 9]), [2, 4, 6, 8])
+    </pre>
+    </div>
+
+    <div>
+      <p>
+        Check that filter passes an optional index argument.
+    </p>
+      <pre>
+        assertEqual(filter(function(value, index) {
+        return value % 2 === 0 || index % 3 === 0;
+        }, [1, 2, 3, 4, 5, 6, 7,
+        8, 9]),
+        [1, 2, 4, 6, 7, 8])
+    </pre>
+    </div>
+
+    <div>
+      <p>remove() elements from a list.</p>
+      <pre>
+        assertEqual(remove(function(value, index) {
+        return value % 2 !== 0 &amp;&amp; index % 3 !== 0;
+        }, [1, 2, 3,
+        4,
+        5, 6, 7, 8, 9]),
+        [1, 2, 4, 6, 7, 8])
+        </pre>
+    </div>
+
+    <div>
+      <p>first() on empty list returns null.</p>
+      <pre>
+        assertEqual(first(null, null), null)
+    </pre>
+    </div>
+
+    <div>
+      <p>first() match</p>
+
+      <pre>
+        assertEqual(first(function(value) { return value &gt; 3; }, [1, 2, 3, 4, 5]), 4)
+</pre>
+    </div>
+
+    <div>
+      <p>first() passes the index as the second value.</p>
+
+      <pre>
+        assertEqual(first(function(value, index) { return index &gt; 2 }, [1, 2, 3, 4, 5]), 4)
+</pre>
+
+      <div>
+        <p>extractProperty() returns a function to extract a named property.</p>
+        <pre>
+          var fn = T5.arrays.extractProperty('name')
+
+          assertEqual(fn({name: 'Tapestry', id: 5}), 'Tapestry')
+    </pre>
+      </div>
+
+    </div>
+
+    <h2>Publish / Subscribe</h2>
+
+
+    <div>
       <p> Ensure that the message object passed to pub() is delivered to the listener.</p>
       <pre>
         var message = { }