Created
September 5, 2011 20:38
-
-
Save philmander/1195862 to your computer and use it in GitHub Desktop.
Javascript interfaces revisited 1
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
var Dog = [ | |
"bark", "eat", "defecate" | |
]; | |
var Poodle = function(name) { //implements Dog | |
this.name = name; | |
}; | |
Poodle.prototype = { | |
bark: function() {}, | |
eat: function() {}, | |
defecate: function() {} | |
}; | |
YUI().use("test", function(Y) { | |
var testCase = new Y.Test.Case({ | |
name: "Poodle Test", | |
testInterface: function() { | |
Y.Assert.isImplemented(Dog, Poodle.prototype, "Poodle does not implement Dog"); | |
}, | |
//more tests... | |
}); | |
Y.Test.Runner.add(testCase); | |
Y.Test.Runner.run(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment