Permalink
Browse files

remove &/path

  • Loading branch information...
1 parent 9ef8193 commit 7d5ad09d72a876e6b26703e499d74758ab27f692 @eldargab committed Sep 9, 2012
Showing with 34 additions and 36 deletions.
  1. +2 −2 lib/app.js
  2. +2 −3 lib/util.js
  3. +25 −24 test/app.js
  4. +5 −7 test/path-resolve.js
View
@@ -103,7 +103,7 @@ App.prototype.isReady = function (path) {
App.prototype.onerror = function (path, fn) {
if (typeof path == 'function') {
fn = path
- path = '&'
+ path = ''
}
this['_onerror_' + this._resolve(path)] = fn
return this
@@ -112,7 +112,7 @@ App.prototype.onerror = function (path, fn) {
App.prototype.raise = function (path, e) {
if (arguments.length == 1) {
e = path
- path = '&'
+ path = ''
}
var p = this._resolve(path)
var handler, parent = p, self = this
View
@@ -1,11 +1,10 @@
exports.resolvePath = function resolvePath (from, to) {
- if (to[0] != '.' && to[0] != '&') return to
+ if (to[0] != '.') return to
var path = from.split('/')
var segs = to.split('/')
- if (to[0] != '&') path.pop()
segs.forEach(function (seg, index) {
- if (seg == '.' || seg == '&') return
+ if (seg == '.') return
if (seg == '..') {
path.pop()
return
View
@@ -72,22 +72,21 @@ describe('App', function () {
app.def('a/b/c', function (get) {
get('a/b').should.equal('a/b')
- get('./d').should.equal('a/b/d')
- get('&/d').should.equal('a/b/c/d')
- get('../x/./y').should.equal('a/x/y')
+ get('./d').should.equal('a/b/c/d')
+ get('../../x/./y').should.equal('a/x/y')
done()
}).eval('a/b/c')
})
it('Evaluates all box dependencies before evaluating box itself', function () {
- var a, xxb, xc
+ var a, xb, xc
- app.def('a', ['x/x/b', 'x/c'], function (_, done) {
+ app.def('a', ['x/b', 'x/c'], function (_, done) {
log('a')
a = done
- }).def('x/x/b', ['../c'], function (_, done) {
- log('xxb')
- xxb = done
+ }).def('x/b', ['../c'], function (_, done) {
+ log('xb')
+ xb = done
}).def('x/c', function (_, done) {
log('xc')
xc = done
@@ -97,11 +96,11 @@ describe('App', function () {
log.should.equal('xc')
xc()
- log.should.equal('xc xxb')
- xxb()
- log.should.equal('xc xxb a')
+ log.should.equal('xc xb')
+ xb()
+ log.should.equal('xc xb a')
a()
- log.should.equal('xc xxb a done')
+ log.should.equal('xc xb a done')
})
})
@@ -165,21 +164,21 @@ describe('App', function () {
var proxy = app.prefix('root')
app.set('root/foo', 'foo')
- proxy.get('&/foo').should.equal('foo')
+ proxy.get('./foo').should.equal('foo')
- proxy.set('&/baz', 'baz')
+ proxy.set('./baz', 'baz')
app.get('root/baz').should.equal('baz')
app.set('hi', 'hi')
proxy.get('hi').should.equal('hi')
- proxy.isReady('./hi').should.be.true
+ proxy.isReady('../hi').should.be.true
- proxy.def('&/hello', function (get) {
- return get('&/world') + ' ' + get('./people')
+ proxy.def('./hello', function (get) {
+ return get('./world') + ' ' + get('../people')
})
app.set('root/hello/world', 'world')
- proxy.set('&/people', 'people')
- proxy.eval('&/hello')
+ proxy.set('./people', 'people')
+ proxy.eval('./hello')
app.get('root/hello').should.equal('world people')
})
})
@@ -287,12 +286,14 @@ describe('App', function () {
})
app.onerror('foo', function (err) {
- this.get('&/bar').should.equal('bar')
+ this.get('./bar').should.equal('bar')
+ log('onerror')
throw err
})
app.onerror(function () {
this.should.equal(app)
+ log.should.equal('onerror')
done()
})
@@ -359,8 +360,8 @@ describe('App', function () {
log('foo')
}).before('foo', function (get) {
log('before-foo')
- get('&/bar').should.equal('bar')
- this.get('&/bar').should.equal('bar')
+ get('./bar').should.equal('bar')
+ this.get('./bar').should.equal('bar')
}).eval('foo')
log.should.equal('foo/bar before-foo foo')
@@ -430,8 +431,8 @@ describe('App', function () {
return 'bar'
}).def('foo/baz', function () {
log('foo/baz')
- }).after('foo/baz', ['./bar'], function () {
- this.get('./bar').should.equal('bar')
+ }).after('foo/baz', ['../bar'], function () {
+ this.get('../bar').should.equal('bar')
log('after:foo/baz')
}).eval('foo/baz')
View
@@ -1,13 +1,11 @@
var resolve = require('../lib/util').resolvePath
describe('util.pathResolve(from, to)', function () {
- test('a/b/c', 'd/f', 'd/f')
- test('a/b/c', './f', 'a/b/f')
- test('a/b/c', '../g', 'a/g')
- test('a/b/c', '&/d', 'a/b/c/d')
- test('a/b', '&/c/./d', 'a/b/c/d')
- test('a', '&/b/../c', 'a/c')
- test('', '&/a', 'a')
+ test('a/b', 'c/d', 'c/d')
+ test('a/b', './c', 'a/b/c')
+ test('a/b', '../c', 'a/c')
+ test('a/b', './c/./d/..', 'a/b/c')
+ test('', '', '')
})
function test (from, to, res) {

0 comments on commit 7d5ad09

Please sign in to comment.