Kaynağa Gözat

Add tests and update todo

master
mtardy 4 yıl önce
ebeveyn
işleme
6905791c60
3 değiştirilmiş dosya ile 76 ekleme ve 10 silme
  1. +27
    -0
      TODO.txt
  2. +37
    -2
      test-object.txt
  3. +12
    -8
      test3.txt

+ 27
- 0
TODO.txt Dosyayı Görüntüle

@ -3,3 +3,30 @@
return
break in switch, loops
continue in loops
getFunction(Object.print)
{
__proto__ : { __name__ : Function },
body: anAst,
parameters: aMap,
scope: aMap,
}
makeFunction({
__proto__ : { __name__ : Function },
body: anAst,
parameters: aMap,
scope: aMap,
})
var num = `4; // THESE ARE THE
var ast = `(3+@num); // IMPORTANT 2 LINES
println(3 + @ast); // -> 10
println(3 + (3+4)); // -> 10
syntax for () {
if (__arguments__[1] == #in) { }
else if (__arguments__[1] == #on) { }
}

+ 37
- 2
test-object.txt Dosyayı Görüntüle

@ -11,7 +11,7 @@ Object.new = fun () {
var obj= { __proto__ : this };
var init= this.init;
print("INIT is ", init);
init && invoke(null, obj, init, __arguments__);
init && invoke(obj, init, __arguments__);
obj;
};
@ -26,4 +26,39 @@ Point.init = fun (x, y) {
this.y = y;
}
print("Point.new(3, 4) is ", Point.new(3, 4));
var p = Point.new(3, 4);
print("Point.new(3, 4) is ", p);
Object.clone = fun () { clone(this) }
var q = p.clone();
print("clone is ", q);
Object.println = fun () { this.print(); print('\n'); this; }
Object.print = fun () {
var proto= this.__proto__;
if (!proto) print(this);
else {
var name= proto.__name__;
if (!name) print(this);
else {
print(name, "{");
var keys= keys(this);
for (var i= 0; i < length(keys); ++i) {
var key= keys[i];
var val= this[key];
if (i) print(", ");
print(" ", key, ": ", val);
}
print(" }");
}
}
this;
}
p.println()

+ 12
- 8
test3.txt Dosyayı Görüntüle

@ -1,8 +1,12 @@
fun f(n) {
if (n < 2) {
return 1
} else {
return 1 + f(n-1) + f(n-2)
}
}
f(27)
var o = {}
o.a = 12
o.b = "salut"
var c = clone(o, "12");
c.a = 24
c.b = "au revoir"
c.chips = "on va manger, des chips!!!"
o
c

Yükleniyor…
İptal
Kaydet