-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest.cs
30 lines (28 loc) · 1.08 KB
/
Test.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
namespace YuchikiML {
using System.Collections.Generic;
using System.Linq;
using System;
static class Test {
public static void TestEval(string name, Expr e, Value expected) {
Console.Write($"Test {name,-20}: ");
var result = e.Calculate();
if (expected.Equals(result)) {
Console.WriteLine("OK");
} else {
Console.WriteLine("NG");
Console.WriteLine($"Expression:{e}, Expected:{expected} of {expected.GetType()}, Result:{result} of {result.GetType()}");
System.Environment.Exit(1);
}
}
public static void ShouldBeEqual<T>(this T t, Object expected, string name) {
Console.Write($"Test {name, -20}: ");
if (expected.Equals(t)) {
Console.WriteLine("OK");
} else {
Console.WriteLine("NG");
Console.WriteLine($"Expected:{expected} of {expected.GetType()}, Result:{t} of {t.GetType()}");
System.Environment.Exit(1);
}
}
}
}