tests added

This commit is contained in:
Sergey Gerasimov
2014-01-07 19:51:33 +04:00
parent ecb706d472
commit 270bb693f2
+25
View File
@@ -0,0 +1,25 @@
/// <reference path="hashtable.d.ts" />
class Point {
constructor(public x: number, public y: number) {
}
}
function hashPoint(p: Point) {
return "Point:" + p.x + "," + p.y;
}
function pointsEqual(p1: Point, p2: Point) {
return p1.x === p2.x && p1.y === p2.y;
}
var coloursForPoints = new Hashtable<Point, string>({ hashCode: hashPoint, equals: pointsEqual });
function getColourAt(x, y) {
var point = new Point(x, y);
return coloursForPoints.get(point);
}
coloursForPoints.put(new Point(1, 2), "green");
alert(getColourAt(1, 2)); // Alerts green