react / wstein / node_modules / browserify / node_modules / browser-pack / node_modules / combine-source-map / node_modules / source-map / dist / test / test_util.js
80559 views/*1* WARNING!2*3* Do not edit this file directly, it is built from the sources at4* https://github.com/mozilla/source-map/5*/67Components.utils.import('resource://test/Utils.jsm');8/* -*- Mode: js; js-indent-level: 2; -*- */9/*10* Copyright 2014 Mozilla Foundation and contributors11* Licensed under the New BSD license. See LICENSE or:12* http://opensource.org/licenses/BSD-3-Clause13*/14define("test/source-map/test-util", ["require", "exports", "module"], function (require, exports, module) {1516var libUtil = require('source-map/util');1718exports['test urls'] = function (assert, util) {19var assertUrl = function (url) {20assert.equal(url, libUtil.urlGenerate(libUtil.urlParse(url)));21};22assertUrl('http://');23assertUrl('http://www.example.com');24assertUrl('http://user:[email protected]');25assertUrl('http://www.example.com:80');26assertUrl('http://www.example.com/');27assertUrl('http://www.example.com/foo/bar');28assertUrl('http://www.example.com/foo/bar/');29assertUrl('http://user:[email protected]:80/foo/bar/');3031assertUrl('//');32assertUrl('//www.example.com');33assertUrl('file:///www.example.com');3435assert.equal(libUtil.urlParse(''), null);36assert.equal(libUtil.urlParse('.'), null);37assert.equal(libUtil.urlParse('..'), null);38assert.equal(libUtil.urlParse('a'), null);39assert.equal(libUtil.urlParse('a/b'), null);40assert.equal(libUtil.urlParse('a//b'), null);41assert.equal(libUtil.urlParse('/a'), null);42assert.equal(libUtil.urlParse('data:foo,bar'), null);43};4445exports['test normalize()'] = function (assert, util) {46assert.equal(libUtil.normalize('/..'), '/');47assert.equal(libUtil.normalize('/../'), '/');48assert.equal(libUtil.normalize('/../../../..'), '/');49assert.equal(libUtil.normalize('/../../../../a/b/c'), '/a/b/c');50assert.equal(libUtil.normalize('/a/b/c/../../../d/../../e'), '/e');5152assert.equal(libUtil.normalize('..'), '..');53assert.equal(libUtil.normalize('../'), '../');54assert.equal(libUtil.normalize('../../a/'), '../../a/');55assert.equal(libUtil.normalize('a/..'), '.');56assert.equal(libUtil.normalize('a/../../..'), '../..');5758assert.equal(libUtil.normalize('/.'), '/');59assert.equal(libUtil.normalize('/./'), '/');60assert.equal(libUtil.normalize('/./././.'), '/');61assert.equal(libUtil.normalize('/././././a/b/c'), '/a/b/c');62assert.equal(libUtil.normalize('/a/b/c/./././d/././e'), '/a/b/c/d/e');6364assert.equal(libUtil.normalize(''), '.');65assert.equal(libUtil.normalize('.'), '.');66assert.equal(libUtil.normalize('./'), '.');67assert.equal(libUtil.normalize('././a'), 'a');68assert.equal(libUtil.normalize('a/./'), 'a/');69assert.equal(libUtil.normalize('a/././.'), 'a');7071assert.equal(libUtil.normalize('/a/b//c////d/////'), '/a/b/c/d/');72assert.equal(libUtil.normalize('///a/b//c////d/////'), '///a/b/c/d/');73assert.equal(libUtil.normalize('a/b//c////d'), 'a/b/c/d');7475assert.equal(libUtil.normalize('.///.././../a/b//./..'), '../../a')7677assert.equal(libUtil.normalize('http://www.example.com'), 'http://www.example.com');78assert.equal(libUtil.normalize('http://www.example.com/'), 'http://www.example.com/');79assert.equal(libUtil.normalize('http://www.example.com/./..//a/b/c/.././d//'), 'http://www.example.com/a/b/d/');80};8182exports['test join()'] = function (assert, util) {83assert.equal(libUtil.join('a', 'b'), 'a/b');84assert.equal(libUtil.join('a/', 'b'), 'a/b');85assert.equal(libUtil.join('a//', 'b'), 'a/b');86assert.equal(libUtil.join('a', 'b/'), 'a/b/');87assert.equal(libUtil.join('a', 'b//'), 'a/b/');88assert.equal(libUtil.join('a/', '/b'), '/b');89assert.equal(libUtil.join('a//', '//b'), '//b');9091assert.equal(libUtil.join('a', '..'), '.');92assert.equal(libUtil.join('a', '../b'), 'b');93assert.equal(libUtil.join('a/b', '../c'), 'a/c');9495assert.equal(libUtil.join('a', '.'), 'a');96assert.equal(libUtil.join('a', './b'), 'a/b');97assert.equal(libUtil.join('a/b', './c'), 'a/b/c');9899assert.equal(libUtil.join('a', 'http://www.example.com'), 'http://www.example.com');100assert.equal(libUtil.join('a', 'data:foo,bar'), 'data:foo,bar');101102103assert.equal(libUtil.join('', 'b'), 'b');104assert.equal(libUtil.join('.', 'b'), 'b');105assert.equal(libUtil.join('', 'b/'), 'b/');106assert.equal(libUtil.join('.', 'b/'), 'b/');107assert.equal(libUtil.join('', 'b//'), 'b/');108assert.equal(libUtil.join('.', 'b//'), 'b/');109110assert.equal(libUtil.join('', '..'), '..');111assert.equal(libUtil.join('.', '..'), '..');112assert.equal(libUtil.join('', '../b'), '../b');113assert.equal(libUtil.join('.', '../b'), '../b');114115assert.equal(libUtil.join('', '.'), '.');116assert.equal(libUtil.join('.', '.'), '.');117assert.equal(libUtil.join('', './b'), 'b');118assert.equal(libUtil.join('.', './b'), 'b');119120assert.equal(libUtil.join('', 'http://www.example.com'), 'http://www.example.com');121assert.equal(libUtil.join('.', 'http://www.example.com'), 'http://www.example.com');122assert.equal(libUtil.join('', 'data:foo,bar'), 'data:foo,bar');123assert.equal(libUtil.join('.', 'data:foo,bar'), 'data:foo,bar');124125126assert.equal(libUtil.join('..', 'b'), '../b');127assert.equal(libUtil.join('..', 'b/'), '../b/');128assert.equal(libUtil.join('..', 'b//'), '../b/');129130assert.equal(libUtil.join('..', '..'), '../..');131assert.equal(libUtil.join('..', '../b'), '../../b');132133assert.equal(libUtil.join('..', '.'), '..');134assert.equal(libUtil.join('..', './b'), '../b');135136assert.equal(libUtil.join('..', 'http://www.example.com'), 'http://www.example.com');137assert.equal(libUtil.join('..', 'data:foo,bar'), 'data:foo,bar');138139140assert.equal(libUtil.join('a', ''), 'a');141assert.equal(libUtil.join('a', '.'), 'a');142assert.equal(libUtil.join('a/', ''), 'a');143assert.equal(libUtil.join('a/', '.'), 'a');144assert.equal(libUtil.join('a//', ''), 'a');145assert.equal(libUtil.join('a//', '.'), 'a');146assert.equal(libUtil.join('/a', ''), '/a');147assert.equal(libUtil.join('/a', '.'), '/a');148assert.equal(libUtil.join('', ''), '.');149assert.equal(libUtil.join('.', ''), '.');150assert.equal(libUtil.join('.', ''), '.');151assert.equal(libUtil.join('.', '.'), '.');152assert.equal(libUtil.join('..', ''), '..');153assert.equal(libUtil.join('..', '.'), '..');154assert.equal(libUtil.join('http://foo.org/a', ''), 'http://foo.org/a');155assert.equal(libUtil.join('http://foo.org/a', '.'), 'http://foo.org/a');156assert.equal(libUtil.join('http://foo.org/a/', ''), 'http://foo.org/a');157assert.equal(libUtil.join('http://foo.org/a/', '.'), 'http://foo.org/a');158assert.equal(libUtil.join('http://foo.org/a//', ''), 'http://foo.org/a');159assert.equal(libUtil.join('http://foo.org/a//', '.'), 'http://foo.org/a');160assert.equal(libUtil.join('http://foo.org', ''), 'http://foo.org/');161assert.equal(libUtil.join('http://foo.org', '.'), 'http://foo.org/');162assert.equal(libUtil.join('http://foo.org/', ''), 'http://foo.org/');163assert.equal(libUtil.join('http://foo.org/', '.'), 'http://foo.org/');164assert.equal(libUtil.join('http://foo.org//', ''), 'http://foo.org/');165assert.equal(libUtil.join('http://foo.org//', '.'), 'http://foo.org/');166assert.equal(libUtil.join('//www.example.com', ''), '//www.example.com/');167assert.equal(libUtil.join('//www.example.com', '.'), '//www.example.com/');168169170assert.equal(libUtil.join('http://foo.org/a', 'b'), 'http://foo.org/a/b');171assert.equal(libUtil.join('http://foo.org/a/', 'b'), 'http://foo.org/a/b');172assert.equal(libUtil.join('http://foo.org/a//', 'b'), 'http://foo.org/a/b');173assert.equal(libUtil.join('http://foo.org/a', 'b/'), 'http://foo.org/a/b/');174assert.equal(libUtil.join('http://foo.org/a', 'b//'), 'http://foo.org/a/b/');175assert.equal(libUtil.join('http://foo.org/a/', '/b'), 'http://foo.org/b');176assert.equal(libUtil.join('http://foo.org/a//', '//b'), 'http://b');177178assert.equal(libUtil.join('http://foo.org/a', '..'), 'http://foo.org/');179assert.equal(libUtil.join('http://foo.org/a', '../b'), 'http://foo.org/b');180assert.equal(libUtil.join('http://foo.org/a/b', '../c'), 'http://foo.org/a/c');181182assert.equal(libUtil.join('http://foo.org/a', '.'), 'http://foo.org/a');183assert.equal(libUtil.join('http://foo.org/a', './b'), 'http://foo.org/a/b');184assert.equal(libUtil.join('http://foo.org/a/b', './c'), 'http://foo.org/a/b/c');185186assert.equal(libUtil.join('http://foo.org/a', 'http://www.example.com'), 'http://www.example.com');187assert.equal(libUtil.join('http://foo.org/a', 'data:foo,bar'), 'data:foo,bar');188189190assert.equal(libUtil.join('http://foo.org', 'a'), 'http://foo.org/a');191assert.equal(libUtil.join('http://foo.org/', 'a'), 'http://foo.org/a');192assert.equal(libUtil.join('http://foo.org//', 'a'), 'http://foo.org/a');193assert.equal(libUtil.join('http://foo.org', '/a'), 'http://foo.org/a');194assert.equal(libUtil.join('http://foo.org/', '/a'), 'http://foo.org/a');195assert.equal(libUtil.join('http://foo.org//', '/a'), 'http://foo.org/a');196197198assert.equal(libUtil.join('http://', 'www.example.com'), 'http://www.example.com');199assert.equal(libUtil.join('file:///', 'www.example.com'), 'file:///www.example.com');200assert.equal(libUtil.join('http://', 'ftp://example.com'), 'ftp://example.com');201202assert.equal(libUtil.join('http://www.example.com', '//foo.org/bar'), 'http://foo.org/bar');203assert.equal(libUtil.join('//www.example.com', '//foo.org/bar'), '//foo.org/bar');204};205206// TODO Issue #128: Define and test this function properly.207exports['test relative()'] = function (assert, util) {208assert.equal(libUtil.relative('/the/root', '/the/root/one.js'), 'one.js');209assert.equal(libUtil.relative('/the/root', '/the/rootone.js'), '/the/rootone.js');210211assert.equal(libUtil.relative('', '/the/root/one.js'), '/the/root/one.js');212assert.equal(libUtil.relative('.', '/the/root/one.js'), '/the/root/one.js');213assert.equal(libUtil.relative('', 'the/root/one.js'), 'the/root/one.js');214assert.equal(libUtil.relative('.', 'the/root/one.js'), 'the/root/one.js');215216assert.equal(libUtil.relative('/', '/the/root/one.js'), 'the/root/one.js');217assert.equal(libUtil.relative('/', 'the/root/one.js'), 'the/root/one.js');218};219220});221function run_test() {222runSourceMapTests('test/source-map/test-util', do_throw);223}224225226