mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.autotest
git-svn-id: svn://ultimatepp.org/upp/trunk@7715 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
204a41d3bb
commit
204ec7ea85
3 changed files with 58 additions and 15 deletions
|
|
@ -67,8 +67,22 @@ CHK(a, |, b); \
|
|||
LOG(#val << " = " << v << ", ref: " << ref); \
|
||||
ASSERT(v == ref); }
|
||||
|
||||
void SIC_Print(EscEscape& e)
|
||||
{
|
||||
if(e[0].IsArray())
|
||||
LOG((String) e[0]);
|
||||
else
|
||||
if(e[0].IsNumber())
|
||||
LOG(e[0].GetNumber());
|
||||
else
|
||||
if(!e[0].IsVoid())
|
||||
e.ThrowError("invalid argument to 'Print'");
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
StdLogSetup(LOG_FILE|LOG_COUT);
|
||||
|
||||
CHKDBL(3.1, 2.1);
|
||||
CHKDBL(3.0, 2.0);
|
||||
CHKDBL(3.0, (int64)2);
|
||||
|
|
@ -96,4 +110,22 @@ CONSOLE_APP_MAIN
|
|||
CHKV(global.Get("a").GetNumber(), 3);
|
||||
CHKV(Evaluate("--a", global).GetNumber(), 2);
|
||||
CHKV(global.Get("a").GetNumber(), 2);
|
||||
|
||||
LOG("----");
|
||||
global.GetAdd("s", "Test");
|
||||
CHKV((WString)Evaluate("s", global), "Test");
|
||||
|
||||
LOG("----");
|
||||
Escape(global, "Print(x)", SIC_Print);
|
||||
try {
|
||||
Scan(global, LoadFile(GetDataFile("script.esc")));
|
||||
Execute(global, "main", INT_MAX);
|
||||
}
|
||||
catch(CParser::Error e) {
|
||||
Cout() << "ERROR: " << e << "\n";
|
||||
}
|
||||
|
||||
DDUMP(global.Get("out"));
|
||||
DDUMP(global.Get("out2"));
|
||||
DDUMP(global.Get("out3"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
check(a, b)
|
||||
{
|
||||
// Print("// ========================");
|
||||
// Print("// a: " + to_string(a) ", b: " + to_string(b));
|
||||
Check("a", a, "");
|
||||
Check("b", b, "");
|
||||
Check("a + b", a + b, "");
|
||||
Check("a - b", a - b, "");
|
||||
Check("a * b", a * b, "");
|
||||
Check("a / b", a / b, "");
|
||||
}
|
||||
|
||||
main() {
|
||||
check(0, 1);
|
||||
check(1.1, 1.2);
|
||||
check(0xfffffffffffffff0, 1);
|
||||
Print("Hello world!");
|
||||
x = {};
|
||||
x.a = 123;
|
||||
x.b = "Hello!";
|
||||
|
||||
:out = x;
|
||||
|
||||
x.foo = @(x) { .a = x; };
|
||||
|
||||
x.foo("test");
|
||||
:out2 = x.a;
|
||||
|
||||
:out3 = [];
|
||||
for(i = 0; i < 10; i++)
|
||||
:out3[] = i;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,15 @@ void TestTrimRight(String what, String s, String r)
|
|||
}
|
||||
}
|
||||
|
||||
void TestMultiReplace()
|
||||
{
|
||||
VectorMap<String, String> r;
|
||||
r("hell", "hello")("hello", "hell");
|
||||
String h = Replace(String("TEXT: hell hello!"), r);
|
||||
DDUMP(h);
|
||||
ASSERT(h == "TEXT: hello hell!");
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
String h = "http://www.website.org";
|
||||
|
|
@ -34,4 +43,6 @@ CONSOLE_APP_MAIN
|
|||
|
||||
TestTrimLeft("http://", "http://www.website.org", "www.website.org");
|
||||
TestTrimRight(".org", "www.website.org", "www.website");
|
||||
|
||||
TestMultiReplace();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue