Created
December 22, 2014 03:39
-
-
Save despairblue/2c826ff1a2a075e55d47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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