Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / @protobufjs / path / tests / index.js
1 var tape = require("tape");\r
2 \r
3 var path = require("..");\r
4 \r
5 tape.test("path", function(test) {\r
6 \r
7     test.ok(path.isAbsolute("X:\\some\\path\\file.js"), "should identify absolute windows paths");\r
8     test.ok(path.isAbsolute("/some/path/file.js"), "should identify absolute unix paths");\r
9 \r
10     test.notOk(path.isAbsolute("some\\path\\file.js"), "should identify relative windows paths");\r
11     test.notOk(path.isAbsolute("some/path/file.js"), "should identify relative unix paths");\r
12 \r
13     var paths = [\r
14         {\r
15             actual: "X:\\some\\..\\.\\path\\\\file.js",\r
16             normal: "X:/path/file.js",\r
17             resolve: {\r
18                 origin: "X:/path/origin.js",\r
19                 expected: "X:/path/file.js"\r
20             }\r
21         }, {\r
22             actual: "some\\..\\.\\path\\\\file.js",\r
23             normal: "path/file.js",\r
24             resolve: {\r
25                 origin: "X:/path/origin.js",\r
26                 expected: "X:/path/path/file.js"\r
27             }\r
28         }, {\r
29             actual: "/some/.././path//file.js",\r
30             normal: "/path/file.js",\r
31             resolve: {\r
32                 origin: "/path/origin.js",\r
33                 expected: "/path/file.js"\r
34             }\r
35         }, {\r
36             actual: "some/.././path//file.js",\r
37             normal: "path/file.js",\r
38             resolve: {\r
39                 origin: "",\r
40                 expected: "path/file.js"\r
41             }\r
42         }, {\r
43             actual: ".././path//file.js",\r
44             normal: "../path/file.js"\r
45         }, {\r
46             actual: "/.././path//file.js",\r
47             normal: "/path/file.js"\r
48         }\r
49     ];\r
50 \r
51     paths.forEach(function(p) {\r
52         test.equal(path.normalize(p.actual), p.normal, "should normalize " + p.actual);\r
53         if (p.resolve) {\r
54             test.equal(path.resolve(p.resolve.origin, p.actual), p.resolve.expected, "should resolve " + p.actual);\r
55             test.equal(path.resolve(p.resolve.origin, p.normal, true), p.resolve.expected, "should resolve " + p.normal + " (already normalized)");\r
56         }\r
57     });\r
58 \r
59     test.end();\r
60 });\r