diff options
author | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-13 09:49:11 +0000 |
---|---|---|
committer | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-13 09:49:11 +0000 |
commit | e44a7e37b6c7b5961adaffc62b9042b8d442938e (patch) | |
tree | 95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojo/tests/data/utils.js | |
parent | a62b9742ee5e28bcec6872d88f50f25b820914f6 (diff) | |
download | semanticscuttle-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/dojo/tests/data/utils.js')
-rw-r--r-- | includes/js/dojo/tests/data/utils.js | 203 |
1 files changed, 203 insertions, 0 deletions
diff --git a/includes/js/dojo/tests/data/utils.js b/includes/js/dojo/tests/data/utils.js new file mode 100644 index 0000000..8b26037 --- /dev/null +++ b/includes/js/dojo/tests/data/utils.js @@ -0,0 +1,203 @@ +if(!dojo._hasResource["tests.data.utils"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["tests.data.utils"] = true; +dojo.provide("tests.data.utils"); +dojo.require("dojo.data.util.filter"); +dojo.require("dojo.data.util.sorter"); + +tests.register("tests.data.utils", + [ + function testWildcardFilter_1(t){ + var pattern = "ca*"; + var values = ["ca", "california", "Macca", "Macca*b", "Macca\\b"]; + + t.assertTrue(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testWildcardFilter_2(t){ + var pattern = "*ca"; + var values = ["ca", "california", "Macca", "Macca*b", "Macca\\b"]; + + t.assertTrue(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testWildcardFilter_3(t){ + var pattern = "*ca*"; + var values = ["ca", "california", "Macca", "Macca*b", "Macca\\b"]; + + t.assertTrue(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testWildcardFilter_4(t){ + //Try and match <anything>c<anything>a*b + var pattern = "*c*a\\*b*"; + var values = ["ca", "california", "Macca", "Macca*b", "Macca\\b"]; + + t.assertFalse(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testWildcardFilter_5(t){ + var pattern = "*c*a\\\\*b"; + var values = ["ca", "california", "Macca", "Macca*b", "Macca\\b"]; + + t.assertFalse(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testWildcardFilter_caseInsensitive(t){ + var pattern = "ca*"; + var values = ["CA", "california", "Macca", "Macca*b", "Macca\\b"]; + + t.assertTrue(values[0].match(dojo.data.util.filter.patternToRegExp(pattern, true))!== null); + t.assertTrue(values[1].match(dojo.data.util.filter.patternToRegExp(pattern, true))!== null); + t.assertFalse(values[2].match(dojo.data.util.filter.patternToRegExp(pattern, true))!== null); + t.assertFalse(values[3].match(dojo.data.util.filter.patternToRegExp(pattern, true))!== null); + t.assertFalse(values[4].match(dojo.data.util.filter.patternToRegExp(pattern, true))!== null); + }, + function testSingleChar_1(t){ + var pattern = "bob?le"; + var values = ["bobble", "boble", "foo", "bobBle", "bar"]; + + t.assertTrue(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testSingleChar_2(t){ + var pattern = "?ob?le"; + var values = ["bobble", "cob1le", "foo", "bobBle", "bar"]; + + t.assertTrue(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testBracketChar(t){ + //Make sure we don't treat this as regexp + var pattern = "*[*]*"; + var values = ["bo[b]ble", "cob1le", "foo", "[bobBle]", "b[]ar"]; + + t.assertTrue(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testBraceChar(t){ + //Make sure we don't treat this as regexp + var pattern = "*{*}*"; + var values = ["bo{b}ble", "cob1le", "foo", "{bobBle}", "b{}ar"]; + + t.assertTrue(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testParenChar(t){ + //Make sure we don't treat this as regexp + var pattern = "*(*)*"; + var values = ["bo(b)ble", "cob1le", "foo", "{bobBle}", "b()ar"]; + + t.assertTrue(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testPlusChar(t){ + //Make sure we don't treat this as regexp, so match anything with a + in it. + var pattern = "*+*"; + var values = ["bo+ble", "cob1le", "foo", "{bobBle}", "b{}ar"]; + + t.assertTrue(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testPeriodChar(t){ + //Make sure we don't treat this as regexp, so match anything with a period + var pattern = "*.*"; + var values = ["bo.ble", "cob1le", "foo", "{bobBle}", "b{}ar"]; + + t.assertTrue(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testBarChar(t){ + //Make sure we don't treat this as regexp, so match anything with a pipe bar + var pattern = "*|*"; + var values = ["bo.ble", "cob|le", "foo", "{bobBle}", "b{}ar"]; + + t.assertFalse(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testDollarSignChar(t){ + //Make sure we don't treat this as regexp, so match anything with a $ in it + var pattern = "*$*"; + var values = ["bo$ble", "cob$le", "foo", "{bobBle}", "b{}ar"]; + + t.assertTrue(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testCarrotChar(t){ + //Make sure we don't treat this as regexp, so match anything with a ^ in it + var pattern = "*^*"; + var values = ["bo$ble", "cob$le", "f^oo", "{bobBle}", "b{}ar"]; + + t.assertFalse(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertTrue(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testEscapeChar(t){ + //Make sure we escape properly, so match this single word. + var pattern = "bob\*ble"; + var values = ["bob*ble", "cob$le", "f^oo", "{bobBle}", "b{}ar"]; + + t.assertTrue(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + }, + function testAbsoluteMatch(t){ + var pattern = "bobble"; + var values = ["bobble", "cob$le", "f^oo", "{bobBle}", "b{}ar"]; + + t.assertTrue(values[0].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[1].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[2].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[3].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + t.assertFalse(values[4].match(dojo.data.util.filter.patternToRegExp(pattern))!== null); + } + ] +); + + +} |