PageRenderTime 55ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/front/node_modules/vinyl-sourcemaps-apply/node_modules/source-map/test/source-map/test-util.js

https://gitlab.com/boxnia/NFU_MOVIL
JavaScript | 216 lines | 168 code | 41 blank | 7 comment | 1 complexity | 771372e4c09dcbf55a65c860d225b3d2 MD5 | raw file
  1. /* -*- Mode: js; js-indent-level: 2; -*- */
  2. /*
  3. * Copyright 2014 Mozilla Foundation and contributors
  4. * Licensed under the New BSD license. See LICENSE or:
  5. * http://opensource.org/licenses/BSD-3-Clause
  6. */
  7. if (typeof define !== 'function') {
  8. var define = require('amdefine')(module, require);
  9. }
  10. define(function (require, exports, module) {
  11. var libUtil = require('../../lib/source-map/util');
  12. exports['test urls'] = function (assert, util) {
  13. var assertUrl = function (url) {
  14. assert.equal(url, libUtil.urlGenerate(libUtil.urlParse(url)));
  15. };
  16. assertUrl('http://');
  17. assertUrl('http://www.example.com');
  18. assertUrl('http://user:pass@www.example.com');
  19. assertUrl('http://www.example.com:80');
  20. assertUrl('http://www.example.com/');
  21. assertUrl('http://www.example.com/foo/bar');
  22. assertUrl('http://www.example.com/foo/bar/');
  23. assertUrl('http://user:pass@www.example.com:80/foo/bar/');
  24. assertUrl('//');
  25. assertUrl('//www.example.com');
  26. assertUrl('file:///www.example.com');
  27. assert.equal(libUtil.urlParse(''), null);
  28. assert.equal(libUtil.urlParse('.'), null);
  29. assert.equal(libUtil.urlParse('..'), null);
  30. assert.equal(libUtil.urlParse('a'), null);
  31. assert.equal(libUtil.urlParse('a/b'), null);
  32. assert.equal(libUtil.urlParse('a//b'), null);
  33. assert.equal(libUtil.urlParse('/a'), null);
  34. assert.equal(libUtil.urlParse('data:foo,bar'), null);
  35. };
  36. exports['test normalize()'] = function (assert, util) {
  37. assert.equal(libUtil.normalize('/..'), '/');
  38. assert.equal(libUtil.normalize('/../'), '/');
  39. assert.equal(libUtil.normalize('/../../../..'), '/');
  40. assert.equal(libUtil.normalize('/../../../../a/b/c'), '/a/b/c');
  41. assert.equal(libUtil.normalize('/a/b/c/../../../d/../../e'), '/e');
  42. assert.equal(libUtil.normalize('..'), '..');
  43. assert.equal(libUtil.normalize('../'), '../');
  44. assert.equal(libUtil.normalize('../../a/'), '../../a/');
  45. assert.equal(libUtil.normalize('a/..'), '.');
  46. assert.equal(libUtil.normalize('a/../../..'), '../..');
  47. assert.equal(libUtil.normalize('/.'), '/');
  48. assert.equal(libUtil.normalize('/./'), '/');
  49. assert.equal(libUtil.normalize('/./././.'), '/');
  50. assert.equal(libUtil.normalize('/././././a/b/c'), '/a/b/c');
  51. assert.equal(libUtil.normalize('/a/b/c/./././d/././e'), '/a/b/c/d/e');
  52. assert.equal(libUtil.normalize(''), '.');
  53. assert.equal(libUtil.normalize('.'), '.');
  54. assert.equal(libUtil.normalize('./'), '.');
  55. assert.equal(libUtil.normalize('././a'), 'a');
  56. assert.equal(libUtil.normalize('a/./'), 'a/');
  57. assert.equal(libUtil.normalize('a/././.'), 'a');
  58. assert.equal(libUtil.normalize('/a/b//c////d/////'), '/a/b/c/d/');
  59. assert.equal(libUtil.normalize('///a/b//c////d/////'), '///a/b/c/d/');
  60. assert.equal(libUtil.normalize('a/b//c////d'), 'a/b/c/d');
  61. assert.equal(libUtil.normalize('.///.././../a/b//./..'), '../../a')
  62. assert.equal(libUtil.normalize('http://www.example.com'), 'http://www.example.com');
  63. assert.equal(libUtil.normalize('http://www.example.com/'), 'http://www.example.com/');
  64. assert.equal(libUtil.normalize('http://www.example.com/./..//a/b/c/.././d//'), 'http://www.example.com/a/b/d/');
  65. };
  66. exports['test join()'] = function (assert, util) {
  67. assert.equal(libUtil.join('a', 'b'), 'a/b');
  68. assert.equal(libUtil.join('a/', 'b'), 'a/b');
  69. assert.equal(libUtil.join('a//', 'b'), 'a/b');
  70. assert.equal(libUtil.join('a', 'b/'), 'a/b/');
  71. assert.equal(libUtil.join('a', 'b//'), 'a/b/');
  72. assert.equal(libUtil.join('a/', '/b'), '/b');
  73. assert.equal(libUtil.join('a//', '//b'), '//b');
  74. assert.equal(libUtil.join('a', '..'), '.');
  75. assert.equal(libUtil.join('a', '../b'), 'b');
  76. assert.equal(libUtil.join('a/b', '../c'), 'a/c');
  77. assert.equal(libUtil.join('a', '.'), 'a');
  78. assert.equal(libUtil.join('a', './b'), 'a/b');
  79. assert.equal(libUtil.join('a/b', './c'), 'a/b/c');
  80. assert.equal(libUtil.join('a', 'http://www.example.com'), 'http://www.example.com');
  81. assert.equal(libUtil.join('a', 'data:foo,bar'), 'data:foo,bar');
  82. assert.equal(libUtil.join('', 'b'), 'b');
  83. assert.equal(libUtil.join('.', 'b'), 'b');
  84. assert.equal(libUtil.join('', 'b/'), 'b/');
  85. assert.equal(libUtil.join('.', 'b/'), 'b/');
  86. assert.equal(libUtil.join('', 'b//'), 'b/');
  87. assert.equal(libUtil.join('.', 'b//'), 'b/');
  88. assert.equal(libUtil.join('', '..'), '..');
  89. assert.equal(libUtil.join('.', '..'), '..');
  90. assert.equal(libUtil.join('', '../b'), '../b');
  91. assert.equal(libUtil.join('.', '../b'), '../b');
  92. assert.equal(libUtil.join('', '.'), '.');
  93. assert.equal(libUtil.join('.', '.'), '.');
  94. assert.equal(libUtil.join('', './b'), 'b');
  95. assert.equal(libUtil.join('.', './b'), 'b');
  96. assert.equal(libUtil.join('', 'http://www.example.com'), 'http://www.example.com');
  97. assert.equal(libUtil.join('.', 'http://www.example.com'), 'http://www.example.com');
  98. assert.equal(libUtil.join('', 'data:foo,bar'), 'data:foo,bar');
  99. assert.equal(libUtil.join('.', 'data:foo,bar'), 'data:foo,bar');
  100. assert.equal(libUtil.join('..', 'b'), '../b');
  101. assert.equal(libUtil.join('..', 'b/'), '../b/');
  102. assert.equal(libUtil.join('..', 'b//'), '../b/');
  103. assert.equal(libUtil.join('..', '..'), '../..');
  104. assert.equal(libUtil.join('..', '../b'), '../../b');
  105. assert.equal(libUtil.join('..', '.'), '..');
  106. assert.equal(libUtil.join('..', './b'), '../b');
  107. assert.equal(libUtil.join('..', 'http://www.example.com'), 'http://www.example.com');
  108. assert.equal(libUtil.join('..', 'data:foo,bar'), 'data:foo,bar');
  109. assert.equal(libUtil.join('a', ''), 'a');
  110. assert.equal(libUtil.join('a', '.'), 'a');
  111. assert.equal(libUtil.join('a/', ''), 'a');
  112. assert.equal(libUtil.join('a/', '.'), 'a');
  113. assert.equal(libUtil.join('a//', ''), 'a');
  114. assert.equal(libUtil.join('a//', '.'), 'a');
  115. assert.equal(libUtil.join('/a', ''), '/a');
  116. assert.equal(libUtil.join('/a', '.'), '/a');
  117. assert.equal(libUtil.join('', ''), '.');
  118. assert.equal(libUtil.join('.', ''), '.');
  119. assert.equal(libUtil.join('.', ''), '.');
  120. assert.equal(libUtil.join('.', '.'), '.');
  121. assert.equal(libUtil.join('..', ''), '..');
  122. assert.equal(libUtil.join('..', '.'), '..');
  123. assert.equal(libUtil.join('http://foo.org/a', ''), 'http://foo.org/a');
  124. assert.equal(libUtil.join('http://foo.org/a', '.'), 'http://foo.org/a');
  125. assert.equal(libUtil.join('http://foo.org/a/', ''), 'http://foo.org/a');
  126. assert.equal(libUtil.join('http://foo.org/a/', '.'), 'http://foo.org/a');
  127. assert.equal(libUtil.join('http://foo.org/a//', ''), 'http://foo.org/a');
  128. assert.equal(libUtil.join('http://foo.org/a//', '.'), 'http://foo.org/a');
  129. assert.equal(libUtil.join('http://foo.org', ''), 'http://foo.org/');
  130. assert.equal(libUtil.join('http://foo.org', '.'), 'http://foo.org/');
  131. assert.equal(libUtil.join('http://foo.org/', ''), 'http://foo.org/');
  132. assert.equal(libUtil.join('http://foo.org/', '.'), 'http://foo.org/');
  133. assert.equal(libUtil.join('http://foo.org//', ''), 'http://foo.org/');
  134. assert.equal(libUtil.join('http://foo.org//', '.'), 'http://foo.org/');
  135. assert.equal(libUtil.join('//www.example.com', ''), '//www.example.com/');
  136. assert.equal(libUtil.join('//www.example.com', '.'), '//www.example.com/');
  137. assert.equal(libUtil.join('http://foo.org/a', 'b'), 'http://foo.org/a/b');
  138. assert.equal(libUtil.join('http://foo.org/a/', 'b'), 'http://foo.org/a/b');
  139. assert.equal(libUtil.join('http://foo.org/a//', 'b'), 'http://foo.org/a/b');
  140. assert.equal(libUtil.join('http://foo.org/a', 'b/'), 'http://foo.org/a/b/');
  141. assert.equal(libUtil.join('http://foo.org/a', 'b//'), 'http://foo.org/a/b/');
  142. assert.equal(libUtil.join('http://foo.org/a/', '/b'), 'http://foo.org/b');
  143. assert.equal(libUtil.join('http://foo.org/a//', '//b'), 'http://b');
  144. assert.equal(libUtil.join('http://foo.org/a', '..'), 'http://foo.org/');
  145. assert.equal(libUtil.join('http://foo.org/a', '../b'), 'http://foo.org/b');
  146. assert.equal(libUtil.join('http://foo.org/a/b', '../c'), 'http://foo.org/a/c');
  147. assert.equal(libUtil.join('http://foo.org/a', '.'), 'http://foo.org/a');
  148. assert.equal(libUtil.join('http://foo.org/a', './b'), 'http://foo.org/a/b');
  149. assert.equal(libUtil.join('http://foo.org/a/b', './c'), 'http://foo.org/a/b/c');
  150. assert.equal(libUtil.join('http://foo.org/a', 'http://www.example.com'), 'http://www.example.com');
  151. assert.equal(libUtil.join('http://foo.org/a', 'data:foo,bar'), 'data:foo,bar');
  152. assert.equal(libUtil.join('http://foo.org', 'a'), 'http://foo.org/a');
  153. assert.equal(libUtil.join('http://foo.org/', 'a'), 'http://foo.org/a');
  154. assert.equal(libUtil.join('http://foo.org//', 'a'), 'http://foo.org/a');
  155. assert.equal(libUtil.join('http://foo.org', '/a'), 'http://foo.org/a');
  156. assert.equal(libUtil.join('http://foo.org/', '/a'), 'http://foo.org/a');
  157. assert.equal(libUtil.join('http://foo.org//', '/a'), 'http://foo.org/a');
  158. assert.equal(libUtil.join('http://', 'www.example.com'), 'http://www.example.com');
  159. assert.equal(libUtil.join('file:///', 'www.example.com'), 'file:///www.example.com');
  160. assert.equal(libUtil.join('http://', 'ftp://example.com'), 'ftp://example.com');
  161. assert.equal(libUtil.join('http://www.example.com', '//foo.org/bar'), 'http://foo.org/bar');
  162. assert.equal(libUtil.join('//www.example.com', '//foo.org/bar'), '//foo.org/bar');
  163. };
  164. // TODO Issue #128: Define and test this function properly.
  165. exports['test relative()'] = function (assert, util) {
  166. assert.equal(libUtil.relative('/the/root', '/the/root/one.js'), 'one.js');
  167. assert.equal(libUtil.relative('/the/root', '/the/rootone.js'), '/the/rootone.js');
  168. assert.equal(libUtil.relative('', '/the/root/one.js'), '/the/root/one.js');
  169. assert.equal(libUtil.relative('.', '/the/root/one.js'), '/the/root/one.js');
  170. assert.equal(libUtil.relative('', 'the/root/one.js'), 'the/root/one.js');
  171. assert.equal(libUtil.relative('.', 'the/root/one.js'), 'the/root/one.js');
  172. assert.equal(libUtil.relative('/', '/the/root/one.js'), 'the/root/one.js');
  173. assert.equal(libUtil.relative('/', 'the/root/one.js'), 'the/root/one.js');
  174. };
  175. });