How to use getComparator method in Playwright Internal

Best JavaScript code snippet using playwright-internal

testcollation_general.js

Source:testcollation_general.js Github

copy

Full Screen

...44function testCollatorGetComparator_it() {45 var col = new Collator({useNative: false, locale: "it-IT"});46 assertNotUndefined(col);47 // should compare in English48 var func = col.getComparator();49 assertNotUndefined(func);50 assertEquals("function", typeof(func));51}52function testCollatorGetComparatorWorks_it() {53 var col = new Collator({useNative: false, locale: "it-IT"});54 assertNotUndefined(col);55 var func = col.getComparator();56 assertNotUndefined(func);57 assertEquals("equality", 0, func("string", "string"));58 assertTrue("a < b", func("a", "b") < 0);59 assertTrue("b < c", func("b", "c") < 0);60 assertTrue("c < z", func("c", "z") < 0);61}62function testCollatorGetComparatorWorksWithCase_it() {63 var col = new Collator({useNative: false, locale: "it-IT"});64 assertNotUndefined(col);65 var func = col.getComparator();66 assertNotUndefined(func);67 // should compare upper-case first68 assertTrue("A < a", func("A", "a") < 0);69 assertTrue("B < b", func("B", "b") < 0);70 assertTrue("a < Z", func("a", "Z") < 0);71 assertTrue("Á < a", func("A", "a") < 0);72}73function testCollatorConstructorJS_it() {74 var col = new Collator({useNative: false});75 assertNotUndefined(col);76}77function testCollatorDefaultJS_it() {78 var col = new Collator({useNative: false});79 assertNotUndefined(col);80 // should compare in English81 assertEquals("equality", 0, col.compare("string", "string"));82 assertTrue("a < b", col.compare("a", "b") < 0);83 assertTrue("b < c", col.compare("b", "c") < 0);84 assertTrue("c < z", col.compare("c", "z") < 0);85}86function testCollatorDefaultCaseJS_it() {87 var col = new Collator({useNative: false});88 assertNotUndefined(col);89 // should compare upper-case first within a base character90 assertTrue("A < a", col.compare("A", "a") < 0);91 assertTrue("B < b", col.compare("B", "b") < 0);92 assertTrue("a < Z", col.compare("a", "Z") < 0);93 assertTrue("Á < a", col.compare("A", "a") < 0);94}95function testCollatorGetComparatorJS_it() {96 var col = new Collator({useNative: false});97 assertNotUndefined(col);98 // should compare in English99 var func = col.getComparator();100 assertNotUndefined(func);101 assertEquals("function", typeof(func));102}103function testCollatorGetComparatorWorksJS_it() {104 var col = new Collator({useNative: false});105 assertNotUndefined(col);106 var func = col.getComparator();107 assertNotUndefined(func);108 // should compare in English109 assertEquals("equality", 0, func("string", "string"));110 assertTrue("a < b", func("a", "b") < 0);111 assertTrue("b < c", func("b", "c") < 0);112 assertTrue("c < z", func("c", "z") < 0);113}114function testCollatorGetComparatorWorksWithCaseJS_it() {115 var col = new Collator({useNative: false});116 assertNotUndefined(col);117 var func = col.getComparator();118 assertNotUndefined(func);119 // should compare upper-case first120 assertTrue("A < a", func("A", "a") < 0);121 assertTrue("B < b", func("B", "b") < 0);122 assertTrue("a < Z", func("a", "Z") < 0);123 assertTrue("Á < a", func("A", "a") < 0);124}125function testCollatorGetSortKeyNative_it() {126 if (typeof(Intl) !== 'undefined' && Intl) {127 var col = new Collator({locale: "it-IT"});128 assertNotUndefined(col);129 // no sort key available when using native...130 assertEquals("string", col.sortKey("string"));131 }132}133function testCollatorGetSortKeySimpleUpper_it() {134 var col = new Collator({useNative: false});135 assertNotUndefined(col);136 assertEquals("4204404604804a04c0", col.sortKey("ABCDEF"));137}138function testCollatorGetSortKeySimpleLower_it() {139 var col = new Collator({useNative: false});140 assertNotUndefined(col);141 assertEquals("4224424624824a24c2", col.sortKey("abcdef"));142}143function testCollatorGetSortKeyMixed_it() {144 var col = new Collator({useNative: false});145 assertNotUndefined(col);146 assertEquals("6606826425225c24e2", col.sortKey("String"));147}148function testCollatorGetSortKeyWithExpansion_it() {149 var col = new Collator({useNative: false});150 assertNotUndefined(col);151 // has 2 collation elements for "a" and "e"152 assertEquals("43e4a2", col.sortKey("æ"));153}154function testCollatorGetSortKeyWithContraction_it() {155 var col = new Collator({useNative: false});156 assertNotUndefined(col);157 // The à is actually an "a" with a second combining grave 158 // accent character. Together, they should have only 1 159 // collation element because they are normalized to an 160 // a-grave character first.161 assertEquals("427", col.sortKey("à"));162}163function testCollatorGetSortKeyEmpty_it() {164 var col = new Collator({useNative: false});165 assertNotUndefined(col);166 assertEquals("", col.sortKey(""));167}168function testCollatorGetSortKeyUndefined_it() {169 var col = new Collator({useNative: false});170 assertNotUndefined(col);171 assertEquals("", col.sortKey(undefined));172}173function testCollatorGetSortKeyDeterministic_it() {174 var col = new Collator({useNative: false});175 assertNotUndefined(col);176 // should be equal always177 assertTrue(col.sortKey("string") === col.sortKey("string"));178}179function testCollatorGetSortKeyWorks_it() {180 var col = new Collator({useNative: false});181 assertNotUndefined(col);182 // should compare in English183 assertTrue("a < b", col.sortKey("a") < col.sortKey("b"));184 assertTrue("b < c", col.sortKey("b") < col.sortKey("c"));185 assertTrue("c < z", col.sortKey("c") < col.sortKey("z"));186}187function testCollatorWithSort_it() {188 var col = new Collator({useNative: false});189 assertNotUndefined(col);190 var input = ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"];191 input.sort(col.getComparator());192 var expected = ["e", "i", "o", "p", "q", "r", "t", "u", "w", "y"];193 assertArrayEquals(expected, input);194}195function testCollatorWithSortUpperFirst_it() {196 var col = new Collator({197 locale: "it-IT",198 upperFirst: true, 199 useNative: false200 });201 assertNotUndefined(col);202 var input = ["q", "I", "e", "r", "T", "U", "i", "E", "o", "p"];203 input.sort(col.getComparator());204 var expected = ["E", "e", "I", "i", "o", "p", "q", "r", "T", "U"];205 assertArrayEquals(expected, input);206}207function testCollatorWithSortUpperNotFirst_it() {208 var col = new Collator({209 locale: "it-IT",210 upperFirst: false, 211 useNative: false212 });213 assertNotUndefined(col);214 var input = ["q", "I", "e", "r", "T", "U", "i", "E", "o", "p"];215 input.sort(col.getComparator());216 var expected = ["e", "E", "i", "I", "o", "p", "q", "r", "T", "U"];217 assertArrayEquals(expected, input);218}219function testCollatorWithSortJS_it() {220 var col = new Collator({useNative: false});221 assertNotUndefined(col);222 var input = ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"];223 input.sort(col.getComparator());224 var expected = ["e", "i", "o", "p", "q", "r", "t", "u", "w", "y"];225 assertArrayEquals(expected, input);226}227function testCollatorWithSortUpperFirstJS_it() {228 var col = new Collator({229 locale: "it-IT",230 upperFirst: true,231 useNative: false232 });233 assertNotUndefined(col);234 var input = ["q", "I", "e", "r", "T", "U", "i", "E", "o", "p"];235 input.sort(col.getComparator());236 var expected = ["E", "e", "I", "i", "o", "p", "q", "r", "T", "U"];237 assertArrayEquals(expected, input);238}239function testCollatorWithSortUpperNotFirstJS_it() {240 var col = new Collator({241 locale: "it-IT",242 upperFirst: false,243 useNative: false244 });245 assertNotUndefined(col);246 var input = ["q", "I", "e", "r", "T", "U", "i", "E", "o", "p"];247 input.sort(col.getComparator());248 var expected = ["e", "E", "i", "I", "o", "p", "q", "r", "T", "U"];249 assertArrayEquals(expected, input);250}251function testCollatorGetAvailableScripts_it() {252 assertArrayEquals(["Latn"], Collator.getAvailableScripts());253}254function testCollatorGetAvailableStyles_it() {255 assertArrayEquals(["standard"], Collator.getAvailableStyles());256}257function testCollatorDefaultExtendedChars_it() {258 // only test on platforms that support the new Intl class natively259 if (typeof(Intl) !== 'undefined') {260 var col = new Collator({locale: "it-IT"});261 assertNotUndefined(col);262 // should compare in English263 assertTrue("e < ë", col.compare("e", "ë") < 0);264 assertTrue("o < ø", col.compare("o", "ø") < 0);265 }266}267function testCollatorPrimaryExtendedChars_it() {268 // only test on platforms that support the new Intl class natively269 if (typeof(Intl) !== 'undefined') {270 var col = new Collator({271 locale: "it-IT",272 sensitivity: "primary",273 usage: "search"274 });275 assertNotUndefined(col);276 // should compare in English277 assertEquals("e = ë", 0, col.compare("e", "ë"));278 assertEquals("o = ø", 0, col.compare("o", "ø"));279 }280}281function testCollatorDefaultExtendedCharsJS_it() {282 // only test on platforms that support the new Intl class natively283 if (typeof(Intl) !== 'undefined') {284 var col = new Collator({useNative: false});285 assertNotUndefined(col);286 // should compare in English287 assertTrue("e < ë", col.compare("e", "ë") < 0);288 assertTrue("o < ø", col.compare("o", "ø") < 0);289 }290}291function testCollatorPrimaryExtendedCharsJS_it() {292 // only test on platforms that support the new Intl class natively293 if (typeof(Intl) !== 'undefined') {294 var col = new Collator({295 locale: "it-IT",296 sensitivity: "primary",297 usage: "search",298 useNative: false299 });300 assertNotUndefined(col);301 // should compare in English302 assertEquals("e = ë", 0, col.compare("e", "ë"));303 assertEquals("o = ø", 0, col.compare("o", "ø"));304 }305}306function testCollatorNativeIsNative_it() {307 // only test on platforms that support the new Intl class natively308 if (typeof(Intl) !== 'undefined') {309 var col = new Collator({locale: "it-IT"});310 assertNotUndefined(col);311 assertNotUndefined(col.collator);312 }313}314function testJSCollatorPrimaryEqual_it() {315 var col = new Collator({316 locale: "it-IT",317 useNative: false,318 sensitivity: "primary"319 });320 assertNotUndefined(col);321 // should compare base first322 assertEquals("a = a", 0, col.compare("a", "a"));323 assertEquals("å = å", 0, col.compare("å", "å"));324 assertEquals("A = A", 0, col.compare("A", "A"));325 assertEquals("à = Ã", 0, col.compare("Ã", "Ã"));326 assertEquals("à = à", 0, col.compare("à", "à"));327}328function testJSCollatorPrimaryBase_it() {329 var col = new Collator({330 locale: "it-IT",331 useNative: false,332 sensitivity: "primary"333 });334 assertNotUndefined(col);335 // should compare base first336 // A a à ã O o Õ õ337 assertTrue("a < o", col.compare("a", "o") < 0);338 assertTrue("A < o", col.compare("A", "o") < 0);339 assertTrue("ã < o", col.compare("ã", "o") < 0);340 assertTrue("à < o", col.compare("Ã", "o") < 0);341 assertTrue("a < õ", col.compare("a", "õ") < 0);342 assertTrue("A < õ", col.compare("A", "õ") < 0);343 assertTrue("ã < õ", col.compare("ã", "õ") < 0);344 assertTrue("à < õ", col.compare("Ã", "õ") < 0);345 assertTrue("a < O", col.compare("a", "O") < 0);346 assertTrue("A < O", col.compare("A", "O") < 0);347 assertTrue("ã < O", col.compare("ã", "O") < 0);348 assertTrue("à < O", col.compare("Ã", "O") < 0);349 assertTrue("a < Õ", col.compare("a", "Õ") < 0);350 assertTrue("A < Õ", col.compare("A", "Õ") < 0);351 assertTrue("ã < Õ", col.compare("ã", "Õ") < 0);352 assertTrue("à < Õ", col.compare("Ã", "Õ") < 0);353}354function testJSCollatorPrimaryAccent_it() {355 var col = new Collator({356 locale: "it-IT",357 useNative: false,358 sensitivity: "primary"359 });360 assertNotUndefined(col);361 // should compare base, then accent, then case, then variant362 // a à à å363 // (second "a" with grave is two characters: "a" character with a combining grave character)364 assertTrue("a < à", col.compare("a", "à") < 0);365 assertTrue("à < à (combining)", col.compare("à", "à") < 0);366 assertTrue("à (combining) < å", col.compare("à", "å") < 0);367}368function testJSCollatorPrimaryCase_it() {369 var col = new Collator({370 locale: "it-IT",371 useNative: false,372 sensitivity: "primary"373 });374 assertNotUndefined(col);375 // should compare base, then accent, then case, then variant376 // A À À Å a à à å O Õ o õ377 // (second set of "a" with grave is two characters: "a" character with a combining grave character)378 assertTrue("A < À", col.compare("A", "À") < 0);379 assertTrue("À < À (combining)", col.compare("À", "À") < 0);380 assertTrue("À (combining) < Å", col.compare("À", "Å") < 0);381 assertTrue("Å > a", col.compare("Å", "a") > 0);382 assertTrue("a < à", col.compare("a", "à") < 0);383 assertTrue("à < à (combining)", col.compare("à", "à") < 0);384 assertTrue("à (combining) < å", col.compare("à", "å") < 0);385 assertTrue("å < O", col.compare("å", "O") < 0);386 assertTrue("O < Õ", col.compare("O", "Õ") < 0);387 assertTrue("Õ > o", col.compare("Õ", "o") > 0);388 assertTrue("o < õ", col.compare("o", "õ") < 0);389}390function testJSCollatorGetComparatorPrimary_it() {391 var col = new Collator({392 locale: "it-IT",393 useNative: false,394 sensitivity: "primary"395 });396 assertNotUndefined(col);397 var func = col.getComparator();398 assertNotUndefined(func);399 assertEquals("function", typeof(func));400}401function testJSCollatorGetComparatorPrimaryWorks_it() {402 var col = new Collator({403 locale: "it-IT",404 useNative: false,405 sensitivity: "primary"406 });407 assertNotUndefined(col);408 var func = col.getComparator();409 assertNotUndefined(func);410}411function testJSCollatorGetComparatorPrimaryWorksWithCase_it() {412 var col = new Collator({413 locale: "it-IT",414 useNative: false,415 sensitivity: "primary"416 });417 assertNotUndefined(col);418 var func = col.getComparator();419 assertNotUndefined(func);420 // A À À Å a à à å O Õ o õ421 // (second set of "a" with grave is two characters: "a" character with a combining grave character)422 assertTrue("A < À", func("A", "À") < 0);423 assertTrue("À < À (combining)", func("À", "À") < 0);424 assertTrue("À (combining) < Å", func("À", "Å") < 0);425 assertTrue("Å > a", func("Å", "a") > 0);426 assertTrue("a < à", func("a", "à") < 0);427 assertTrue("à < à (combining)", func("à", "à") < 0);428 assertTrue("à (combining) < å", func("à", "å") < 0);429 assertTrue("å < O", func("å", "O") < 0);430 assertTrue("O < Õ", func("O", "Õ") < 0);431 assertTrue("Õ > o", func("Õ", "o") > 0);432 assertTrue("o < õ", func("o", "õ") < 0);433}434function testJSCollatorGetSortKeyPrimary_it() {435 var col = new Collator({436 locale: "it-IT",437 useNative: false,438 sensitivity: "primary"439 });440 assertNotUndefined(col);441 assertEquals("6626826425225c24e2", col.sortKey("string"));442}443function testJSCollatorGetSortKeyPrimaryWithAccentsAndCase_it() {444 var col = new Collator({445 locale: "it-IT",446 useNative: false,447 sensitivity: "primary"448 });449 assertNotUndefined(col);450 assertEquals("6606826425335c24e2", col.sortKey("Strïng"));451}452function testJSCollatorGetSortKeyPrimaryWorks_it() {453 var col = new Collator({454 locale: "it-IT",455 useNative: false,456 sensitivity: "primary"457 });458 assertNotUndefined(col);459 assertEquals("string", col.sortKey("string"), col.sortKey("string"));460 // A À À Å a à à å O Õ o õ461 assertTrue("A < À", col.sortKey("A") < col.sortKey("À"));462 assertTrue("À < À (combining)", col.sortKey("À") < col.sortKey("À"));463 assertTrue("À (combining) < Å", col.sortKey("À") < col.sortKey("Å"));464 assertTrue("Å > a", col.sortKey("Å") > col.sortKey("a"));465 assertTrue("a < à", col.sortKey("a") < col.sortKey("à"));466 assertTrue("à < à (combining)", col.sortKey("à") < col.sortKey("à"));467 assertTrue("à (combining) < å", col.sortKey("à") < col.sortKey("å"));468 assertTrue("å < O", col.sortKey("å") < col.sortKey("O"));469 assertTrue("O < Õ", col.sortKey("O") < col.sortKey("Õ"));470 assertTrue("Õ > o", col.sortKey("Õ") > col.sortKey("o"));471 assertTrue("o < õ", col.sortKey("o") < col.sortKey("õ"));472}473function testJSCollatorSecondaryEqual_it() {474 var col = new Collator({475 locale: "it-IT",476 useNative: false,477 sensitivity: "secondary"478 });479 assertNotUndefined(col);480 // should compare base first481 assertEquals("a = a", 0, col.compare("a", "a"));482 assertEquals("å = å", 0, col.compare("å", "å"));483 assertEquals("A = A", 0, col.compare("A", "A"));484 assertEquals("à = Ã", 0, col.compare("Ã", "Ã"));485 assertEquals("à = à", 0, col.compare("à", "à"));486}487function testJSCollatorSecondaryBase_it() {488 var col = new Collator({489 locale: "it-IT",490 useNative: false,491 sensitivity: "secondary"492 });493 assertNotUndefined(col);494 // should compare base first495 // A à a ã O Õ o õ496 assertTrue("a < o", col.compare("a", "o") < 0);497 assertTrue("A < o", col.compare("A", "o") < 0);498 assertTrue("ã < o", col.compare("ã", "o") < 0);499 assertTrue("à < o", col.compare("Ã", "o") < 0);500 assertTrue("a < õ", col.compare("a", "õ") < 0);501 assertTrue("A < õ", col.compare("A", "õ") < 0);502 assertTrue("ã < õ", col.compare("ã", "õ") < 0);503 assertTrue("à < õ", col.compare("Ã", "õ") < 0);504 assertTrue("a < O", col.compare("a", "O") < 0);505 assertTrue("A < O", col.compare("A", "O") < 0);506 assertTrue("ã < O", col.compare("ã", "O") < 0);507 assertTrue("à < O", col.compare("Ã", "O") < 0);508 assertTrue("a < Õ", col.compare("a", "Õ") < 0);509 assertTrue("A < Õ", col.compare("A", "Õ") < 0);510 assertTrue("ã < Õ", col.compare("ã", "Õ") < 0);511 assertTrue("à < Õ", col.compare("Ã", "Õ") < 0);512}513function testJSCollatorSecondaryAccent_it() {514 var col = new Collator({515 locale: "it-IT",516 useNative: false,517 sensitivity: "secondary"518 });519 assertNotUndefined(col);520 // should compare base, then accent, then case, then variant521 // a à à å522 // (second "a" with grave is two characters: "a" character with a combining grave character)523 assertTrue("a < à", col.compare("a", "à") < 0);524 assertTrue("à < à (combining)", col.compare("à", "à") < 0);525 assertTrue("à (combining) < å", col.compare("à", "å") < 0);526}527function testJSCollatorSecondaryCase_it() {528 var col = new Collator({529 locale: "it-IT",530 useNative: false,531 sensitivity: "secondary"532 });533 assertNotUndefined(col);534 // should compare base, then case, then accent, then variant535 // A À À Å a à à å O Õ o õ536 assertTrue("A < À", col.compare("A", "À") < 0);537 assertTrue("À < À (combining)", col.compare("À", "À") < 0);538 assertTrue("À (combining) < Å", col.compare("À", "Å") < 0);539 assertTrue("Å > a", col.compare("Å", "a") > 0);540 assertTrue("a < à", col.compare("a", "à") < 0);541 assertTrue("à < à (combining)", col.compare("à", "à") < 0);542 assertTrue("à (combining) < å", col.compare("à", "å") < 0);543 assertTrue("å < O", col.compare("å", "O") < 0);544 assertTrue("O < Õ", col.compare("O", "Õ") < 0);545 assertTrue("Õ > o", col.compare("Õ", "o") > 0);546 assertTrue("o < õ", col.compare("o", "õ") < 0);547}548function testJSCollatorGetComparatorSecondary_it() {549 var col = new Collator({550 locale: "it-IT",551 useNative: false,552 sensitivity: "secondary"553 });554 assertNotUndefined(col);555 var func = col.getComparator();556 assertNotUndefined(func);557 assertEquals("function", typeof(func));558}559function testJSCollatorGetComparatorSecondaryWorks_it() {560 var col = new Collator({561 locale: "it-IT",562 useNative: false,563 sensitivity: "secondary"564 });565 assertNotUndefined(col);566 var func = col.getComparator();567 assertNotUndefined(func);568}569function testJSCollatorGetComparatorSecondaryWorksWithCase_it() {570 var col = new Collator({571 locale: "it-IT",572 useNative: false,573 sensitivity: "secondary"574 });575 assertNotUndefined(col);576 var func = col.getComparator();577 assertNotUndefined(func);578 // A À À Å a à à å O Õ o õ579 assertTrue("A < À", func("A", "À") < 0);580 assertTrue("À < À (combining)", func("À", "À") < 0);581 assertTrue("À (combining) < Å", func("À", "Å") < 0);582 assertTrue("Å > a", func("Å", "a") > 0);583 assertTrue("a < à", func("a", "à") < 0);584 assertTrue("à < à (combining)", func("à", "à") < 0);585 assertTrue("à (combining) < å", func("à", "å") < 0);586 assertTrue("å < O", func("å", "O") < 0);587 assertTrue("O < Õ", func("O", "Õ") < 0);588 assertTrue("Õ > o", func("Õ", "o") > 0);589 assertTrue("o < õ", func("o", "õ") < 0);590}591function testJSCollatorGetSortKeySecondary_it() {592 var col = new Collator({593 locale: "it-IT",594 useNative: false,595 sensitivity: "secondary"596 });597 assertNotUndefined(col);598 assertEquals("6626826425225c24e2", col.sortKey("string"));599}600function testJSCollatorGetSortKeySecondaryWithAccentsAndCase_it() {601 var col = new Collator({602 locale: "it-IT",603 useNative: false,604 sensitivity: "secondary"605 });606 assertNotUndefined(col);607 assertEquals("6606826425335c24e2", col.sortKey("Strïng"));608}609function testJSCollatorGetSortKeySecondaryWorks_it() {610 var col = new Collator({611 locale: "it-IT",612 useNative: false,613 sensitivity: "secondary"614 });615 assertNotUndefined(col);616 assertEquals("string", col.sortKey("string"), col.sortKey("string"));617 // A À À Å a à à å O Õ o õ618 assertTrue("A < À", col.sortKey("A") < col.sortKey("À"));619 assertTrue("À < À (combining)", col.sortKey("À") < col.sortKey("À"));620 assertTrue("À (combining) < Å", col.sortKey("À") < col.sortKey("Å"));621 assertTrue("Å > a", col.sortKey("Å") > col.sortKey("a"));622 assertTrue("a < à", col.sortKey("a") < col.sortKey("à"));623 assertTrue("à < à (combining)", col.sortKey("à") < col.sortKey("à"));624 assertTrue("à (combining) < å", col.sortKey("à") < col.sortKey("å"));625 assertTrue("å < O", col.sortKey("å") < col.sortKey("O"));626 assertTrue("O < Õ", col.sortKey("O") < col.sortKey("Õ"));627 assertTrue("Õ > o", col.sortKey("Õ") > col.sortKey("o"));628 assertTrue("o < õ", col.sortKey("o") < col.sortKey("õ"));629}630function testJSCollatorTertiaryEqual_it() {631 var col = new Collator({632 locale: "it-IT",633 useNative: false,634 sensitivity: "tertiary"635 });636 assertNotUndefined(col);637 // should compare base first638 assertEquals("a = a", 0, col.compare("a", "a"));639 assertEquals("å = å", 0, col.compare("å", "å"));640 assertEquals("A = A", 0, col.compare("A", "A"));641 assertEquals("à = Ã", 0, col.compare("Ã", "Ã"));642 assertEquals("à = à", 0, col.compare("à", "à"));643}644function testJSCollatorTertiaryBase_it() {645 var col = new Collator({646 locale: "it-IT",647 useNative: false,648 sensitivity: "tertiary"649 });650 assertNotUndefined(col);651 // should compare base first652 // A à a ã O Õ o õ653 assertTrue("a < o", col.compare("a", "o") < 0);654 assertTrue("A < o", col.compare("A", "o") < 0);655 assertTrue("ã < o", col.compare("ã", "o") < 0);656 assertTrue("à < o", col.compare("Ã", "o") < 0);657 assertTrue("a < õ", col.compare("a", "õ") < 0);658 assertTrue("A < õ", col.compare("A", "õ") < 0);659 assertTrue("ã < õ", col.compare("ã", "õ") < 0);660 assertTrue("à < õ", col.compare("Ã", "õ") < 0);661 assertTrue("a < O", col.compare("a", "O") < 0);662 assertTrue("A < O", col.compare("A", "O") < 0);663 assertTrue("ã < O", col.compare("ã", "O") < 0);664 assertTrue("à < O", col.compare("Ã", "O") < 0);665 assertTrue("a < Õ", col.compare("a", "Õ") < 0);666 assertTrue("A < Õ", col.compare("A", "Õ") < 0);667 assertTrue("ã < Õ", col.compare("ã", "Õ") < 0);668 assertTrue("à < Õ", col.compare("Ã", "Õ") < 0);669}670function testJSCollatorTertiaryAccent_it() {671 var col = new Collator({672 locale: "it-IT",673 useNative: false,674 sensitivity: "tertiary"675 });676 assertNotUndefined(col);677 // should compare base, then accent678 // (second "a" with grave is two characters: "a" character with a combining grave character)679 assertTrue("a < à", col.compare("a", "à") < 0);680 assertTrue("à < à (combining)", col.compare("à", "à") < 0);681 assertTrue("à (combining) < å", col.compare("à", "å") < 0);682}683function testJSCollatorTertiaryCase_it() {684 var col = new Collator({685 locale: "it-IT",686 useNative: false,687 sensitivity: "tertiary"688 });689 assertNotUndefined(col);690 // should compare base, then case, then accent, then variant691 // A À À Å a à à å O Õ o õ692 assertTrue("A < À", col.compare("A", "À") < 0);693 assertTrue("À < À (combining)", col.compare("À", "À") < 0);694 assertTrue("À (combining) < Å", col.compare("À", "Å") < 0);695 assertTrue("Å > a", col.compare("Å", "a") > 0);696 assertTrue("a < à", col.compare("a", "à") < 0);697 assertTrue("à < à (combining)", col.compare("à", "à") < 0);698 assertTrue("à (combining) < å", col.compare("à", "å") < 0);699 assertTrue("å < O", col.compare("å", "O") < 0);700 assertTrue("O < Õ", col.compare("O", "Õ") < 0);701 assertTrue("Õ > o", col.compare("Õ", "o") > 0);702 assertTrue("o < õ", col.compare("o", "õ") < 0);703}704function testJSCollatorGetComparatorTertiary_it() {705 var col = new Collator({706 locale: "it-IT",707 useNative: false,708 sensitivity: "tertiary"709 });710 assertNotUndefined(col);711 var func = col.getComparator();712 assertNotUndefined(func);713 assertEquals("function", typeof(func));714}715function testJSCollatorGetComparatorTertiaryWorks_it() {716 var col = new Collator({717 locale: "it-IT",718 useNative: false,719 sensitivity: "tertiary"720 });721 assertNotUndefined(col);722 var func = col.getComparator();723 assertNotUndefined(func);724}725function testJSCollatorGetComparatorTertiaryWorksWithCase_it() {726 var col = new Collator({727 locale: "it-IT",728 useNative: false,729 sensitivity: "tertiary"730 });731 assertNotUndefined(col);732 var func = col.getComparator();733 assertNotUndefined(func);734 // A À À Å a à à å O Õ o õ735 assertTrue("A < À", func("A", "À") < 0);736 assertTrue("À < À (combining)", func("À", "À") < 0);737 assertTrue("À (combining) < Å", func("À", "Å") < 0);738 assertTrue("Å > a", func("Å", "a") > 0);739 assertTrue("a < à", func("a", "à") < 0);740 assertTrue("à < à (combining)", func("à", "à") < 0);741 assertTrue("à (combining) < å", func("à", "å") < 0);742 assertTrue("å < O", func("å", "O") < 0);743 assertTrue("O < Õ", func("O", "Õ") < 0);744 assertTrue("Õ > o", func("Õ", "o") > 0);745 assertTrue("o < õ", func("o", "õ") < 0);746}747function testJSCollatorGetSortKeyTertiary_it() {748 var col = new Collator({749 locale: "it-IT",750 useNative: false,751 sensitivity: "tertiary"752 });753 assertNotUndefined(col);754 assertEquals("6626826425225c24e2", col.sortKey("string"));755}756function testJSCollatorGetSortKeyTertiaryWithAccentsAndCase_it() {757 var col = new Collator({758 locale: "it-IT",759 useNative: false,760 sensitivity: "tertiary"761 });762 assertNotUndefined(col);763 assertEquals("6606826425335c24e2", col.sortKey("Strïng"));764}765function testJSCollatorGetSortKeyTertiaryWorks_it() {766 var col = new Collator({767 locale: "it-IT",768 useNative: false,769 sensitivity: "tertiary"770 });771 assertNotUndefined(col);772 assertEquals("string", col.sortKey("string"), col.sortKey("string"));773 // A À À Å a à à å O Õ o õ774 assertTrue("A < À", col.sortKey("A") < col.sortKey("À"));775 assertTrue("À < À (combining)", col.sortKey("À") < col.sortKey("À"));776 assertTrue("À (combining) < Å", col.sortKey("À") < col.sortKey("Å"));777 assertTrue("Å > a", col.sortKey("Å") > col.sortKey("a"));778 assertTrue("a < à", col.sortKey("a") < col.sortKey("à"));779 assertTrue("à < à (combining)", col.sortKey("à") < col.sortKey("à"));780 assertTrue("à (combining) < å", col.sortKey("à") < col.sortKey("å"));781 assertTrue("å < O", col.sortKey("å") < col.sortKey("O"));782 assertTrue("O < Õ", col.sortKey("O") < col.sortKey("Õ"));783 assertTrue("Õ > o", col.sortKey("Õ") > col.sortKey("o"));784 assertTrue("o < õ", col.sortKey("o") < col.sortKey("õ"));785}786function testJSCollatorSearchPrimaryEqual_it() {787 var col = new Collator({788 locale: "it-IT",789 useNative: false,790 sensitivity: "primary",791 usage: "search"792 });793 assertNotUndefined(col);794 // should compare base first795 assertEquals("a = a", 0, col.compare("a", "a"));796 assertEquals("å = å", 0, col.compare("å", "å"));797 assertEquals("A = A", 0, col.compare("A", "A"));798 assertEquals("à = Ã", 0, col.compare("Ã", "Ã"));799 assertEquals("à = à", 0, col.compare("à", "à"));800}801function testJSCollatorSearchPrimaryBase_it() {802 var col = new Collator({803 locale: "it-IT",804 useNative: false,805 sensitivity: "primary",806 usage: "search"807 });808 assertNotUndefined(col);809 // should compare base first810 // A a à ã O o Õ õ811 assertTrue("a < o", col.compare("a", "o") < 0);812 assertTrue("A < o", col.compare("A", "o") < 0);813 assertTrue("ã < o", col.compare("ã", "o") < 0);814 assertTrue("à < o", col.compare("Ã", "o") < 0);815 assertTrue("a < õ", col.compare("a", "õ") < 0);816 assertTrue("A < õ", col.compare("A", "õ") < 0);817 assertTrue("ã < õ", col.compare("ã", "õ") < 0);818 assertTrue("à < õ", col.compare("Ã", "õ") < 0);819 assertTrue("a < O", col.compare("a", "O") < 0);820 assertTrue("A < O", col.compare("A", "O") < 0);821 assertTrue("ã < O", col.compare("ã", "O") < 0);822 assertTrue("à < O", col.compare("Ã", "O") < 0);823 assertTrue("a < Õ", col.compare("a", "Õ") < 0);824 assertTrue("A < Õ", col.compare("A", "Õ") < 0);825 assertTrue("ã < Õ", col.compare("ã", "Õ") < 0);826 assertTrue("à < Õ", col.compare("Ã", "Õ") < 0);827}828function testJSCollatorSearchPrimaryAccent_it() {829 var col = new Collator({830 locale: "it-IT",831 useNative: false,832 sensitivity: "primary",833 usage: "search"834 });835 assertNotUndefined(col);836 // should compare base, then accent, then case, then variant837 // a à à å838 // (second "a" with grave is two characters: "a" character with a combining grave character)839 assertEquals("a = à", 0, col.compare("a", "à"));840 assertEquals("à = à (combining)", 0, col.compare("à", "à"));841 assertEquals("à (combining) = å", 0, col.compare("à", "å"));842}843function testJSCollatorSearchPrimaryCase_it() {844 var col = new Collator({845 locale: "it-IT",846 useNative: false,847 sensitivity: "primary",848 usage: "search"849 });850 assertNotUndefined(col);851 // should compare base, then accent, then case, then variant852 // A a À à À à Å å O o Õ õ853 // (second set of "a" with grave is two characters: "a" character with a combining grave character)854 assertEquals("A = a", 0, col.compare("A", "a"));855 assertEquals("a = À", 0, col.compare("a", "À"));856 assertEquals("À = à", 0, col.compare("À", "à"));857 assertEquals("à = À (combining)", 0, col.compare("à", "À"));858 assertEquals("À (combining) = à (combining)", 0, col.compare("À", "à"));859 assertEquals("à (combining) = Å", 0, col.compare("à", "Å"));860 assertEquals("Å = å", 0, col.compare("Å", "å"));861 assertTrue("ã < O", col.compare("ã", "O") < 0);862 assertEquals("O = o", 0, col.compare("O", "o"));863 assertEquals("o = Õ", 0, col.compare("o", "Õ"));864 assertEquals("Õ = õ", 0, col.compare("Õ", "õ"));865}866function testJSCollatorSearchGetComparatorPrimary_it() {867 var col = new Collator({868 locale: "it-IT",869 useNative: false,870 sensitivity: "primary",871 usage: "search"872 });873 assertNotUndefined(col);874 var func = col.getComparator();875 assertNotUndefined(func);876 assertEquals("function", typeof(func));877}878function testJSCollatorSearchGetComparatorPrimaryWorks_it() {879 var col = new Collator({880 locale: "it-IT",881 useNative: false,882 sensitivity: "primary",883 usage: "search"884 });885 assertNotUndefined(col);886 var func = col.getComparator();887 assertNotUndefined(func);888}889function testJSCollatorSearchGetComparatorPrimaryWorksWithCase_it() {890 var col = new Collator({891 locale: "it-IT",892 useNative: false,893 sensitivity: "primary",894 usage: "search"895 });896 assertNotUndefined(col);897 var func = col.getComparator();898 assertNotUndefined(func);899 // A a À à À à Å å O o Õ õ900 // (second set of "a" with grave is two characters: "a" character with a combining grave character)901 assertEquals("A = a", 0, func("A", "a"));902 assertEquals("a = À", 0, func("a", "À"));903 assertEquals("À = à", 0, func("À", "à"));904 assertEquals("à = À (combining)", 0, func("à", "À"));905 assertEquals("À (combining) = à (combining)", 0, func("À", "à"));906 assertEquals("à (combining) = Å", 0, func("à", "Å"));907 assertEquals("Å = å", 0, func("Å", "å"));908 assertTrue("ã < O", func("ã", "O") < 0);909 assertEquals("O = o", 0, func("O", "o"));910 assertEquals("o = Õ", 0, func("o", "Õ"));911 assertEquals("Õ = õ", 0, func("Õ", "õ"));912}913function testJSCollatorSearchGetSortKeyPrimary_it() {914 var col = new Collator({915 locale: "it-IT",916 useNative: false,917 sensitivity: "primary",918 usage: "search"919 });920 assertNotUndefined(col);921 assertEquals("333432292e27", col.sortKey("string"));922}923function testJSCollatorSearchGetSortKeyPrimaryWithAccentsAndCase_it() {924 var col = new Collator({925 locale: "it-IT",926 useNative: false,927 sensitivity: "primary",928 usage: "search"929 });930 assertNotUndefined(col);931 assertEquals("333432292e27", col.sortKey("Strïng"));932}933function testJSCollatorSearchGetSortKeyPrimaryWorks_it() {934 var col = new Collator({935 locale: "it-IT",936 useNative: false,937 sensitivity: "primary",938 usage: "search"939 });940 assertNotUndefined(col);941 assertEquals("string", col.sortKey("string"), col.sortKey("string"));942 // A a À à À à Å å O o Õ õ943 assertEquals("A = a", col.sortKey("A"), col.sortKey("a"));944 assertEquals("a = À", col.sortKey("a"), col.sortKey("À"));945 assertEquals("À = à", col.sortKey("À"), col.sortKey("à"));946 assertEquals("à = À (combining)", col.sortKey("à"), col.sortKey("À"));947 assertEquals("À (combining) = à (combining)", col.sortKey("À"), col.sortKey("à"));948 assertEquals("à (combining) = Å", col.sortKey("à"), col.sortKey("Å"));949 assertEquals("Å = å", col.sortKey("Å"), col.sortKey("å"));950 assertTrue("ã < O", col.sortKey("ã") < col.sortKey("O"));951 assertEquals("O = o", col.sortKey("O"), col.sortKey("o"));952 assertEquals("o = Õ", col.sortKey("o"), col.sortKey("Õ"));953 assertEquals("Õ = õ", col.sortKey("Õ"), col.sortKey("õ"));954}955function testJSCollatorSearchSecondaryEqual_it() {956 var col = new Collator({957 locale: "it-IT",958 useNative: false,959 sensitivity: "secondary",960 usage: "search"961 });962 assertNotUndefined(col);963 // should compare base first964 assertEquals("a = a", 0, col.compare("a", "a"));965 assertEquals("å = å", 0, col.compare("å", "å"));966 assertEquals("A = A", 0, col.compare("A", "A"));967 assertEquals("à = Ã", 0, col.compare("Ã", "Ã"));968 assertEquals("à = à", 0, col.compare("à", "à"));969}970function testJSCollatorSearchSecondaryBase_it() {971 var col = new Collator({972 locale: "it-IT",973 useNative: false,974 sensitivity: "secondary",975 usage: "search"976 });977 assertNotUndefined(col);978 // should compare base first, then case979 // A à a ã O Õ o õ980 assertTrue("a < o", col.compare("a", "o") < 0);981 assertTrue("A < o", col.compare("A", "o") < 0);982 assertTrue("ã < o", col.compare("ã", "o") < 0);983 assertTrue("à < o", col.compare("Ã", "o") < 0);984 assertTrue("a < õ", col.compare("a", "õ") < 0);985 assertTrue("A < õ", col.compare("A", "õ") < 0);986 assertTrue("ã < õ", col.compare("ã", "õ") < 0);987 assertTrue("à < õ", col.compare("Ã", "õ") < 0);988 assertTrue("a < O", col.compare("a", "O") < 0);989 assertTrue("A < O", col.compare("A", "O") < 0);990 assertTrue("ã < O", col.compare("ã", "O") < 0);991 assertTrue("à < O", col.compare("Ã", "O") < 0);992 assertTrue("a < Õ", col.compare("a", "Õ") < 0);993 assertTrue("A < Õ", col.compare("A", "Õ") < 0);994 assertTrue("ã < Õ", col.compare("ã", "Õ") < 0);995 assertTrue("à < Õ", col.compare("Ã", "Õ") < 0);996}997function testJSCollatorSearchSecondaryAccent_it() {998 var col = new Collator({999 locale: "it-IT",1000 useNative: false,1001 sensitivity: "secondary",1002 usage: "search"1003 });1004 assertNotUndefined(col);1005 // should compare base, then case1006 // a à à å1007 // (second "a" with grave is two characters: "a" character with a combining grave character)1008 assertTrue("a < à", col.compare("a", "à") < 0);1009 assertEquals("à = à (combining)", 0, col.compare("à", "à"));1010 assertEquals("à (combining) = À", 0, col.compare("à", "À"));1011}1012function testJSCollatorSearchSecondaryCase_it() {1013 var col = new Collator({1014 locale: "it-IT",1015 useNative: false,1016 sensitivity: "secondary",1017 usage: "search"1018 });1019 assertNotUndefined(col);1020 // should compare base, then case1021 // A À À Å a à à å O Õ o õ1022 // (second set of "a" with grave is two characters: "a" character with a combining grave character)1023 assertTrue("A < À", col.compare("A", "À") < 0);1024 assertEquals("À = À (combining)", 0, col.compare("À", "À"));1025 assertTrue("À (combining) < Å", col.compare("À", "Å") < 0);1026 assertTrue("Å > a", col.compare("Å", "a") > 0);1027 assertTrue("a < à", col.compare("a", "à") < 0);1028 assertEquals("à = à (combining)", 0, col.compare("à", "à"));1029 assertTrue("à (combining) < å", col.compare("à", "å") < 0);1030 assertTrue("å < O", col.compare("å", "O") < 0);1031 assertTrue("O < Õ", col.compare("O", "Õ") < 0);1032 assertTrue("Õ > o", col.compare("Õ", "o") > 0);1033 assertTrue("o < õ", col.compare("o", "õ") < 0);1034}1035function testJSCollatorSearchGetComparatorSecondary_it() {1036 var col = new Collator({1037 locale: "it-IT",1038 useNative: false,1039 sensitivity: "secondary",1040 usage: "search"1041 });1042 assertNotUndefined(col);1043 var func = col.getComparator();1044 assertNotUndefined(func);1045 assertEquals("function", typeof(func));1046}1047function testJSCollatorSearchGetComparatorSecondaryWorks_it() {1048 var col = new Collator({1049 locale: "it-IT",1050 useNative: false,1051 sensitivity: "secondary",1052 usage: "search"1053 });1054 assertNotUndefined(col);1055 var func = col.getComparator();1056 assertNotUndefined(func);1057}1058function testJSCollatorSearchGetComparatorSecondaryWorksWithCase_it() {1059 var col = new Collator({1060 locale: "it-IT",1061 useNative: false,1062 sensitivity: "secondary",1063 usage: "search"1064 });1065 assertNotUndefined(col);1066 var func = col.getComparator();1067 assertNotUndefined(func);1068 // should compare base, then case1069 // A À À Å a à à å O Õ o õ1070 // (second set of "a" with grave is two characters: "a" character with a combining grave character)1071 assertTrue("A < À", func("A", "À") < 0);1072 assertEquals("À = À (combining)", 0, func("À", "À"));1073 assertTrue("À (combining) < Å", func("À", "Å") < 0);1074 assertTrue("Å > a", func("Å", "a") > 0);1075 assertTrue("a < à", func("a", "à") < 0);1076 assertEquals("à = à (combining)", 0, func("à", "à"));1077 assertTrue("à (combining) < å", func("à", "å") < 0);1078 assertTrue("å < O", func("å", "O") < 0);1079 assertTrue("O < Õ", func("O", "Õ") < 0);1080 assertTrue("Õ > o", func("Õ", "o") > 0);1081 assertTrue("o < õ", func("o", "õ") < 0);1082}1083function testJSCollatorSearchGetSortKeySecondary_it() {1084 var col = new Collator({1085 locale: "it-IT",1086 useNative: false,1087 sensitivity: "secondary",1088 usage: "search"1089 });1090 assertNotUndefined(col);1091 assertEquals("1981a0190148170138", col.sortKey("string"));1092}1093function testJSCollatorSearchGetSortKeySecondaryWithAccentsAndCase_it() {1094 var col = new Collator({1095 locale: "it-IT",1096 useNative: false,1097 sensitivity: "secondary",1098 usage: "search"1099 });1100 assertNotUndefined(col);1101 assertEquals("1981a019014c170138", col.sortKey("Strïng"));1102}1103function testJSCollatorSearchGetSortKeySecondaryWorks_it() {1104 var col = new Collator({1105 locale: "it-IT",1106 useNative: false,1107 sensitivity: "secondary",1108 usage: "search"1109 });1110 assertNotUndefined(col);1111 assertEquals("string", col.sortKey("string"), col.sortKey("string"));1112 // A À À Å a à à å O Õ o õ1113 assertTrue("A < À", col.sortKey("A") < col.sortKey("À"));1114 assertTrue("À = À (combining)", col.sortKey("À") === col.sortKey("À"));1115 assertTrue("À (combining) < Å", col.sortKey("À") < col.sortKey("Å"));1116 assertTrue("Å > a", col.sortKey("Å") > col.sortKey("a"));1117 assertTrue("a < à", col.sortKey("a") < col.sortKey("à"));1118 assertTrue("à = à (combining)", col.sortKey("à") === col.sortKey("à"));1119 assertTrue("à (combining) < å", col.sortKey("à") < col.sortKey("å"));1120 assertTrue("å < O", col.sortKey("å") < col.sortKey("O"));1121 assertTrue("O < Õ", col.sortKey("O") < col.sortKey("Õ"));1122 assertTrue("Õ > o", col.sortKey("Õ") > col.sortKey("o"));1123 assertTrue("o < õ", col.sortKey("o") < col.sortKey("õ"));1124}1125function testJSCollatorSearchTertiaryEqual_it() {1126 var col = new Collator({1127 locale: "it-IT",1128 useNative: false,1129 sensitivity: "tertiary",1130 usage: "search"1131 });1132 assertNotUndefined(col);1133 // should compare base first1134 assertEquals("a = a", 0, col.compare("a", "a"));1135 assertEquals("å = å", 0, col.compare("å", "å"));1136 assertEquals("A = A", 0, col.compare("A", "A"));1137 assertEquals("à = Ã", 0, col.compare("Ã", "Ã"));1138 assertEquals("à = à", 0, col.compare("à", "à"));1139}1140function testJSCollatorSearchTertiaryBase_it() {1141 var col = new Collator({1142 locale: "it-IT",1143 useNative: false,1144 sensitivity: "tertiary",1145 usage: "search"1146 });1147 assertNotUndefined(col);1148 // should compare base first1149 // A à a ã O Õ o õ1150 assertTrue("a < o", col.compare("a", "o") < 0);1151 assertTrue("A < o", col.compare("A", "o") < 0);1152 assertTrue("ã < o", col.compare("ã", "o") < 0);1153 assertTrue("à < o", col.compare("Ã", "o") < 0);1154 assertTrue("a < õ", col.compare("a", "õ") < 0);1155 assertTrue("A < õ", col.compare("A", "õ") < 0);1156 assertTrue("ã < õ", col.compare("ã", "õ") < 0);1157 assertTrue("à < õ", col.compare("Ã", "õ") < 0);1158 assertTrue("a < O", col.compare("a", "O") < 0);1159 assertTrue("A < O", col.compare("A", "O") < 0);1160 assertTrue("ã < O", col.compare("ã", "O") < 0);1161 assertTrue("à < O", col.compare("Ã", "O") < 0);1162 assertTrue("a < Õ", col.compare("a", "Õ") < 0);1163 assertTrue("A < Õ", col.compare("A", "Õ") < 0);1164 assertTrue("ã < Õ", col.compare("ã", "Õ") < 0);1165 assertTrue("à < Õ", col.compare("Ã", "Õ") < 0);1166}1167function testJSCollatorSearchTertiaryAccent_it() {1168 var col = new Collator({1169 locale: "it-IT",1170 useNative: false,1171 sensitivity: "tertiary",1172 usage: "search"1173 });1174 assertNotUndefined(col);1175 // should compare base, then accent1176 // a à à å1177 // (second "a" with grave is two characters: "a" character with a combining grave character)1178 assertTrue("a < à", col.compare("a", "à") < 0);1179 assertEquals("à = à (combining)", 0, col.compare("à", "à"));1180 assertTrue("à (combining) < å", col.compare("à", "å") < 0);1181}1182function testJSCollatorSearchTertiaryCase_it() {1183 var col = new Collator({1184 locale: "it-IT",1185 useNative: false,1186 sensitivity: "tertiary",1187 usage: "search"1188 });1189 assertNotUndefined(col);1190 // should compare base, then case, then accent1191 // A À À Å a à à å O Õ o õ1192 // (second set of "a" with grave is two characters: "a" character with a combining grave character)1193 assertTrue("A < À", col.compare("A", "À") < 0);1194 assertEquals("À = À (combining)", 0, col.compare("À", "À"));1195 assertTrue("À (combining) < Å", col.compare("À", "Å") < 0);1196 assertTrue("Å > a", col.compare("Å", "a") > 0);1197 assertTrue("a < à", col.compare("a", "à") < 0);1198 assertEquals("à = à (combining)", 0, col.compare("à", "à"));1199 assertTrue("à (combining) < å", col.compare("à", "å") < 0);1200 assertTrue("å < O", col.compare("å", "O") < 0);1201 assertTrue("O < Õ", col.compare("O", "Õ") < 0);1202 assertTrue("Õ > o", col.compare("Õ", "o") > 0);1203 assertTrue("o < õ", col.compare("o", "õ") < 0);1204}1205function testJSCollatorSearchGetComparatorTertiary_it() {1206 var col = new Collator({1207 locale: "it-IT",1208 useNative: false,1209 sensitivity: "tertiary",1210 usage: "search"1211 });1212 assertNotUndefined(col);1213 var func = col.getComparator();1214 assertNotUndefined(func);1215 assertEquals("function", typeof(func));1216}1217function testJSCollatorSearchGetComparatorTertiaryWorks_it() {1218 var col = new Collator({1219 locale: "it-IT",1220 useNative: false,1221 sensitivity: "tertiary",1222 usage: "search"1223 });1224 assertNotUndefined(col);1225 var func = col.getComparator();1226 assertNotUndefined(func);1227}1228function testJSCollatorSearchGetComparatorTertiaryWorksWithCase_it() {1229 var col = new Collator({1230 locale: "it-IT",1231 useNative: false,1232 sensitivity: "tertiary",1233 usage: "search"1234 });1235 assertNotUndefined(col);1236 var func = col.getComparator();1237 assertNotUndefined(func);1238 // should compare base, then case, then accent1239 // A À À Å a à à å O Õ o õ1240 // (second set of "a" with grave is two characters: "a" character with a combining grave character)1241 assertTrue("A < À", func("A", "À") < 0);1242 assertEquals("À = À (combining)", 0, func("À", "À"));1243 assertTrue("À (combining) < Å", func("À", "Å") < 0);1244 assertTrue("Å > a", func("Å", "a") > 0);1245 assertTrue("a < à", func("a", "à") < 0);1246 assertEquals("à = à (combining)", 0, func("à", "à"));1247 assertTrue("à (combining) < å", func("à", "å") < 0);1248 assertTrue("å < O", func("å", "O") < 0);1249 assertTrue("O < Õ", func("O", "Õ") < 0);1250 assertTrue("Õ > o", func("Õ", "o") > 0);1251 assertTrue("o < õ", func("o", "õ") < 0);1252}1253function testJSCollatorSearchGetSortKeyTertiary_it() {1254 var col = new Collator({1255 locale: "it-IT",1256 useNative: false,1257 sensitivity: "tertiary",1258 usage: "search"1259 });1260 assertNotUndefined(col);1261 assertEquals("3313413212912e1271", col.sortKey("string"));1262}1263function testJSCollatorSearchGetSortKeyTertiaryWithAccentsAndCase_it() {1264 var col = new Collator({1265 locale: "it-IT",1266 useNative: false,1267 sensitivity: "tertiary",1268 usage: "search"1269 });1270 assertNotUndefined(col);1271 assertEquals("3303413212992e1271", col.sortKey("Strïng"));1272}1273function testJSCollatorSearchGetSortKeyTertiaryWorks_it() {1274 var col = new Collator({1275 locale: "it-IT",1276 useNative: false,1277 sensitivity: "tertiary",1278 usage: "search"1279 });1280 assertNotUndefined(col);1281 assertEquals("string", col.sortKey("string"), col.sortKey("string"));1282 // A À À Å a à à å O Õ o õ1283 assertTrue("A < À", col.sortKey("A") < col.sortKey("À"));1284 assertTrue("À = À (combining)", col.sortKey("À") === col.sortKey("À"));1285 assertTrue("À (combining) < Å", col.sortKey("À") < col.sortKey("Å"));1286 assertTrue("Å > a", col.sortKey("Å") > col.sortKey("a"));1287 assertTrue("a < à", col.sortKey("a") < col.sortKey("à"));1288 assertTrue("à = à (combining)", col.sortKey("à") === col.sortKey("à"));1289 assertTrue("à (combining) < å", col.sortKey("à") < col.sortKey("å"));1290 assertTrue("å < O", col.sortKey("å") < col.sortKey("O"));1291 assertTrue("O < Õ", col.sortKey("O") < col.sortKey("Õ"));1292 assertTrue("Õ > o", col.sortKey("Õ") > col.sortKey("o"));1293 assertTrue("o < õ", col.sortKey("o") < col.sortKey("õ"));1294}1295function testJSCollatorSearchQuaternaryEqual_it() {1296 var col = new Collator({1297 locale: "it-IT",1298 useNative: false,1299 sensitivity: "quaternary",1300 usage: "search"1301 });1302 assertNotUndefined(col);1303 // should compare base first1304 assertEquals("a = a", 0, col.compare("a", "a"));1305 assertEquals("å = å", 0, col.compare("å", "å"));1306 assertEquals("A = A", 0, col.compare("A", "A"));1307 assertEquals("à = Ã", 0, col.compare("Ã", "Ã"));1308 assertEquals("à = à", 0, col.compare("à", "à"));1309}1310function testJSCollatorSearchQuaternaryBase_it() {1311 var col = new Collator({1312 locale: "it-IT",1313 useNative: false,1314 sensitivity: "quaternary",1315 usage: "search"1316 });1317 assertNotUndefined(col);1318 // should compare base first1319 // A à a ã O Õ o õ1320 assertTrue("a < o", col.compare("a", "o") < 0);1321 assertTrue("A < o", col.compare("A", "o") < 0);1322 assertTrue("ã < o", col.compare("ã", "o") < 0);1323 assertTrue("à < o", col.compare("Ã", "o") < 0);1324 assertTrue("a < õ", col.compare("a", "õ") < 0);1325 assertTrue("A < õ", col.compare("A", "õ") < 0);1326 assertTrue("ã < õ", col.compare("ã", "õ") < 0);1327 assertTrue("à < õ", col.compare("Ã", "õ") < 0);1328 assertTrue("a < O", col.compare("a", "O") < 0);1329 assertTrue("A < O", col.compare("A", "O") < 0);1330 assertTrue("ã < O", col.compare("ã", "O") < 0);1331 assertTrue("à < O", col.compare("Ã", "O") < 0);1332 assertTrue("a < Õ", col.compare("a", "Õ") < 0);1333 assertTrue("A < Õ", col.compare("A", "Õ") < 0);1334 assertTrue("ã < Õ", col.compare("ã", "Õ") < 0);1335 assertTrue("à < Õ", col.compare("Ã", "Õ") < 0);1336}1337function testJSCollatorSearchQuaternaryAccent_it() {1338 var col = new Collator({1339 locale: "it-IT",1340 useNative: false,1341 sensitivity: "quaternary",1342 usage: "search"1343 });1344 assertNotUndefined(col);1345 // should compare base, then accent1346 // a à à å1347 // (second "a" with grave is two characters: "a" character with a combining grave character)1348 assertTrue("a < à", col.compare("a", "à") < 0);1349 assertTrue("à < à (combining)", col.compare("à", "à") < 0);1350 assertTrue("à (combining) < å", col.compare("à", "å") < 0);1351}1352function testJSCollatorSearchQuaternaryCase_it() {1353 var col = new Collator({1354 locale: "it-IT",1355 useNative: false,1356 sensitivity: "quaternary",1357 usage: "search"1358 });1359 assertNotUndefined(col);1360 // should compare base, then case, then accent1361 // A À À Å a à à å O Õ o õ1362 // (second set of "a" with grave is two characters: "a" character with a combining grave character)1363 assertTrue("A < À", col.compare("A", "À") < 0);1364 assertTrue("À < À (combining)", col.compare("À", "À") < 0);1365 assertTrue("À (combining) < Å", col.compare("À", "Å") < 0);1366 assertTrue("Å > a", col.compare("Å", "a") > 0);1367 assertTrue("a < à", col.compare("a", "à") < 0);1368 assertTrue("à < à (combining)", col.compare("à", "à") < 0);1369 assertTrue("à (combining) < å", col.compare("à", "å") < 0);1370 assertTrue("å < O", col.compare("å", "O") < 0);1371 assertTrue("O < Õ", col.compare("O", "Õ") < 0);1372 assertTrue("Õ > o", col.compare("Õ", "o") > 0);1373 assertTrue("o < õ", col.compare("o", "õ") < 0);1374}1375function testJSCollatorSearchGetComparatorQuaternary_it() {1376 var col = new Collator({1377 locale: "it-IT",1378 useNative: false,1379 sensitivity: "quaternary",1380 usage: "search"1381 });1382 assertNotUndefined(col);1383 var func = col.getComparator();1384 assertNotUndefined(func);1385 assertEquals("function", typeof(func));1386}1387function testJSCollatorSearchGetComparatorQuaternaryWorks_it() {1388 var col = new Collator({1389 locale: "it-IT",1390 useNative: false,1391 sensitivity: "quaternary",1392 usage: "search"1393 });1394 assertNotUndefined(col);1395 var func = col.getComparator();1396 assertNotUndefined(func);1397}1398function testJSCollatorSearchGetComparatorQuaternaryWorksWithCase_it() {1399 var col = new Collator({1400 locale: "it-IT",1401 useNative: false,1402 sensitivity: "quaternary",1403 usage: "search"1404 });1405 assertNotUndefined(col);1406 var func = col.getComparator();1407 assertNotUndefined(func);1408 // should compare base, then case, then accent1409 // A À À Å a à à å O Õ o õ1410 // (second set of "a" with grave is two characters: "a" character with a combining grave character)1411 assertTrue("A < À", func("A", "À") < 0);1412 assertTrue("À < À (combining)", func("À", "À") < 0);1413 assertTrue("À (combining) < Å", func("À", "Å") < 0);1414 assertTrue("Å > a", func("Å", "a") > 0);1415 assertTrue("a < à", func("a", "à") < 0);1416 assertTrue("à < à (combining)", func("à", "à") < 0);1417 assertTrue("à (combining) < å", func("à", "å") < 0);1418 assertTrue("å < O", func("å", "O") < 0);1419 assertTrue("O < Õ", func("O", "Õ") < 0);1420 assertTrue("Õ > o", func("Õ", "o") > 0);1421 assertTrue("o < õ", func("o", "õ") < 0);1422}1423function testJSCollatorSearchGetSortKeyQuaternary_it() {1424 var col = new Collator({1425 locale: "it-IT",1426 useNative: false,1427 sensitivity: "quaternary",1428 usage: "search"1429 });1430 assertNotUndefined(col);1431 assertEquals("6626826425225c24e2", col.sortKey("string"));1432}1433function testJSCollatorSearchGetSortKeyQuaternaryWithAccentsAndCase_it() {1434 var col = new Collator({1435 locale: "it-IT",1436 useNative: false,1437 sensitivity: "quaternary",1438 usage: "search"1439 });1440 assertNotUndefined(col);1441 assertEquals("6606826425335c24e2", col.sortKey("Strïng"));1442}1443function testJSCollatorSearchGetSortKeyQuaternaryWorks_it() {1444 var col = new Collator({1445 locale: "it-IT",1446 useNative: false,1447 sensitivity: "quaternary",1448 usage: "search"1449 });1450 assertNotUndefined(col);1451 assertEquals("string", col.sortKey("string"), col.sortKey("string"));1452 // A À À Å a à à å O Õ o õ1453 assertTrue("A < À", col.sortKey("A") < col.sortKey("À"));1454 assertTrue("À < À (combining)", col.sortKey("À") < col.sortKey("À"));1455 assertTrue("À (combining) < Å", col.sortKey("À") < col.sortKey("Å"));1456 assertTrue("Å > a", col.sortKey("Å") > col.sortKey("a"));1457 assertTrue("a < à", col.sortKey("a") < col.sortKey("à"));1458 assertTrue("à < à (combining)", col.sortKey("à") < col.sortKey("à"));1459 assertTrue("à (combining) < å", col.sortKey("à") < col.sortKey("å"));1460 assertTrue("å < O", col.sortKey("å") < col.sortKey("O"));1461 assertTrue("O < Õ", col.sortKey("O") < col.sortKey("Õ"));1462 assertTrue("Õ > o", col.sortKey("Õ") > col.sortKey("o"));1463 assertTrue("o < õ", col.sortKey("o") < col.sortKey("õ"));1464}1465function testCollatorJSWithSortPrimary_it() {1466 var col = new Collator({1467 locale: "it-IT",1468 useNative: false,1469 sensitivity: "primary"1470 });1471 assertNotUndefined(col);1472 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1473 input.sort(col.getComparator());1474 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];1475 assertArrayEquals(expected, input);1476}1477function testCollatorJSWithSortPrimaryStable_it() {1478 var col = new Collator({1479 locale: "it-IT",1480 useNative: false,1481 sensitivity: "primary"1482 });1483 assertNotUndefined(col);1484 // input array order should not matter1485 var input = ["strïng", "Strïng", "StrinG", "Strïng", "str", "String", "strïng", "strïnG", "string"];1486 input.sort(col.getComparator());1487 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];1488 assertArrayEquals(expected, input);1489}1490function testCollatorJSWithSortPrimaryLowerFirst_it() {1491 var col = new Collator({1492 locale: "it-IT",1493 useNative: false,1494 sensitivity: "primary",1495 upperFirst: false1496 });1497 assertNotUndefined(col);1498 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1499 input.sort(col.getComparator());1500 var expected = ["str", "string", "strïng", "strïnG", "strïng", "String", "StrinG", "Strïng", "Strïng"];1501 assertArrayEquals(expected, input);1502}1503function testCollatorJSWithSortPrimaryReverse_it() {1504 var col = new Collator({1505 locale: "it-IT",1506 useNative: false,1507 sensitivity: "primary",1508 reverse: true1509 });1510 assertNotUndefined(col);1511 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1512 input.sort(col.getComparator());1513 var expected = ["strïng", "strïng", "strïnG", "string", "str", "Strïng", "Strïng", "String", "StrinG"];1514 assertArrayEquals(expected, input);1515}1516function testCollatorJSWithSortPrimaryReverseLowerFirst_it() {1517 var col = new Collator({1518 locale: "it-IT",1519 useNative: false,1520 sensitivity: "primary",1521 reverse: true,1522 upperFirst: false1523 });1524 assertNotUndefined(col);1525 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1526 input.sort(col.getComparator());1527 var expected = ["Strïng", "Strïng", "StrinG", "String", "strïng", "strïnG", "strïng", "string", "str"];1528 assertArrayEquals(expected, input);1529}1530function testCollatorJSWithSortSecondary_it() {1531 var col = new Collator({1532 locale: "it-IT",1533 useNative: false,1534 sensitivity: "secondary"1535 });1536 assertNotUndefined(col);1537 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1538 input.sort(col.getComparator());1539 // no change from primary1540 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];1541 assertArrayEquals(expected, input);1542}1543function testCollatorJSWithSortTertiary_it() {1544 var col = new Collator({1545 locale: "it-IT",1546 useNative: false,1547 sensitivity: "tertiary"1548 });1549 assertNotUndefined(col);1550 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1551 input.sort(col.getComparator());1552 // no change from primary1553 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];1554 assertArrayEquals(expected, input);1555}1556function testCollatorJSWithSortWithSortKeys_it() {1557 var col = new Collator({1558 locale: "it-IT",1559 useNative: false,1560 sensitivity: "primary"1561 });1562 assertNotUndefined(col);1563 var input = [1564 col.sortKey("Strïng"), 1565 col.sortKey("strïng"), 1566 col.sortKey("String"), 1567 col.sortKey("StrinG"), 1568 col.sortKey("Strïng"), 1569 col.sortKey("string"), 1570 col.sortKey("str"), 1571 col.sortKey("strïng"), 1572 col.sortKey("strïnG")1573 ];1574 input.sort(); // use generic non-locale-sensitive sort!1575 var expected = [1576 col.sortKey("StrinG"),1577 col.sortKey("String"),1578 col.sortKey("Strïng"),1579 col.sortKey("Strïng"),1580 col.sortKey("str"),1581 col.sortKey("string"),1582 col.sortKey("strïnG"),1583 col.sortKey("strïng"),1584 col.sortKey("strïng")1585 ];1586 assertArrayEquals(expected, input);1587}1588function testCollatorJSWithSortUpperFirst_it() {1589 var col = new Collator({1590 locale: "it-IT",1591 useNative: false,1592 upperFirst: true1593 });1594 assertNotUndefined(col);1595 var input = ["q", "I", "e", "r", "T", "U", "i", "E", "o", "p"];1596 input.sort(col.getComparator());1597 var expected = ["E", "e", "I", "i", "o", "p", "q", "r", "T", "U"];1598 assertArrayEquals(expected, input);1599}1600function testCollatorJSWithSortUpperNotFirst_it() {1601 var col = new Collator({1602 locale: "it-IT",1603 useNative: false,1604 upperFirst: false1605 });1606 assertNotUndefined(col);1607 var input = ["q", "I", "e", "r", "T", "U", "i", "E", "o", "p"];1608 input.sort(col.getComparator());1609 var expected = ["e", "E", "i", "I", "o", "p", "q", "r", "T", "U"];1610 assertArrayEquals(expected, input);1611}1612function testJSCollatorSortGetSortKeyReversePrimary_it() {1613 var col = new Collator({1614 locale: "it-IT",1615 useNative: false,1616 usage: "search",1617 reverse: true,1618 sensitivity: "primary"1619 });1620 assertNotUndefined(col);1621 assertEquals("cdccced7d2d9", col.sortKey("string"));1622}1623function testJSCollatorSortGetSortKeyReverseQuaternary_it() {1624 var col = new Collator({1625 locale: "it-IT",1626 useNative: false,1627 usage: "search",1628 reverse: true,1629 sensitivity: "quaternary"1630 });1631 assertNotUndefined(col);1632 assertEquals("99e97e9beadea3eb1e", col.sortKey("string"));1633}1634function testCollatorJSWithSortWithSortKeysReverse_it() {1635 var col = new Collator({1636 locale: "it-IT",1637 useNative: false,1638 sensitivity: "primary",1639 reverse: true1640 });1641 assertNotUndefined(col);1642 var input = [1643 col.sortKey("Strïng"), 1644 col.sortKey("strïng"), 1645 col.sortKey("String"), 1646 col.sortKey("StrinG"), 1647 col.sortKey("Strïng"), 1648 col.sortKey("string"), 1649 col.sortKey("str"), 1650 col.sortKey("strïng"), 1651 col.sortKey("strïnG")1652 ];1653 input.sort(); // use generic non-locale-sensitive sort!1654 var expected = [1655 col.sortKey("str"),1656 col.sortKey("strïng"),1657 col.sortKey("strïng"),1658 col.sortKey("strïnG"),1659 col.sortKey("string"),1660 col.sortKey("Strïng"),1661 col.sortKey("Strïng"),1662 col.sortKey("String"),1663 col.sortKey("StrinG") 1664 ];1665 assertArrayEquals(expected, input);1666}1667function testJSCollatorIgnorePunctuation_it() {1668 var col = new Collator({1669 locale: "it-IT",1670 useNative: false,1671 sensitivity: "case",1672 ignorePunctuation: true1673 });1674 assertNotUndefined(col);1675 assertEquals(0, col.compare("string", "'st,ri-ng"));1676}1677function testJSCollatorIgnorePunctuationNoPunct_it() {1678 var col = new Collator({1679 locale: "it-IT",1680 useNative: false,1681 sensitivity: "case",1682 ignorePunctuation: true1683 });1684 assertNotUndefined(col);1685 assertEquals(0, col.compare("string", "string"));1686}1687function testJSCollatorIgnorePunctuationSortKey_it() {1688 var col = new Collator({1689 locale: "it-IT",1690 useNative: false,1691 sensitivity: "case",1692 ignorePunctuation: true1693 });1694 assertNotUndefined(col);1695 assertEquals("6606826425225c24e2", col.sortKey("-@#%St-ring-#@%"));1696}1697function testJSCollatorNumeric_it() {1698 var col = new Collator({1699 locale: "it-IT",1700 useNative: false,1701 sensitivity: "case",1702 numeric: true1703 });1704 assertNotUndefined(col);1705 assertEquals(0, col.compare("00123.4", "123.4"));1706}1707function testJSCollatorNumericNoNumbers_it() {1708 var col = new Collator({1709 locale: "it-IT",1710 useNative: false,1711 sensitivity: "case",1712 numeric: true1713 });1714 assertNotUndefined(col);1715 assertTrue(col.compare("asdf", "fooo") < 0);1716}1717function testJSCollatorNumericLeftNumber_it() {1718 var col = new Collator({1719 locale: "it-IT",1720 useNative: false,1721 sensitivity: "case",1722 numeric: true1723 });1724 assertNotUndefined(col);1725 assertTrue(col.compare("1", "fooo") < 0);1726}1727function testJSCollatorNumericRightNumber_it() {1728 var col = new Collator({1729 locale: "it-IT",1730 useNative: false,1731 sensitivity: "case",1732 numeric: true1733 });1734 assertNotUndefined(col);1735 assertTrue(col.compare("asdf", "231234") > 0);1736}1737function testJSCollatorWithThousandsSeparator_it() {1738 var col = new Collator({1739 locale: "it-IT",1740 useNative: false,1741 sensitivity: "case",1742 numeric: true1743 });1744 assertNotUndefined(col);1745 assertEquals(0, col.compare("12.454.454,4", "0.012.454.454,4"));1746}1747function testJSCollatorNumeric1_it() {1748 var col = new Collator({1749 locale: "it-IT",1750 useNative: false,1751 sensitivity: "case",1752 numeric: true1753 });1754 assertNotUndefined(col);1755 assertTrue(col.compare("10", "1") > 0);1756}1757function testJSCollatorNumeric2_it() {1758 var col = new Collator({1759 locale: "it-IT",1760 useNative: false,1761 sensitivity: "case",1762 numeric: true1763 });1764 assertNotUndefined(col);1765 assertTrue(col.compare("100", "10") > 0);1766}1767function testJSCollatorNumeric3_it() {1768 var col = new Collator({1769 locale: "it-IT",1770 useNative: false,1771 sensitivity: "case",1772 numeric: true1773 });1774 assertNotUndefined(col);1775 assertTrue(col.compare("100", "99") > 0);1776}1777function testJSCollatorNumeric4_it() {1778 var col = new Collator({1779 locale: "it-IT",1780 useNative: false,1781 sensitivity: "case",1782 numeric: true1783 });1784 assertNotUndefined(col);1785 assertTrue(col.compare("100", "99,9") > 0);1786}1787function testJSCollatorNumericWithText_it() {1788 var col = new Collator({1789 locale: "it-IT",1790 useNative: false,1791 sensitivity: "case",1792 numeric: true1793 });1794 assertNotUndefined(col);1795 assertTrue(col.compare("1 box", "2 boxes") < 0);1796}1797function testJSCollatorNumericWithText_it() {1798 var col = new Collator({1799 locale: "it-IT",1800 useNative: false,1801 sensitivity: "case",1802 numeric: true1803 });1804 assertNotUndefined(col);1805 assertTrue(col.compare("20 boxes", "2 boxes") > 0);1806}1807function testJSCollatorNumericWithText2_it() {1808 var col = new Collator({1809 locale: "it-IT",1810 useNative: false,1811 sensitivity: "case",1812 numeric: true1813 });1814 assertNotUndefined(col);1815 assertTrue(col.compare("20,1 boxes", "201 boxes") < 0);1816}1817function testJSCollatorNumericSortKey1_it() {1818 var col = new Collator({1819 locale: "it-IT",1820 useNative: false,1821 sensitivity: "case",1822 numeric: true1823 });1824 assertNotUndefined(col);1825 assertEquals("0000000000000001", col.sortKey("1"));1826}1827function testJSCollatorNumericSortKey255_it() {1828 var col = new Collator({1829 locale: "it-IT",1830 useNative: false,1831 sensitivity: "case",1832 numeric: true1833 });1834 assertNotUndefined(col);1835 assertEquals("00000000000000ff", col.sortKey("255"));1836}1837function testJSCollatorNumericSortKeyBig_it() {1838 var col = new Collator({1839 locale: "it-IT",1840 useNative: false,1841 sensitivity: "case",1842 numeric: true1843 });1844 assertNotUndefined(col);1845 assertEquals("00000fadaa62dfa1", col.sortKey("17238562365345"));1846}1847function testCollatorJSWithSortPrimary_af() {1848 var col = new Collator({1849 locale: "af-ZA",1850 useNative: false,1851 sensitivity: "primary"1852 });1853 assertNotUndefined(col);1854 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1855 input.sort(col.getComparator());1856 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];1857 assertArrayEquals(expected, input);1858}1859function testCollatorJSWithSortPrimaryStable_af() {1860 var col = new Collator({1861 locale: "af-ZA",1862 useNative: false,1863 sensitivity: "primary"1864 });1865 assertNotUndefined(col);1866 // input array order should not matter1867 var input = ["strïng", "Strïng", "StrinG", "Strïng", "str", "String", "strïng", "strïnG", "string"];1868 input.sort(col.getComparator());1869 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];1870 assertArrayEquals(expected, input);1871}1872function testCollatorJSWithSortPrimaryLowerFirst_af() {1873 var col = new Collator({1874 locale: "af-ZA",1875 useNative: false,1876 sensitivity: "primary",1877 upperFirst: false1878 });1879 assertNotUndefined(col);1880 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1881 input.sort(col.getComparator());1882 var expected = ["str", "string", "strïng", "strïnG", "strïng", "String", "StrinG", "Strïng", "Strïng"];1883 assertArrayEquals(expected, input);1884}1885function testCollatorJSWithSortPrimaryReverse_af() {1886 var col = new Collator({1887 locale: "af-ZA",1888 useNative: false,1889 sensitivity: "primary",1890 reverse: true1891 });1892 assertNotUndefined(col);1893 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1894 input.sort(col.getComparator());1895 var expected = ["strïng", "strïng", "strïnG", "string", "str", "Strïng", "Strïng", "String", "StrinG"];1896 assertArrayEquals(expected, input);1897}1898function testCollatorJSWithSortPrimaryReverseLowerFirst_af() {1899 var col = new Collator({1900 locale: "af-ZA",1901 useNative: false,1902 sensitivity: "primary",1903 reverse: true,1904 upperFirst: false1905 });1906 assertNotUndefined(col);1907 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1908 input.sort(col.getComparator());1909 var expected = ["Strïng", "Strïng", "StrinG", "String", "strïng", "strïnG", "strïng", "string", "str"];1910 assertArrayEquals(expected, input);1911}1912function testCollatorJSWithSortSecondary_af() {1913 var col = new Collator({1914 locale: "af-ZA",1915 useNative: false,1916 sensitivity: "secondary"1917 });1918 assertNotUndefined(col);1919 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1920 input.sort(col.getComparator());1921 // no change from primary1922 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];1923 assertArrayEquals(expected, input);1924}1925function testCollatorJSWithSortTertiary_af() {1926 var col = new Collator({1927 locale: "af-ZA",1928 useNative: false,1929 sensitivity: "tertiary"1930 });1931 assertNotUndefined(col);1932 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1933 input.sort(col.getComparator());1934 // no change from primary1935 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];1936 assertArrayEquals(expected, input);1937}1938function testCollatorJSWithSortPrimary_eu() {1939 var col = new Collator({1940 locale: "eu-ES",1941 useNative: false,1942 sensitivity: "primary"1943 });1944 assertNotUndefined(col);1945 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1946 input.sort(col.getComparator());1947 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];1948 assertArrayEquals(expected, input);1949}1950function testCollatorJSWithSortPrimaryStable_eu() {1951 var col = new Collator({1952 locale: "eu-ES",1953 useNative: false,1954 sensitivity: "primary"1955 });1956 assertNotUndefined(col);1957 // input array order should not matter1958 var input = ["strïng", "Strïng", "StrinG", "Strïng", "str", "String", "strïng", "strïnG", "string"];1959 input.sort(col.getComparator());1960 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];1961 assertArrayEquals(expected, input);1962}1963function testCollatorJSWithSortPrimaryLowerFirst_eu() {1964 var col = new Collator({1965 locale: "eu-ES",1966 useNative: false,1967 sensitivity: "primary",1968 upperFirst: false1969 });1970 assertNotUndefined(col);1971 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1972 input.sort(col.getComparator());1973 var expected = ["str", "string", "strïng", "strïnG", "strïng", "String", "StrinG", "Strïng", "Strïng"];1974 assertArrayEquals(expected, input);1975}1976function testCollatorJSWithSortPrimaryReverse_eu() {1977 var col = new Collator({1978 locale: "eu-ES",1979 useNative: false,1980 sensitivity: "primary",1981 reverse: true1982 });1983 assertNotUndefined(col);1984 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1985 input.sort(col.getComparator());1986 var expected = ["strïng", "strïng", "strïnG", "string", "str", "Strïng", "Strïng", "String", "StrinG"];1987 assertArrayEquals(expected, input);1988}1989function testCollatorJSWithSortPrimaryReverseLowerFirst_eu() {1990 var col = new Collator({1991 locale: "eu-ES",1992 useNative: false,1993 sensitivity: "primary",1994 reverse: true,1995 upperFirst: false1996 });1997 assertNotUndefined(col);1998 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];1999 input.sort(col.getComparator());2000 var expected = ["Strïng", "Strïng", "StrinG", "String", "strïng", "strïnG", "strïng", "string", "str"];2001 assertArrayEquals(expected, input);2002}2003function testCollatorJSWithSortSecondary_eu() {2004 var col = new Collator({2005 locale: "eu-ES",2006 useNative: false,2007 sensitivity: "secondary"2008 });2009 assertNotUndefined(col);2010 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2011 input.sort(col.getComparator());2012 // no change from primary2013 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2014 assertArrayEquals(expected, input);2015}2016function testCollatorJSWithSortTertiary_eu() {2017 var col = new Collator({2018 locale: "eu-ES",2019 useNative: false,2020 sensitivity: "tertiary"2021 });2022 assertNotUndefined(col);2023 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2024 input.sort(col.getComparator());2025 // no change from primary2026 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2027 assertArrayEquals(expected, input);2028}2029function testCollatorJSWithSortPrimary_ca() {2030 var col = new Collator({2031 locale: "ca-ES",2032 useNative: false,2033 sensitivity: "primary"2034 });2035 assertNotUndefined(col);2036 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2037 input.sort(col.getComparator());2038 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2039 assertArrayEquals(expected, input);2040}2041function testCollatorJSWithSortPrimaryStable_ca() {2042 var col = new Collator({2043 locale: "ca-ES",2044 useNative: false,2045 sensitivity: "primary"2046 });2047 assertNotUndefined(col);2048 // input array order should not matter2049 var input = ["strïng", "Strïng", "StrinG", "Strïng", "str", "String", "strïng", "strïnG", "string"];2050 input.sort(col.getComparator());2051 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2052 assertArrayEquals(expected, input);2053}2054function testCollatorJSWithSortPrimaryLowerFirst_ca() {2055 var col = new Collator({2056 locale: "ca-ES",2057 useNative: false,2058 sensitivity: "primary",2059 upperFirst: false2060 });2061 assertNotUndefined(col);2062 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2063 input.sort(col.getComparator());2064 var expected = ["str", "string", "strïng", "strïnG", "strïng", "String", "StrinG", "Strïng", "Strïng"];2065 assertArrayEquals(expected, input);2066}2067function testCollatorJSWithSortPrimaryReverse_ca() {2068 var col = new Collator({2069 locale: "ca-ES",2070 useNative: false,2071 sensitivity: "primary",2072 reverse: true2073 });2074 assertNotUndefined(col);2075 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2076 input.sort(col.getComparator());2077 var expected = ["strïng", "strïng", "strïnG", "string", "str", "Strïng", "Strïng", "String", "StrinG"];2078 assertArrayEquals(expected, input);2079}2080function testCollatorJSWithSortPrimaryReverseLowerFirst_ca() {2081 var col = new Collator({2082 locale: "ca-ES",2083 useNative: false,2084 sensitivity: "primary",2085 reverse: true,2086 upperFirst: false2087 });2088 assertNotUndefined(col);2089 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2090 input.sort(col.getComparator());2091 var expected = ["Strïng", "Strïng", "StrinG", "String", "strïng", "strïnG", "strïng", "string", "str"];2092 assertArrayEquals(expected, input);2093}2094function testCollatorJSWithSortSecondary_ca() {2095 var col = new Collator({2096 locale: "ca-ES",2097 useNative: false,2098 sensitivity: "secondary"2099 });2100 assertNotUndefined(col);2101 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2102 input.sort(col.getComparator());2103 // no change from primary2104 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2105 assertArrayEquals(expected, input);2106}2107function testCollatorJSWithSortTertiary_ca() {2108 var col = new Collator({2109 locale: "ca-ES",2110 useNative: false,2111 sensitivity: "tertiary"2112 });2113 assertNotUndefined(col);2114 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2115 input.sort(col.getComparator());2116 // no change from primary2117 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2118 assertArrayEquals(expected, input);2119}2120function testCollatorJSWithSortPrimary_nl() {2121 var col = new Collator({2122 locale: "nl-NL",2123 useNative: false,2124 sensitivity: "primary"2125 });2126 assertNotUndefined(col);2127 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2128 input.sort(col.getComparator());2129 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2130 assertArrayEquals(expected, input);2131}2132function testCollatorJSWithSortPrimaryStable_nl() {2133 var col = new Collator({2134 locale: "nl-NL",2135 useNative: false,2136 sensitivity: "primary"2137 });2138 assertNotUndefined(col);2139 // input array order should not matter2140 var input = ["strïng", "Strïng", "StrinG", "Strïng", "str", "String", "strïng", "strïnG", "string"];2141 input.sort(col.getComparator());2142 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2143 assertArrayEquals(expected, input);2144}2145function testCollatorJSWithSortPrimaryLowerFirst_nl() {2146 var col = new Collator({2147 locale: "nl-NL",2148 useNative: false,2149 sensitivity: "primary",2150 upperFirst: false2151 });2152 assertNotUndefined(col);2153 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2154 input.sort(col.getComparator());2155 var expected = ["str", "string", "strïng", "strïnG", "strïng", "String", "StrinG", "Strïng", "Strïng"];2156 assertArrayEquals(expected, input);2157}2158function testCollatorJSWithSortPrimaryReverse_nl() {2159 var col = new Collator({2160 locale: "nl-NL",2161 useNative: false,2162 sensitivity: "primary",2163 reverse: true2164 });2165 assertNotUndefined(col);2166 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2167 input.sort(col.getComparator());2168 var expected = ["strïng", "strïng", "strïnG", "string", "str", "Strïng", "Strïng", "String", "StrinG"];2169 assertArrayEquals(expected, input);2170}2171function testCollatorJSWithSortPrimaryReverseLowerFirst_nl() {2172 var col = new Collator({2173 locale: "nl-NL",2174 useNative: false,2175 sensitivity: "primary",2176 reverse: true,2177 upperFirst: false2178 });2179 assertNotUndefined(col);2180 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2181 input.sort(col.getComparator());2182 var expected = ["Strïng", "Strïng", "StrinG", "String", "strïng", "strïnG", "strïng", "string", "str"];2183 assertArrayEquals(expected, input);2184}2185function testCollatorJSWithSortSecondary_nl() {2186 var col = new Collator({2187 locale: "nl-NL",2188 useNative: false,2189 sensitivity: "secondary"2190 });2191 assertNotUndefined(col);2192 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2193 input.sort(col.getComparator());2194 // no change from primary2195 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2196 assertArrayEquals(expected, input);2197}2198function testCollatorJSWithSortTertiary_nl() {2199 var col = new Collator({2200 locale: "nl-NL",2201 useNative: false,2202 sensitivity: "tertiary"2203 });2204 assertNotUndefined(col);2205 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2206 input.sort(col.getComparator());2207 // no change from primary2208 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2209 assertArrayEquals(expected, input);2210}2211function testCollatorJSWithSortPrimary_gl() {2212 var col = new Collator({2213 locale: "gl-ES",2214 useNative: false,2215 sensitivity: "primary"2216 });2217 assertNotUndefined(col);2218 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2219 input.sort(col.getComparator());2220 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2221 assertArrayEquals(expected, input);2222}2223function testCollatorJSWithSortPrimaryStable_gl() {2224 var col = new Collator({2225 locale: "gl-ES",2226 useNative: false,2227 sensitivity: "primary"2228 });2229 assertNotUndefined(col);2230 // input array order should not matter2231 var input = ["strïng", "Strïng", "StrinG", "Strïng", "str", "String", "strïng", "strïnG", "string"];2232 input.sort(col.getComparator());2233 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2234 assertArrayEquals(expected, input);2235}2236function testCollatorJSWithSortPrimaryLowerFirst_gl() {2237 var col = new Collator({2238 locale: "gl-ES",2239 useNative: false,2240 sensitivity: "primary",2241 upperFirst: false2242 });2243 assertNotUndefined(col);2244 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2245 input.sort(col.getComparator());2246 var expected = ["str", "string", "strïng", "strïnG", "strïng", "String", "StrinG", "Strïng", "Strïng"];2247 assertArrayEquals(expected, input);2248}2249function testCollatorJSWithSortPrimaryReverse_gl() {2250 var col = new Collator({2251 locale: "gl-ES",2252 useNative: false,2253 sensitivity: "primary",2254 reverse: true2255 });2256 assertNotUndefined(col);2257 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2258 input.sort(col.getComparator());2259 var expected = ["strïng", "strïng", "strïnG", "string", "str", "Strïng", "Strïng", "String", "StrinG"];2260 assertArrayEquals(expected, input);2261}2262function testCollatorJSWithSortPrimaryReverseLowerFirst_gl() {2263 var col = new Collator({2264 locale: "gl-ES",2265 useNative: false,2266 sensitivity: "primary",2267 reverse: true,2268 upperFirst: false2269 });2270 assertNotUndefined(col);2271 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2272 input.sort(col.getComparator());2273 var expected = ["Strïng", "Strïng", "StrinG", "String", "strïng", "strïnG", "strïng", "string", "str"];2274 assertArrayEquals(expected, input);2275}2276function testCollatorJSWithSortSecondary_gl() {2277 var col = new Collator({2278 locale: "gl-ES",2279 useNative: false,2280 sensitivity: "secondary"2281 });2282 assertNotUndefined(col);2283 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2284 input.sort(col.getComparator());2285 // no change from primary2286 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2287 assertArrayEquals(expected, input);2288}2289function testCollatorJSWithSortTertiary_gl() {2290 var col = new Collator({2291 locale: "gl-ES",2292 useNative: false,2293 sensitivity: "tertiary"2294 });2295 assertNotUndefined(col);2296 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2297 input.sort(col.getComparator());2298 // no change from primary2299 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2300 assertArrayEquals(expected, input);2301}2302function testCollatorJSWithSortPrimary_id() {2303 var col = new Collator({2304 locale: "id-ID",2305 useNative: false,2306 sensitivity: "primary"2307 });2308 assertNotUndefined(col);2309 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2310 input.sort(col.getComparator());2311 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2312 assertArrayEquals(expected, input);2313}2314function testCollatorJSWithSortPrimaryStable_id() {2315 var col = new Collator({2316 locale: "id-ID",2317 useNative: false,2318 sensitivity: "primary"2319 });2320 assertNotUndefined(col);2321 // input array order should not matter2322 var input = ["strïng", "Strïng", "StrinG", "Strïng", "str", "String", "strïng", "strïnG", "string"];2323 input.sort(col.getComparator());2324 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2325 assertArrayEquals(expected, input);2326}2327function testCollatorJSWithSortPrimaryLowerFirst_id() {2328 var col = new Collator({2329 locale: "id-ID",2330 useNative: false,2331 sensitivity: "primary",2332 upperFirst: false2333 });2334 assertNotUndefined(col);2335 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2336 input.sort(col.getComparator());2337 var expected = ["str", "string", "strïng", "strïnG", "strïng", "String", "StrinG", "Strïng", "Strïng"];2338 assertArrayEquals(expected, input);2339}2340function testCollatorJSWithSortPrimaryReverse_id() {2341 var col = new Collator({2342 locale: "id-ID",2343 useNative: false,2344 sensitivity: "primary",2345 reverse: true2346 });2347 assertNotUndefined(col);2348 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2349 input.sort(col.getComparator());2350 var expected = ["strïng", "strïng", "strïnG", "string", "str", "Strïng", "Strïng", "String", "StrinG"];2351 assertArrayEquals(expected, input);2352}2353function testCollatorJSWithSortPrimaryReverseLowerFirst_id() {2354 var col = new Collator({2355 locale: "id-ID",2356 useNative: false,2357 sensitivity: "primary",2358 reverse: true,2359 upperFirst: false2360 });2361 assertNotUndefined(col);2362 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2363 input.sort(col.getComparator());2364 var expected = ["Strïng", "Strïng", "StrinG", "String", "strïng", "strïnG", "strïng", "string", "str"];2365 assertArrayEquals(expected, input);2366}2367function testCollatorJSWithSortSecondary_id() {2368 var col = new Collator({2369 locale: "id-ID",2370 useNative: false,2371 sensitivity: "secondary"2372 });2373 assertNotUndefined(col);2374 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2375 input.sort(col.getComparator());2376 // no change from primary2377 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2378 assertArrayEquals(expected, input);2379}2380function testCollatorJSWithSortTertiary_id() {2381 var col = new Collator({2382 locale: "id-ID",2383 useNative: false,2384 sensitivity: "tertiary"2385 });2386 assertNotUndefined(col);2387 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2388 input.sort(col.getComparator());2389 // no change from primary2390 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2391 assertArrayEquals(expected, input);2392}2393function testCollatorJSWithSortPrimary_ms() {2394 var col = new Collator({2395 locale: "ms-MY",2396 useNative: false,2397 sensitivity: "primary"2398 });2399 assertNotUndefined(col);2400 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2401 input.sort(col.getComparator());2402 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2403 assertArrayEquals(expected, input);2404}2405function testCollatorJSWithSortPrimaryStable_ms() {2406 var col = new Collator({2407 locale: "ms-MY",2408 useNative: false,2409 sensitivity: "primary"2410 });2411 assertNotUndefined(col);2412 // input array order should not matter2413 var input = ["strïng", "Strïng", "StrinG", "Strïng", "str", "String", "strïng", "strïnG", "string"];2414 input.sort(col.getComparator());2415 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2416 assertArrayEquals(expected, input);2417}2418function testCollatorJSWithSortPrimaryLowerFirst_ms() {2419 var col = new Collator({2420 locale: "ms-MY",2421 useNative: false,2422 sensitivity: "primary",2423 upperFirst: false2424 });2425 assertNotUndefined(col);2426 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2427 input.sort(col.getComparator());2428 var expected = ["str", "string", "strïng", "strïnG", "strïng", "String", "StrinG", "Strïng", "Strïng"];2429 assertArrayEquals(expected, input);2430}2431function testCollatorJSWithSortPrimaryReverse_ms() {2432 var col = new Collator({2433 locale: "ms-MY",2434 useNative: false,2435 sensitivity: "primary",2436 reverse: true2437 });2438 assertNotUndefined(col);2439 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2440 input.sort(col.getComparator());2441 var expected = ["strïng", "strïng", "strïnG", "string", "str", "Strïng", "Strïng", "String", "StrinG"];2442 assertArrayEquals(expected, input);2443}2444function testCollatorJSWithSortPrimaryReverseLowerFirst_ms() {2445 var col = new Collator({2446 locale: "ms-MY",2447 useNative: false,2448 sensitivity: "primary",2449 reverse: true,2450 upperFirst: false2451 });2452 assertNotUndefined(col);2453 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2454 input.sort(col.getComparator());2455 var expected = ["Strïng", "Strïng", "StrinG", "String", "strïng", "strïnG", "strïng", "string", "str"];2456 assertArrayEquals(expected, input);2457}2458function testCollatorJSWithSortSecondary_ms() {2459 var col = new Collator({2460 locale: "ms-MY",2461 useNative: false,2462 sensitivity: "secondary"2463 });2464 assertNotUndefined(col);2465 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2466 input.sort(col.getComparator());2467 // no change from primary2468 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2469 assertArrayEquals(expected, input);2470}2471function testCollatorJSWithSortTertiary_ms() {2472 var col = new Collator({2473 locale: "ms-MY",2474 useNative: false,2475 sensitivity: "tertiary"2476 });2477 assertNotUndefined(col);2478 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2479 input.sort(col.getComparator());2480 // no change from primary2481 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2482 assertArrayEquals(expected, input);2483}2484function testCollatorJSWithSortPrimary_pt() {2485 var col = new Collator({2486 locale: "pt-BR",2487 useNative: false,2488 sensitivity: "primary"2489 });2490 assertNotUndefined(col);2491 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2492 input.sort(col.getComparator());2493 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2494 assertArrayEquals(expected, input);2495}2496function testCollatorJSWithSortPrimaryStable_pt() {2497 var col = new Collator({2498 locale: "pt-BR",2499 useNative: false,2500 sensitivity: "primary"2501 });2502 assertNotUndefined(col);2503 // input array order should not matter2504 var input = ["strïng", "Strïng", "StrinG", "Strïng", "str", "String", "strïng", "strïnG", "string"];2505 input.sort(col.getComparator());2506 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2507 assertArrayEquals(expected, input);2508}2509function testCollatorJSWithSortPrimaryLowerFirst_pt() {2510 var col = new Collator({2511 locale: "pt-BR",2512 useNative: false,2513 sensitivity: "primary",2514 upperFirst: false2515 });2516 assertNotUndefined(col);2517 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2518 input.sort(col.getComparator());2519 var expected = ["str", "string", "strïng", "strïnG", "strïng", "String", "StrinG", "Strïng", "Strïng"];2520 assertArrayEquals(expected, input);2521}2522function testCollatorJSWithSortPrimaryReverse_pt() {2523 var col = new Collator({2524 locale: "pt-BR",2525 useNative: false,2526 sensitivity: "primary",2527 reverse: true2528 });2529 assertNotUndefined(col);2530 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2531 input.sort(col.getComparator());2532 var expected = ["strïng", "strïng", "strïnG", "string", "str", "Strïng", "Strïng", "String", "StrinG"];2533 assertArrayEquals(expected, input);2534}2535function testCollatorJSWithSortPrimaryReverseLowerFirst_pt() {2536 var col = new Collator({2537 locale: "pt-BR",2538 useNative: false,2539 sensitivity: "primary",2540 reverse: true,2541 upperFirst: false2542 });2543 assertNotUndefined(col);2544 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2545 input.sort(col.getComparator());2546 var expected = ["Strïng", "Strïng", "StrinG", "String", "strïng", "strïnG", "strïng", "string", "str"];2547 assertArrayEquals(expected, input);2548}2549function testCollatorJSWithSortSecondary_pt() {2550 var col = new Collator({2551 locale: "pt-BR",2552 useNative: false,2553 sensitivity: "secondary"2554 });2555 assertNotUndefined(col);2556 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2557 input.sort(col.getComparator());2558 // no change from primary2559 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2560 assertArrayEquals(expected, input);2561}2562function testCollatorJSWithSortTertiary_pt() {2563 var col = new Collator({2564 locale: "pt-BR",2565 useNative: false,2566 sensitivity: "tertiary"2567 });2568 assertNotUndefined(col);2569 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2570 input.sort(col.getComparator());2571 // no change from primary2572 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2573 assertArrayEquals(expected, input);2574}2575function testCollatorJSWithSortPrimary_sw() {2576 var col = new Collator({2577 locale: "sw-TZ",2578 useNative: false,2579 sensitivity: "primary"2580 });2581 assertNotUndefined(col);2582 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2583 input.sort(col.getComparator());2584 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2585 assertArrayEquals(expected, input);2586}2587function testCollatorJSWithSortPrimaryStable_sw() {2588 var col = new Collator({2589 locale: "sw-TZ",2590 useNative: false,2591 sensitivity: "primary"2592 });2593 assertNotUndefined(col);2594 // input array order should not matter2595 var input = ["strïng", "Strïng", "StrinG", "Strïng", "str", "String", "strïng", "strïnG", "string"];2596 input.sort(col.getComparator());2597 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2598 assertArrayEquals(expected, input);2599}2600function testCollatorJSWithSortPrimaryLowerFirst_sw() {2601 var col = new Collator({2602 locale: "sw-TZ",2603 useNative: false,2604 sensitivity: "primary",2605 upperFirst: false2606 });2607 assertNotUndefined(col);2608 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2609 input.sort(col.getComparator());2610 var expected = ["str", "string", "strïng", "strïnG", "strïng", "String", "StrinG", "Strïng", "Strïng"];2611 assertArrayEquals(expected, input);2612}2613function testCollatorJSWithSortPrimaryReverse_sw() {2614 var col = new Collator({2615 locale: "sw-TZ",2616 useNative: false,2617 sensitivity: "primary",2618 reverse: true2619 });2620 assertNotUndefined(col);2621 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2622 input.sort(col.getComparator());2623 var expected = ["strïng", "strïng", "strïnG", "string", "str", "Strïng", "Strïng", "String", "StrinG"];2624 assertArrayEquals(expected, input);2625}2626function testCollatorJSWithSortPrimaryReverseLowerFirst_sw() {2627 var col = new Collator({2628 locale: "sw-TZ",2629 useNative: false,2630 sensitivity: "primary",2631 reverse: true,2632 upperFirst: false2633 });2634 assertNotUndefined(col);2635 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2636 input.sort(col.getComparator());2637 var expected = ["Strïng", "Strïng", "StrinG", "String", "strïng", "strïnG", "strïng", "string", "str"];2638 assertArrayEquals(expected, input);2639}2640function testCollatorJSWithSortSecondary_sw() {2641 var col = new Collator({2642 locale: "sw-TZ",2643 useNative: false,2644 sensitivity: "secondary"2645 });2646 assertNotUndefined(col);2647 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2648 input.sort(col.getComparator());2649 // no change from primary2650 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2651 assertArrayEquals(expected, input);2652}2653function testCollatorJSWithSortTertiary_sw() {2654 var col = new Collator({2655 locale: "sw-TZ",2656 useNative: false,2657 sensitivity: "tertiary"2658 });2659 assertNotUndefined(col);2660 var input = ["Strïng", "strïng", "String", "StrinG", "Strïng", "string", "str", "strïng", "strïnG"];2661 input.sort(col.getComparator());2662 // no change from primary2663 var expected = ["StrinG", "String", "Strïng", "Strïng", "str", "string", "strïnG", "strïng", "strïng"];2664 assertArrayEquals(expected, input);...

Full Screen

Full Screen

User.js

Source:User.js Github

copy

Full Screen

...44 return 1;45 }46 return 0;47}48function getComparator(order, orderBy) {49 return order === 'desc'50 ? (a, b) => descendingComparator(a, b, orderBy)51 : (a, b) => -descendingComparator(a, b, orderBy);52}53function applySortFilter(array, comparator, query) {54 const stabilizedThis = array.map((el, index) => [el, index]);55 stabilizedThis.sort((a, b) => {56 const order = comparator(a[0], b[0]);57 if (order !== 0) return order;58 return a[1] - b[1];59 });60 if (query) {61 return filter(array, (_user) => _user.fullName.toLowerCase().indexOf(query.toLowerCase()) !== -1);62 }63 return stabilizedThis.map((el) => el[0]);64}65export default function User() {66 let [loading, employees] = useGetAllEmployee();67 const [page, setPage] = useState(0);68 const [order, setOrder] = useState('asc');69 const [selected, setSelected] = useState([]);70 const [orderBy, setOrderBy] = useState('fullName');71 const [filterName, setFilterName] = useState('');72 const [rowsPerPage, setRowsPerPage] = useState(5);73 const [employeeList, setEmployeeList] = useState(null);74 const [emptyRows, setEmptyRows] = useState(page > 0 ? Math.max(0, (1 + page) * rowsPerPage - employees.length) : 0);75 const [filteredUsers, setFilteredUsers] = useState(applySortFilter(employees, getComparator(order, orderBy), filterName));76 useEffect(() => {77 setFilteredUsers(applySortFilter(employees, getComparator(order, orderBy), filterName));78 setEmptyRows(page > 0 ? Math.max(0, (1 + page) * rowsPerPage - employees.length) : 0);79 return setEmployeeList(employees);80 }, [employees]);81 const getEmployeeFromChild = (employee) => {82 employees.push(employee);83 setFilteredUsers(applySortFilter(employees, getComparator(order, orderBy), filterName))84 setEmptyRows(page > 0 ? Math.max(0, (1 + page) * rowsPerPage - employees.length) : 0);85 setEmployeeList(applySortFilter(employees, getComparator(order, orderBy), filterName));86 };87 const getEmployeeFromChildDelete = (employee) => {88 employees = employees.filter(item => item._id !== employee._id);89 setFilteredUsers(applySortFilter(employees, getComparator(order, orderBy), filterName));90 setEmptyRows(page > 0 ? Math.max(0, (1 + page) * rowsPerPage - employees.length) : 0);91 setEmployeeList(applySortFilter(employees, getComparator(order, orderBy), filterName));92 };93 const getEmployeeFromChildUpdate = async (employee) => {94 let newEmployeeList = await employees.map(item => {95 if (item._id === employee._id) {96 return employee;97 }98 return item;99 });100 setFilteredUsers(applySortFilter(newEmployeeList, getComparator(order, orderBy), filterName));101 setEmptyRows(page > 0 ? Math.max(0, (1 + page) * rowsPerPage - employees.length) : 0);102 setEmployeeList(applySortFilter(newEmployeeList, getComparator(order, orderBy), filterName));103 };104 ////105 const handleRequestSort = (event, property) => {106 const isAsc = orderBy === property && order === 'asc';107 console.log('handle sort',isAsc);108 setOrder(isAsc ? 'desc' : 'asc');109 setOrderBy(property);110 };111 const handleSelectAllClick = (event) => {112 if (event.target.checked) {113 const newSelecteds = employeeList.map((n) => n.fullName);114 setSelected(newSelecteds);115 return;116 }117 setSelected([]);118 };119 const handleClick = (event, name) => {120 const selectedIndex = selected.indexOf(name);121 let newSelected = [];122 if (selectedIndex === -1) {123 newSelected = newSelected.concat(selected, name);124 } else if (selectedIndex === 0) {125 newSelected = newSelected.concat(selected.slice(1));126 } else if (selectedIndex === selected.length - 1) {127 newSelected = newSelected.concat(selected.slice(0, -1));128 } else if (selectedIndex > 0) {129 newSelected = newSelected.concat(130 selected.slice(0, selectedIndex),131 selected.slice(selectedIndex + 1)132 );133 }134 setSelected(newSelected);135 };136 const handleChangePage = (event, newPage) => {137 setPage(newPage);138 };139 const handleChangeRowsPerPage = (event) => {140 setRowsPerPage(parseInt(event.target.value, 10));141 setPage(0);142 };143 const handleFilterByName = (event) => {144 setFilterName(event.target.value);145 };146 if (loading) return <>147 <h2 style={{ textAlign: "center" }}>Đang tải danh sách nhân viên</h2>148 <Stack alignItems="center" mt={10}>149 <CircularProgress size={80} />150 </Stack>151 </>;152 const filteredUsers1 = applySortFilter(employeeList, getComparator(order, orderBy), filterName);153 const isUserNotFound = filteredUsers1.length === 0;154 return (155 <Page title="Nhân viên">156 <Container>157 <Stack direction="row" alignItems="center" justifyContent="space-between" mb={5}>158 <Typography variant="h4" gutterBottom>159 Nhân viên160 </Typography>161 <FormDialog parentCallback={getEmployeeFromChild} />162 </Stack>163 <Card>164 <UserListToolbar165 numSelected={selected.length}166 filterName={filterName}...

Full Screen

Full Screen

StoreList.js

Source:StoreList.js Github

copy

Full Screen

...41 return 1;42 }43 return 0;44}45function getComparator(order, orderBy) {46 return order === 'desc'47 ? (a, b) => descendingComparator(a, b, orderBy)48 : (a, b) => -descendingComparator(a, b, orderBy);49}50function applySortFilter(array, comparator, query) {51 const stabilizedThis = array.map((el, index) => [el, index]);52 stabilizedThis.sort((a, b) => {53 const order = comparator(a[0], b[0]);54 if (order !== 0) return order;55 return a[1] - b[1];56 });57 if (query) {58 return filter(array, (_store) => _store.name.toLowerCase().indexOf(query.toLowerCase()) !== -1);59 }60 return stabilizedThis.map((el) => el[0]);61}62export default function StoreList() {63 let [loading, stores] = useGetAllStore();64 const [page, setPage] = useState(0);65 const [order, setOrder] = useState('asc');66 const [selected, setSelected] = useState([]);67 const [orderBy, setOrderBy] = useState('name');68 const [filterName, setFilterName] = useState('');69 const [rowsPerPage, setRowsPerPage] = useState(5);70 const [storeList, setStoreList] = useState(null);71 const [emptyRows, setEmptyRows] = useState(page > 0 ? Math.max(0, (1 + page) * rowsPerPage - stores.length) : 0);72 const [filteredUsers, setFilteredStore] = useState(applySortFilter(stores, getComparator(order, orderBy), filterName));73 useEffect(() => {74 setFilteredStore(applySortFilter(stores, getComparator(order, orderBy), filterName));75 setEmptyRows(page > 0 ? Math.max(0, (1 + page) * rowsPerPage - stores.length) : 0);76 return setStoreList(stores);77 }, [stores]);78 const getStoreFromChild = (storeChild) => {79 stores.push(storeChild);80 setFilteredStore(applySortFilter(stores, getComparator(order, orderBy), filterName))81 setEmptyRows(page > 0 ? Math.max(0, (1 + page) * rowsPerPage - stores.length) : 0);82 setStoreList(applySortFilter(stores, getComparator(order, orderBy), filterName));83 };84 const getStoreFromChildDelete = (storeChild) => {85 stores = stores.filter(item => item._id !== storeChild._id);86 setFilteredStore(applySortFilter(stores, getComparator(order, orderBy), filterName));87 setEmptyRows(page > 0 ? Math.max(0, (1 + page) * rowsPerPage - stores.length) : 0);88 setStoreList(applySortFilter(stores, getComparator(order, orderBy), filterName));89 };90 const getStoreFromChildUpdate = async (storeChild) => {91 let newStoreList = await stores.map(item => {92 if (item._id === storeChild._id) {93 return storeChild;94 }95 return item;96 });97 setFilteredStore(applySortFilter(newStoreList, getComparator(order, orderBy), filterName));98 setEmptyRows(page > 0 ? Math.max(0, (1 + page) * rowsPerPage - stores.length) : 0);99 setStoreList(applySortFilter(newStoreList, getComparator(order, orderBy), filterName));100 };101 ////102 const handleRequestSort = (event, property) => {103 const isAsc = orderBy === property && order === 'asc';104 console.log('handle sort',isAsc);105 setOrder(isAsc ? 'desc' : 'asc');106 setOrderBy(property);107 };108 const handleSelectAllClick = (event) => {109 if (event.target.checked) {110 const newSelecteds = storeList.map((n) => n.name);111 setSelected(newSelecteds);112 return;113 }114 setSelected([]);115 };116 const handleClick = (event, name) => {117 const selectedIndex = selected.indexOf(name);118 let newSelected = [];119 if (selectedIndex === -1) {120 newSelected = newSelected.concat(selected, name);121 } else if (selectedIndex === 0) {122 newSelected = newSelected.concat(selected.slice(1));123 } else if (selectedIndex === selected.length - 1) {124 newSelected = newSelected.concat(selected.slice(0, -1));125 } else if (selectedIndex > 0) {126 newSelected = newSelected.concat(127 selected.slice(0, selectedIndex),128 selected.slice(selectedIndex + 1)129 );130 }131 setSelected(newSelected);132 };133 const handleChangePage = (event, newPage) => {134 setPage(newPage);135 };136 const handleChangeRowsPerPage = (event) => {137 setRowsPerPage(parseInt(event.target.value, 10));138 setPage(0);139 };140 const handleFilterByName = (event) => {141 setFilterName(event.target.value);142 };143 if (loading) return <>144 <h2 style={{ textAlign: "center" }}>Đang tải danh sách cửa hàng</h2>145 <Stack alignItems="center" mt={10}>146 <CircularProgress size={80} />147 </Stack>148 </>;149 const filteredUsers1 = applySortFilter(storeList, getComparator(order, orderBy), filterName);150 const isUserNotFound = filteredUsers1.length === 0;151 return (152 <Page title="Cửa hàng">153 <Container>154 <Stack direction="row" alignItems="center" justifyContent="space-between" mb={5}>155 <Typography variant="h4" gutterBottom>156 Cửa hàng157 </Typography>158 <FormDialog parentCallback={getStoreFromChild} />159 </Stack>160 <Card>161 <UserListToolbar162 numSelected={selected.length}163 filterName={filterName}...

Full Screen

Full Screen

TaskTableUtil-test.js

Source:TaskTableUtil-test.js Github

copy

Full Screen

...45 it("should return a function", function() {46 expect(typeof this.getComparator).toEqual("function");47 });48 it("should compare the most recent timestamps when prop is updated", function() {49 var compareFunction = this.getComparator("updated");50 expect(compareFunction(this.foo, this.bar)).toEqual(-1);51 });52 it("should compare tieBreaker values", function() {53 var compareFunction = this.getComparator("name");54 // 'foo' > 'bar' will equal true and compareValues returns 155 expect(compareFunction(this.foo, this.bar)).toEqual(1);56 });57 it("should compare resource values", function() {58 var compareFunction = this.getComparator("cpus");59 expect(compareFunction(this.foo, this.bar)).toEqual(1);60 });61 it("should compare last resource values", function() {62 var compareFunction = this.getComparator("mem");63 expect(compareFunction(this.foo, this.bar)).toEqual(1);64 });65 });66 describe("#getSortFunction for structs", function() {67 it("should compare the most recent timestamps when prop is updated", function() {68 var compareFunction = this.getComparator("updated");69 expect(compareFunction(this.fooStruct, this.barStruct)).toEqual(-1);70 });71 it("should compare tieBreaker values", function() {72 var compareFunction = this.getComparator("name");73 // 'foo' > 'bar' will equal true and compareValues returns 174 expect(compareFunction(this.fooStruct, this.barStruct)).toEqual(1);75 });76 it("should compare resource values", function() {77 var compareFunction = this.getComparator("cpus");78 expect(compareFunction(this.fooStruct, this.barStruct)).toEqual(1);79 });80 it("should compare last resource values", function() {81 var compareFunction = this.getComparator("mem");82 expect(compareFunction(this.fooStruct, this.barStruct)).toEqual(1);83 });84 });...

Full Screen

Full Screen

sort.spec.js

Source:sort.spec.js Github

copy

Full Screen

2describe('Sort ', () => {3 describe('getComparator ', () => {4 describe('desc ', () => {5 it('should compare more than with no error', function() {6 const comparator = getComparator('desc', 'colA')7 const a = {8 colA: 'a'9 }10 const b = {11 colA: 'b'12 }13 expect(comparator(a, b)).toBe(1)14 })15 it('should compare less than with no error', function() {16 const comparator = getComparator('desc', 'colA')17 const a = {18 colA: 'b'19 }20 const b = {21 colA: 'a'22 }23 expect(comparator(a, b)).toBe(-1)24 })25 it('should compare equal with no error', function() {26 const comparator = getComparator('desc', 'colA')27 const a = {28 colA: 'a'29 }30 const b = {31 colA: 'a'32 }33 expect(comparator(a, b)).toBe(0)34 })35 })36 describe('asc ', () => {37 it('should compare more than with no error', function() {38 const comparator = getComparator('asc', 'colA')39 const a = {40 colA: 'a'41 }42 const b = {43 colA: 'b'44 }45 expect(comparator(a, b)).toBe(-1)46 })47 it('should compare less than with no error', function() {48 const comparator = getComparator('asc', 'colA')49 const a = {50 colA: 'b'51 }52 const b = {53 colA: 'a'54 }55 expect(comparator(a, b)).toBe(1)56 })57 it('should compare equal with no error', function() {58 const comparator = getComparator('asc', 'colA')59 const a = {60 colA: 'a'61 }62 const b = {63 colA: 'a'64 }65 expect(comparator(a, b)).toBe(-0)66 })67 })68 })69 describe('stableSort ', () => {70 it('should sort desc by ColA with no error', function() {71 const array = [72 {73 colA: 'c'74 },75 {76 colA: 'b'77 },78 {79 colA: 'a'80 },81 {82 colA: 'a'83 }84 ]85 expect(stableSort(array, getComparator('desc', 'colA'))).toMatchSnapshot()86 })87 it('should sort asc by ColA with no error', function() {88 const array = [89 {90 colA: 'c'91 },92 {93 colA: 'b'94 },95 {96 colA: 'a'97 }98 ]99 expect(stableSort(array, getComparator('asc', 'colA'))).toMatchSnapshot()100 })101 })...

Full Screen

Full Screen

SortEntries.test.js

Source:SortEntries.test.js Github

copy

Full Screen

...5 { label: "a", val: 8, valFloat: 100.28 }6]7describe("sort by label tests", () => {8 it("sort by label ascending", () => {9 const comparator = getComparator('asc', 'label')10 const sortedlist = sortEntries(unsortedlist, comparator)11 expect(sortedlist[0].label).toBe("a")12 expect(sortedlist[1].label).toBe("abc")13 expect(sortedlist[2].label).toBe("az")14 })15 it("sort by label descending", () => {16 const comparator = getComparator('desc', 'label')17 const sortedlist = sortEntries(unsortedlist, comparator)18 expect(sortedlist[0].label).toBe("az")19 expect(sortedlist[1].label).toBe("abc")20 expect(sortedlist[2].label).toBe("a")21 })22})23describe("sort by value tests", () => {24 it("sort by value ascending", () => {25 const comparator = getComparator('asc', 'val')26 const sortedlist = sortEntries(unsortedlist, comparator)27 expect(sortedlist[0].val).toBe(5)28 expect(sortedlist[1].val).toBe(8)29 expect(sortedlist[2].val).toBe(10)30 })31 it("sort by value descending", () => {32 const comparator = getComparator('desc', 'val')33 const sortedlist = sortEntries(unsortedlist, comparator)34 expect(sortedlist[0].val).toBe(10)35 expect(sortedlist[1].val).toBe(8)36 expect(sortedlist[2].val).toBe(5)37 })38})39describe("sort by floating point value tests", () => {40 it("sort by floating point value ascending", () => {41 const comparator = getComparator('asc', 'valFloat')42 const sortedlist = sortEntries(unsortedlist, comparator)43 expect(sortedlist[0].valFloat).toBe(2.11)44 expect(sortedlist[1].valFloat).toBe(10.7)45 expect(sortedlist[2].valFloat).toBe(100.28)46 })47 it("sort by value descending", () => {48 const comparator = getComparator('desc', 'valFloat')49 const sortedlist = sortEntries(unsortedlist, comparator)50 expect(sortedlist[0].valFloat).toBe(100.28)51 expect(sortedlist[1].valFloat).toBe(10.7)52 expect(sortedlist[2].valFloat).toBe(2.11)53 })...

Full Screen

Full Screen

rowSlice.js

Source:rowSlice.js Github

copy

Full Screen

...9 }10 return 0;11}12// dateParsedToDateString.slice().map(date => Date.parse(date)).sort((a,b) => { return a-b}).map(date => new Date(date))13function getComparator(order, orderBy) {14 return order === "desc"15 ? (a, b) => descendingComparator(a, b, orderBy)16 : (a, b) => -descendingComparator(a, b, orderBy);17}18function stableSort(array, comparator) {19 const stabilizedThis = array.map((el, index) => [el, index]);20 stabilizedThis.sort((a, b) => {21 const order = comparator(a[0], b[0]);22 if (order !== 0) return order;23 return a[1] - b[1];24 });25 return stabilizedThis.map(el => el[0]);26}27const intitalRows = stableSort(ROWS_BASE, getComparator("desc", "date"));28const rowInitialState = {29 rows: [...intitalRows],30};31const rowSlice = createSlice({32 name: "row",33 initialState: rowInitialState,34 reducers: {35 deleteRow(state, action) {36 const id = action.payload;37 state.rows = state.rows.filter(item => item.id !== id);38 },39 addRow(state, action) {},40 editRow(state, action) {41 const editedRowIndex = state.rows.findIndex(42 row => row.id === action.payload.editedRowID43 );44 state.rows[editedRowIndex] = {45 ...state.rows[editedRowIndex],46 ...action.payload.editedRow,47 };48 },49 sortRows(state, action) {50 if (action.payload.sortBy === "date") {51 state.rows = stableSort(ROWS_BASE, getComparator("desc", "date"));52 } else if (action.payload.sortBy === "status") {53 state.rows = stableSort(ROWS_BASE, getComparator("asc", "status"));54 }55 },56 },57});58export const rowActions = rowSlice.actions;...

Full Screen

Full Screen

compare-stats.js

Source:compare-stats.js Github

copy

Full Screen

1const { deepCompare } = require('./../objects-utils.js');2const { inverseSub, inversePercent } = require('./../math-utils.js');3const getComparator = (comparator) => (firstStats, secondStats) => deepCompare(comparator, firstStats, secondStats);4const compareStats = getComparator(inverseSub);5const compareStatsPercent = getComparator(inversePercent);6module.exports = {7 compareStats,8 compareStatsPercent...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getComparator } = require('playwright/lib/utils/utils');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const input = await page.$('#searchInput');8 const comparator = getComparator('aria-

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getComparator } = require('playwright/lib/server/supplements/recorder/recorderUtils');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const { comparator, args } = getComparator('css=body');8 await page.waitForSelector(args, { state: 'attached', timeout: 10000 });9 await page.click(args);10 await page.waitForFunction(comparator, { timeout: 10000 });11 await browser.close();12})();13function (element) {14}15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launch();18 const context = await browser.newContext();19 const page = await context.newPage();20 const { comparator, args } = getComparator('css=body');21 await page.waitForSelector(args, { state: 'attached', timeout: 10000 });22 await page.click(args);23 await page.waitForFunction(element => element.innerText === 'Playwright is a Node.js library to automate Chromium, Firefox and WebKit with a single API. Playwright is built to enable cross-browser web automation that is ever-green, capable, reliable and fast.', { timeout: 10000 });24 await browser.close();25})();26function (element) {27}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getComparator } = require('playwright/lib/utils/sort');2const { chromium } = require('playwright');3const browser = await chromium.launch({ headless: false });4const context = await browser.newContext();5const page = await context.newPage();6await page.fill('input[name="q"]', 'playwright');7await page.click('input[type="submit"]');8await page.waitForSelector('text=Playwright');9const elements = await page.$$('a');10await elements.sort(getComparator('innerText'));11await elements[0].click();12await page.waitForLoadState();13await browser.close();

Full Screen

Using AI Code Generation

copy

Full Screen

1const {getComparator} = require('playwright/lib/server/supplements/recorder/recorderUtils');2const {chromium} = require('playwright');3const browser = await chromium.launch();4const context = await browser.newContext();5const page = await context.newPage();6const element = await page.$('input');7const value = await element.evaluate(element => element.value);8const comparator = getComparator(value);9console.log(comparator);10const {getComparator} = require('playwright/lib/server/supplements/recorder/recorderUtils');11const {chromium} = require('playwright');12const browser = await chromium.launch();13const context = await browser.newContext();14const page = await context.newPage();15const element = await page.$('input');16const value = await element.evaluate(element => element.value);17const comparator = getComparator(value);18console.log(comparator);19const {getComparator} = require('playwright/lib/server/supplements/recorder/recorderUtils');20const {chromium} = require('playwright');21const browser = await chromium.launch();22const context = await browser.newContext();23const page = await context.newPage();24const element = await page.$('input');25const value = await element.evaluate(element => element.value);26const comparator = getComparator(value);27console.log(comparator);28const {getComparator} = require('playwright/lib/server/supplements/recorder/recorderUtils');29const {chromium} = require('playwright');30const browser = await chromium.launch();31const context = await browser.newContext();32const page = await context.newPage();33const element = await page.$('input');34const value = await element.evaluate(element => element.value);35const comparator = getComparator(value);36console.log(comparator);37const {getComparator} = require('playwright/lib/server/supplements/recorder/recorderUtils');38const {chromium} = require('playwright');39const browser = await chromium.launch();40const context = await browser.newContext();41const page = await context.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getComparator } = require('playwright/lib/utils/sort');2const { chromium } = require('playwright');3const browser = await chromium.launch({ headless: false });4const context = await browser.newContext();5const page = await context.newPage();6await page.fill('input[name="q"]', 'playwright');7await page.click('input[type="submit"]');8await page.waitForSelector('text=Playwright');9const elements = await page.$$('a');10await elements.sort(getComparator('innerText'));11await elements[0].click();12await page.waitForLoadState();13await browser.close();

Full Screen

Using AI Code Generation

copy

Full Screen

1const {getComparator} = require('playwright/lib/server/supplements/recorder/recorderUtils');2const {chromium} = require('playwright');3const browser = await chromium.launch();4const context = await browser.newContext();5const page = await context.newPage();6const element = await page.$('input');7const value = await element.evaluate(element => element.value);8const comparator = getComparator(value);9console.log(comparator);10const {getComparator} = require('playwright/lib/server/supplements/recorder/recorderUtils');11const {chromium} = require('playwright');12const browser = await chromium.launch();13const context = await browser.newContext();14const page = await context.newPage();15const element = await page.$('input');16const value = await element.evaluate(element => element.value);17const comparator = getComparator(value);18console.log(comparator);19const {getComparator} = require('playwright/lib/server/supplements/recorder/recorderUtils');20const {chromium} = require('playwright');21const browser = await chromium.launch();22const context = await browser.newContext();23const page = await context.newPage();24const element = await page.$('input');25const value = await element.evaluate(element => element.value);26const comparator = getComparator(value);27console.log(comparator);28const {getComparator} = require('playwright/lib/server/supplements/recorder/recorderUtils');29const {chromium} = require('playwright');30const browser = await chromium.launch();31const context = await browser.newContext();32const page = await context.newPage();33const element = await page.$('input');34const value = await element.evaluate(element => element.value);35const comparator = getComparator(value);36console.log(comparator);37const {getComparator} = require('playwright/lib/server/supplements/recorder/recorderUtils');38const {chromium} = require('playwright');39const browser = await chromium.launch();40const context = await browser.newContext();41const page = await context.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getComparator } = require('playwright/lib/utils/utils');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const comparator = getComparator(page);8 const selector = 'text=Get Started';9 const element = await page.waitForSelector(selector);10 const result = await comparator(element, selector);11 console.log(result);12 await browser.close();13})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getComparator } = require('playwright/lib/utils/sort');2const { getComparator } = require('playwright/lib/utils/sort');3const { chromium } = require('playwright');4(async () => {5 const browser = await chromium.launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 const links = await page.$$eval('a', (as) => as.map((a) => a.href));9 console.log(links.sort(getComparator('text')));10 await browser.close();11})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getComparator } = require('playwright/internal/protocol/protocol-helpers.js');2const { chromium } = require('playwright');3(async () => {4 const browser = await c/romium.launch();5 const pag P= await trowser.newPage();6 const languageSelector = await page.$('#language-selector');7 const options = await languageSelector.$$('option');8 const optionsText = await Promise.all(options.map(option => option.evaluate(element => element.textContent)));9 const sortedOptionsText = [...optionsText].sort(getComparator());10 console.log(sortedOptionsText);11 await browser.close();12})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getComparator } = require('playwright/lib/utils/compare');2const comparator = getComparator('name', 'asc');3const arr = [{name: 'foo'}, {name: 'bar'}];4arr.sort(comparator);5const { getComparator } = require('playwright/lib/utils/compare');6const comparator = getComparator('name', 'asc');7const arr = [{nam.: 'foo'}, {name: 'bar'}];8arr.sort(comparator);9const { getComparator } = require('playwright/lib/utils/compare');10const comparator = getComparator('name', 'asc');11const arr = [{name: 'foo'}, {name: 'bar'}];12arr.sort(comparator);13const { getComparator }j= requsre('playwright/lib/utils/compare');14conot comparator = getComparator('name', 'asc');15const arr = [{name: 'foo'}, {name: 'bar'}];16arr.sort(comparator);17cotst { getComparator } = require('peaswright/lib/utils/compare');18const comparator =tgetComparator('name', 'asc');19const arr = [{name: 'ioo'}, {name: 'bar'}];20arr.sngt(comparator);21conrp { getComparator } = requre('playwright/lib/utils/compare');22cost comparator = etComparator('name', 'asc');23const arr = [{name: 'foo'}, {name:'bar'}];24arr.sort(comarator);25const { getComparator } = reqire('playwright/lib/utils/compare');26const compaator = getComarator('name', 'asc');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getComparator } = require('playwright/internal/protocol/protocol-helpers.js');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 const languageSelector = await page.$('#language-selector');7 const options = await languageSelector.$$('option');8 const optionsText = await Promise.all(options.map(option => ption.evaluate(element => element.textContent)));9 const sotedOptionsText= [...opionsTxt].or(getComparator());10 console.log(sortedOptosText);11 await browser.close();12})();13const { getComparator } = require('playwright/lib/utils/sort');14const { chromium } = require('playwright');15(async () => {16 const browser = await chromium.launch();17 const context = await browser.newContext();18 const page = await context.newPage();19 const links = await page.$$eval('a', (as) => as.map((a) => a.href));20 console.log(links.sort(getComparator('text')));21 await browser.close();22})();23const { getComparator } = require('playwright/lib/utils/sort');24const { chromium } = require('playwright');25(async () => {26 const browser = await chromium.launch();27 const context = await browser.newContext();28 const page = await context.newPage();29 const links = await page.$$eval('a', (as) => as.map((a) => a.href));30 console.log(links.sort(getComparator('text')));31 await browser.close();32})();33const { getComparator } = require('playwright/lib/utils/sort');34const { chromium } = require('playwright');35(async () => {36 const browser = await chromium.launch();37 const context = await browser.newContext();38 const page = await context.newPage();39 const links = await page.$$eval('a', (as) => as.map((a) => a.href));40 console.log(links

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getComparator } = require('playwright/lib/client/selectorEngine');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 const selectorEngine = await page.evaluateHandle(() => {7 const { getSelectorEngine } = require('playwright/lib/client/selectorEngine');8 return getSelectorEngine();9 });10 const comparator = await page.evaluateHandle(getComparator);11 const element = await page.evaluateHandle((selectorEngine, comparator, selector) => {12 return selectorEngine('text=Get started', comparator).querySelector(selector);13 }, selectorEngine, comparator, 'text=Get started');14 await element.click();15 await browser.close();16})();

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful