Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
put Path.isValid back
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelw committed Sep 3, 2013
1 parent 4190641 commit cf35308
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
5 changes: 5 additions & 0 deletions src/observe.js
Original file line number Diff line number Diff line change
Expand Up @@ -1309,4 +1309,9 @@
global.PathObserver = PathObserver;
global.CompoundPathObserver = CompoundPathObserver;
global.Path = Path;

global.Path.isValid = function(pathString) {
return Path.get(pathString) !== undefined;
};

})(typeof global !== 'undefined' && global ? global : this);
30 changes: 15 additions & 15 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,24 @@ suite('Path', function() {
});

test('valid paths', function() {
assert.isDefined(Path.get('a'));
assert.isDefined(Path.get('a.b'));
assert.isDefined(Path.get('a. b'));
assert.isDefined(Path.get('a .b'));
assert.isDefined(Path.get('a . b'));
assert.isDefined(Path.get(''));
assert.isDefined(Path.get(' '));
assert.isDefined(Path.get(null));
assert.isDefined(Path.get(undefined));
assert.isDefined(Path.get());
assert.isDefined(Path.get(42));
assert.isTrue(Path.isValid('a'));
assert.isTrue(Path.isValid('a.b'));
assert.isTrue(Path.isValid('a. b'));
assert.isTrue(Path.isValid('a .b'));
assert.isTrue(Path.isValid('a . b'));
assert.isTrue(Path.isValid(''));
assert.isTrue(Path.isValid(' '));
assert.isTrue(Path.isValid(null));
assert.isTrue(Path.isValid(undefined));
assert.isTrue(Path.isValid());
assert.isTrue(Path.isValid(42));
});

test('invalid paths', function() {
assert.isUndefined(Path.get('a b'));
assert.isUndefined(Path.get('.'));
assert.isUndefined(Path.get(' . '));
assert.isUndefined(Path.get('..'));
assert.isFalse(Path.isValid('a b'));
assert.isFalse(Path.isValid('.'));
assert.isFalse(Path.isValid(' . '));
assert.isFalse(Path.isValid('..'));
});

test('Paths are interned', function() {
Expand Down

0 comments on commit cf35308

Please sign in to comment.