Skip to content

Instantly share code, notes, and snippets.

@philmander
Created September 5, 2011 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philmander/1195862 to your computer and use it in GitHub Desktop.
Save philmander/1195862 to your computer and use it in GitHub Desktop.
Javascript interfaces revisited 1
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