Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (c) 2009 Panagiotis Astithas |
michael@0 | 3 | * Permission to use, copy, modify, and distribute this software for any |
michael@0 | 4 | * purpose with or without fee is hereby granted, provided that the above |
michael@0 | 5 | * copyright notice and this permission notice appear in all copies. |
michael@0 | 6 | * |
michael@0 | 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
michael@0 | 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
michael@0 | 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
michael@0 | 10 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
michael@0 | 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
michael@0 | 12 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
michael@0 | 13 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
michael@0 | 14 | */ |
michael@0 | 15 | |
michael@0 | 16 | 'use strict'; |
michael@0 | 17 | // <INJECTED SOURCE:START> |
michael@0 | 18 | |
michael@0 | 19 | // THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT |
michael@0 | 20 | // DO NOT EDIT IT DIRECTLY |
michael@0 | 21 | |
michael@0 | 22 | var exports = {}; |
michael@0 | 23 | |
michael@0 | 24 | var TEST_URI = "data:text/html;charset=utf-8,<p id='gcli-input'>gcli-testSpell.js</p>"; |
michael@0 | 25 | |
michael@0 | 26 | function test() { |
michael@0 | 27 | return Task.spawn(function() { |
michael@0 | 28 | let options = yield helpers.openTab(TEST_URI); |
michael@0 | 29 | yield helpers.openToolbar(options); |
michael@0 | 30 | gcli.addItems(mockCommands.items); |
michael@0 | 31 | |
michael@0 | 32 | yield helpers.runTests(options, exports); |
michael@0 | 33 | |
michael@0 | 34 | gcli.removeItems(mockCommands.items); |
michael@0 | 35 | yield helpers.closeToolbar(options); |
michael@0 | 36 | yield helpers.closeTab(options); |
michael@0 | 37 | }).then(finish, helpers.handleError); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | // <INJECTED SOURCE:END> |
michael@0 | 41 | |
michael@0 | 42 | // var assert = require('../testharness/assert'); |
michael@0 | 43 | var spell = require('gcli/util/spell'); |
michael@0 | 44 | |
michael@0 | 45 | exports.testSpellerSimple = function(options) { |
michael@0 | 46 | var alternatives = [ |
michael@0 | 47 | 'window', 'document', 'InstallTrigger', 'requirejs', 'require','define', |
michael@0 | 48 | 'console', 'location', 'constructor', 'getInterface', 'external', 'sidebar' |
michael@0 | 49 | ]; |
michael@0 | 50 | |
michael@0 | 51 | assert.is(spell.correct('document', alternatives), 'document'); |
michael@0 | 52 | assert.is(spell.correct('documen', alternatives), 'document'); |
michael@0 | 53 | assert.is(spell.correct('ocument', alternatives), 'document'); |
michael@0 | 54 | assert.is(spell.correct('odcument', alternatives), 'document'); |
michael@0 | 55 | |
michael@0 | 56 | assert.is(spell.correct('=========', alternatives), undefined); |
michael@0 | 57 | }; |
michael@0 | 58 | |
michael@0 | 59 | exports.testRank = function(options) { |
michael@0 | 60 | var distances = spell.rank('fred', [ 'banana', 'fred', 'ed', 'red', 'FRED' ]); |
michael@0 | 61 | |
michael@0 | 62 | assert.is(distances.length, 5, 'rank length'); |
michael@0 | 63 | |
michael@0 | 64 | assert.is(distances[0].name, 'fred', 'fred name #0'); |
michael@0 | 65 | assert.is(distances[1].name, 'FRED', 'FRED name #1'); |
michael@0 | 66 | assert.is(distances[2].name, 'red', 'red name #2'); |
michael@0 | 67 | assert.is(distances[3].name, 'ed', 'ed name #3'); |
michael@0 | 68 | assert.is(distances[4].name, 'banana', 'banana name #4'); |
michael@0 | 69 | |
michael@0 | 70 | assert.is(distances[0].dist, 0, 'fred dist 0'); |
michael@0 | 71 | assert.is(distances[1].dist, 4, 'FRED dist 4'); |
michael@0 | 72 | assert.is(distances[2].dist, 10, 'red dist 10'); |
michael@0 | 73 | assert.is(distances[3].dist, 20, 'ed dist 20'); |
michael@0 | 74 | assert.is(distances[4].dist, 100, 'banana dist 100'); |
michael@0 | 75 | }; |
michael@0 | 76 | |
michael@0 | 77 | exports.testRank2 = function(options) { |
michael@0 | 78 | var distances = spell.rank('caps', [ 'CAPS', 'false' ]); |
michael@0 | 79 | assert.is(JSON.stringify(distances), |
michael@0 | 80 | '[{"name":"CAPS","dist":4},{"name":"false","dist":50}]', |
michael@0 | 81 | 'spell.rank("caps", [ "CAPS", "false" ]'); |
michael@0 | 82 | }; |
michael@0 | 83 | |
michael@0 | 84 | exports.testDistancePrefix = function(options) { |
michael@0 | 85 | assert.is(spell.distancePrefix('fred', 'freddy'), 0, 'distancePrefix fred'); |
michael@0 | 86 | assert.is(spell.distancePrefix('FRED', 'freddy'), 4, 'distancePrefix FRED'); |
michael@0 | 87 | }; |