Skip to content
Permalink
Browse files

Merge branch 'add_path_resolve_test' into dev

  • Loading branch information...
xicilion committed Jun 24, 2019
2 parents 750f23e + 83cc739 commit 15b9de451797d296882d311232e6bfb068573158
Showing with 16 additions and 2 deletions.
  1. +8 −1 fibjs/include/path.h
  2. +8 −1 test/path_test.js
@@ -565,7 +565,14 @@ inline result_t _resolve(OptArgs ps, exlib::string& retVal)
p.resolvePosix(s);
}

return _normalize(p.str(), retVal, true);
result_t hr = _normalize(p.str(), retVal, true);
if (hr < 0)
return hr;

if (retVal.empty())
retVal = "/";

return 0;
}

inline result_t _resolve(exlib::string& path)
@@ -843,6 +843,13 @@ describe('path', () => {
assert.strictEqual(failures.length, 0, failures.join(''));
});

it('root resolve', () => {
const cwd = process.cwd();
process.chdir('/');
assert.equal(path.resolve('a/b/c/', '../../..'), process.cwd());
process.chdir(cwd);
});

it('relative', () => {
const failures = [];
const slashRE = /\//g;
@@ -1080,4 +1087,4 @@ describe('path', () => {
});
});

require.main === module && test.run(console.DEBUG);
require.main === module && test.run(console.DEBUG);

0 comments on commit 15b9de4

Please sign in to comment.
You can’t perform that action at this time.