Sun calculation js library which is fully based on formula from http://aa.quae.nl/en/reken/zonpositie.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

50 lines
999 B

var assert = require('assert')
var bindObj = require('./bind-obj-methods.js')
var obj, m
function makeObj () {
var obj = {
method: function () { return this.foo },
foo: 'bar'
}
Object.defineProperty(obj, 'secretMethod', {
value: function () {
return 'secret' + this.method()
},
enumerable: false,
configurable: true,
writable: true
})
return obj
}
// pretend we already bound secretMethod
obj = makeObj()
bindObj(obj, obj, [ 'secretMethod', 'method' ])
m = obj.method
assert.equal(m(), undefined)
m = obj.secretMethod
assert.throws(m)
obj = makeObj()
bindObj(obj, obj, { secretMethod: true })
m = obj.method
assert.equal(m(), 'bar')
m = obj.secretMethod
assert.throws(m)
obj = makeObj()
bindObj(obj, obj)
m = obj.method
assert.equal(m(), 'bar')
m = obj.secretMethod
assert.equal(m(), 'secretbar')
obj = makeObj()
bindObj(obj, Object.prototype)
m = obj.hasOwnProperty
assert.equal(m('hasOwnProperty'), true)
console.log('TAP version 13\nok\n1..1')