Skip to content

Instantly share code, notes, and snippets.

@despairblue
Created December 22, 2014 03:39
Show Gist options
  • Save despairblue/2c826ff1a2a075e55d47 to your computer and use it in GitHub Desktop.
Save despairblue/2c826ff1a2a075e55d47 to your computer and use it in GitHub Desktop.
'use strict';
var c = require('rho-contracts')
var Mongoose = {
puts1: function(text) {
console.log(text)
}
}
var mongoose = Object.create(Mongoose)
mongoose.puts2 = function(text) {
console.log(text)
}
var run = function(mongoose) {
// both should fail
mongoose.puts1(1)
mongoose.puts2(2)
}
var runContract = c.fun({
mongoose: c.object({
puts1: c.fun({
text: c.string
}),
puts2: c.fun({
text: c.string
}),
})
})
run = runContract.wrap(run)
run(mongoose)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment