diff options
author | max99x <max99x@gmail.com> | 2011-07-22 21:36:14 +0300 |
---|---|---|
committer | max99x <max99x@gmail.com> | 2011-07-22 23:31:57 +0300 |
commit | 5f9646ca267736036e87afc965e665539eed3578 (patch) | |
tree | 29f7928e8e37fc7a968434b8fad87d25ce2b5e8f /tests/filesystem | |
parent | 4f25c5b69954137557da89973f10d121cdb4a980 (diff) |
Added FS.analyzePath() which will simplify some library functions.
Diffstat (limited to 'tests/filesystem')
-rw-r--r-- | tests/filesystem/output.txt | 208 | ||||
-rw-r--r-- | tests/filesystem/src.js | 46 |
2 files changed, 254 insertions, 0 deletions
diff --git a/tests/filesystem/output.txt b/tests/filesystem/output.txt new file mode 100644 index 00000000..dd58133c --- /dev/null +++ b/tests/filesystem/output.txt @@ -0,0 +1,208 @@ + + isRoot: false + exists: true + error: 0 + path: /abc + name: abc + object.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +/ + isRoot: true + exists: true + error: 0 + path: / + name: / + object.contents: ["forbidden","abc","def"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +. + isRoot: false + exists: true + error: 0 + path: /abc + name: abc + object.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +.. + isRoot: true + exists: true + error: 0 + path: / + name: / + object.contents: ["forbidden","abc","def"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +../.. + isRoot: true + exists: true + error: 0 + path: / + name: / + object.contents: ["forbidden","abc","def"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +/abc + isRoot: false + exists: true + error: 0 + path: /abc + name: abc + object.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +/abc/123 + isRoot: false + exists: true + error: 0 + path: /abc/123 + name: 123 + object.contents: [] + parentExists: true + parentPath: /abc + parentObject.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + +/abc/noexist + isRoot: false + exists: false + error: 2 + path: null + name: noexist + object.contents: null + parentExists: true + parentPath: /abc + parentObject.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + +/abc/deviceA + isRoot: false + exists: true + error: 0 + path: /abc/deviceA + name: deviceA + object.contents: [] + parentExists: true + parentPath: /abc + parentObject.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + +/abc/localLink + isRoot: false + exists: true + error: 0 + path: /abc/123 + name: 123 + object.contents: [] + parentExists: true + parentPath: /abc + parentObject.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + +/abc/rootLink + isRoot: true + exists: true + error: 0 + path: / + name: / + object.contents: ["forbidden","abc","def"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +/abc/relativeLink + isRoot: false + exists: true + error: 0 + path: /def + name: def + object.contents: ["789","deviceB"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +/abc/relativeLink/deviceB + isRoot: false + exists: true + error: 0 + path: /def/deviceB + name: deviceB + object.contents: [] + parentExists: true + parentPath: /def + parentObject.contents: ["789","deviceB"] + +/abc/rootLink/noexist + isRoot: false + exists: false + error: 2 + path: null + name: noexist + object.contents: null + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +/abc/rootLink/abc/noexist + isRoot: false + exists: false + error: 2 + path: null + name: noexist + object.contents: null + parentExists: true + parentPath: /abc + parentObject.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + +/forbidden + isRoot: false + exists: true + error: 0 + path: /forbidden + name: forbidden + object.contents: ["test"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +/forbidden/test + isRoot: false + exists: false + error: 13 + path: null + name: test + object.contents: null + parentExists: true + parentPath: /forbidden + parentObject.contents: ["test"] + +/forbidden/noexist + isRoot: false + exists: false + error: 13 + path: null + name: noexist + object.contents: null + parentExists: true + parentPath: /forbidden + parentObject.contents: ["test"] + +/noexist1/noexist2 + isRoot: false + exists: false + error: 2 + path: null + name: null + object.contents: null + parentExists: false + parentPath: null + parentObject.contents: null diff --git a/tests/filesystem/src.js b/tests/filesystem/src.js new file mode 100644 index 00000000..5fdef564 --- /dev/null +++ b/tests/filesystem/src.js @@ -0,0 +1,46 @@ +FS.createFolder('/', 'forbidden', false, false); +FS.createFolder('/forbidden', 'test', true, true); +FS.createPath('/', 'abc/123', true, true); +FS.createPath('/', 'abc/456', true, true); +FS.createPath('/', 'def/789', true, true); +FS.createDevice('/abc', 'deviceA', function() {}, function() {}); +FS.createDevice('/def', 'deviceB', function() {}, function() {}); +FS.createLink('/abc', 'localLink', '123', true, true); +FS.createLink('/abc', 'rootLink', '/', true, true); +FS.createLink('/abc', 'relativeLink', '../def', true, true); + +function explore(path) { + print(path); + var ret = FS.analyzePath(path); + print(' isRoot: ' + ret.isRoot); + print(' exists: ' + ret.exists); + print(' error: ' + ret.error); + print(' path: ' + ret.path); + print(' name: ' + ret.name); + print(' object.contents: ' + (ret.object && JSON.stringify(Object.keys(ret.object.contents || {})))); + print(' parentExists: ' + ret.parentExists); + print(' parentPath: ' + ret.parentPath); + print(' parentObject.contents: ' + (ret.parentObject && JSON.stringify(Object.keys(ret.parentObject.contents)))); + print(''); +} + +FS.currentPath = '/abc'; +explore(''); +explore('/'); +explore('.'); +explore('..'); +explore('../..'); +explore('/abc'); +explore('/abc/123'); +explore('/abc/noexist'); +explore('/abc/deviceA'); +explore('/abc/localLink'); +explore('/abc/rootLink'); +explore('/abc/relativeLink'); +explore('/abc/relativeLink/deviceB'); +explore('/abc/rootLink/noexist'); +explore('/abc/rootLink/abc/noexist'); +explore('/forbidden'); +explore('/forbidden/test'); +explore('/forbidden/noexist'); +explore('/noexist1/noexist2'); |