Mercurial > js4py-pl
view core-javascript/core-javascript-work/test_library.js @ 201:b6864a86e876 default tip
Przetłumaczone getting-started
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Sun, 15 Jul 2012 13:27:27 +0200 |
| 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
