Mercurial > js4py
view core-javascript/core-javascript-work/test_library.js @ 154:ee0bf994ab95 core-javascript.closure-exercises
Add remove_answers.py script (and clean up closure-exercises.py).
| author | jf3243 |
|---|---|
| date | Wed, 02 Nov 2011 17:27:39 +0000 |
| parents | 20d76c716c9d |
| children |
line wrap: on
line source
var telltail = 'global'; var TEST = function(title, code){ print( 'Testing: ' + title ); code(); }; var assert = function(arg){ if(!arg){ ddt(); } }; // start SimpleClass TEST('SimpleClass', function() { var fruit = {}; fruit.__init__ = function(name, colour){ this.name = name; this.colour = colour; }; fruit.greet = function(){ return "Hello, I'm a " + this.color + " " + this.name + "."; }; var Fruit = SimpleClass(fruit); var bn = Fruit('banana', 'yellow'); var rc = Fruit('cherry', 'red'); var gs = Fruit('Granny Smith', 'green'); assert( bn.greet() === "Hello, I'm a undefined banana." ); }); // end SimpleClass
