summaryrefslogtreecommitdiff
path: root/includes/js/dojox/string/tests/Builder.js
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
commite44a7e37b6c7b5961adaffc62b9042b8d442938e (patch)
tree95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojox/string/tests/Builder.js
parenta62b9742ee5e28bcec6872d88f50f25b820914f6 (diff)
downloadsemanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz
semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojox/string/tests/Builder.js')
-rw-r--r--includes/js/dojox/string/tests/Builder.js91
1 files changed, 91 insertions, 0 deletions
diff --git a/includes/js/dojox/string/tests/Builder.js b/includes/js/dojox/string/tests/Builder.js
new file mode 100644
index 0000000..fc51291
--- /dev/null
+++ b/includes/js/dojox/string/tests/Builder.js
@@ -0,0 +1,91 @@
+if(!dojo._hasResource["dojox.string.tests.Builder"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.string.tests.Builder"] = true;
+dojo.provide("dojox.string.tests.Builder");
+
+dojo.require("dojox.string.Builder");
+
+tests.register("dojox.string.tests.Builder", [
+ {
+ name: "Append",
+ runTest: function(t) {
+ var b = new dojox.string.Builder();
+ b.append("foo");
+ t.is("foo", b.toString());
+ b.append("bar", "baz");
+ t.is("foobarbaz", b.toString());
+ b.append("ben").append("zoo");
+ t.is("foobarbazbenzoo", b.toString());
+ b.append(5);
+ t.is("foobarbazbenzoo5", b.toString());
+ }
+ },
+ {
+ name: "Construction",
+ runTest: function(t){
+ var b = new dojox.string.Builder();
+ t.is("", b.toString());
+ b = new dojox.string.Builder("foo");
+ t.is("foo", b.toString());
+ }
+ },
+ {
+ name: "Replace",
+ runTest: function(t){
+ var b = new dojox.string.Builder("foobar");
+ t.is("foobar", b.toString());
+ b.replace("foo", "baz");
+ t.is("bazbar", b.toString());
+ b.replace("baz", "ben");
+ t.is("benbar", b.toString());
+ b.replace("foo", "moo");
+ t.is("benbar", b.toString());
+ b.replace("enba", "o");
+ t.is("bor", b.toString());
+ b.replace("o", "a").replace("b", "f");
+ t.is("far", b.toString());
+ }
+ },
+ {
+ name: "Insert",
+ runTest: function(t){
+ var b = new dojox.string.Builder();
+ //insert at 0 is prepend
+ b.insert(0, "foo");
+ t.is("foo", b.toString());
+ b.insert(0, "more");
+ t.is("morefoo", b.toString());
+
+ //insert positions stuff after the 4th character
+ b.insert(4, "fun");
+ t.is("morefunfoo", b.toString());
+
+ //insert at len of string is push_back
+ b.insert(10, "awesome");
+ t.is("morefunfooawesome", b.toString());
+
+ //insert past len of string is push_back
+ b.insert(100, "bad");
+ t.is("morefunfooawesomebad", b.toString());
+
+ b = new dojox.string.Builder();
+ b.insert(0, "foo").insert(3, "bar").insert(3, "zoo");
+ t.is("foozoobar", b.toString());
+ }
+ },
+ {
+ name: "Remove",
+ runTest: function(t){
+ var b = new dojox.string.Builder("foobarbaz");
+ b.remove(3,3);
+ t.is("foobaz", b.toString());
+ b.remove(0,3);
+ t.is("baz", b.toString());
+ b.remove(2, 100);
+ t.is("ba", b.toString());
+ b.remove(0,0);
+ t.is("ba", b.toString())
+ }
+ }
+]);
+
+}