.autotest

git-svn-id: svn://ultimatepp.org/upp/trunk@8175 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2015-02-14 18:13:37 +00:00
parent 74a77d0d69
commit d740b08fe4
8 changed files with 140 additions and 1 deletions

View file

@ -0,0 +1,67 @@
#include <CppBase/CppBase.h>
using namespace Upp;
Vector<String> errs;
void AddError(int ln, const String& s)
{
errs.Add(AsString(ln) + ": " + s);
}
void Test(const char *path)
{
CppBase base;
LOG("**** " << GetFileName(path));
FileIn in(path);
errs.Clear();
Parser p;
p.Do(in, Vector<String>(), base, path, callback(AddError));
if(errs.GetCount())
DUMPC(errs);
Qualify(base);
String out;
for(int i = 0; i < base.GetCount(); i++) {
out << Nvl(base.GetKey(i), "<globals>") << " {\n";
const Array<CppItem>& ma = base[i];
for(int j = 0; j < ma.GetCount(); j++) {
const CppItem& m = ma[j];
out << '\t' << CppItemKindAsString(m.kind) << ' ' << m.qitem << ", line " << m.line << "\n";
}
out << "}\n";
}
p.dobody = true;
in.Seek(0);
p.Do(in, Vector<String>(), base, path, callback(AddError));
out << "<locals> {\n";
for(int i = 0; i < p.local.GetCount(); i++) {
out << p.local.GetKey(i) << " " << p.local[i].type;
if(p.local[i].isptr)
out << " pointer";
out << ", line: " << p.local[i].line << "\n";
}
out << "}";
LOG("====");
LOG(out);
LOG("-------------------------------------------------------------------------------");
String h = LoadFile(ForceExt(path, ".out"));
h.Replace("\r", "");
ASSERT(out == h);
}
CONSOLE_APP_MAIN {
StdLogSetup(LOG_COUT|LOG_FILE);
FindFile ff(GetDataFile("*.in"));
while(ff) {
Test(ff.GetPath());
ff.Next();
}
LOG("=========== OK");
}

View file

@ -0,0 +1,14 @@
uses
Core,
CppBase;
file
CppParser.cpp,
test1.in,
test1.out,
test2.in,
test2.out;
mainconfig
"" = "SSE2";

5
autotest/CppParser/init Normal file
View file

@ -0,0 +1,5 @@
#ifndef _CppParser_icpp_init_stub
#define _CppParser_icpp_init_stub
#include "Core/init"
#include "CppBase/init"
#endif

View file

@ -0,0 +1,18 @@
void Test() {}
class Foo {
Foo();
};
struct Point {
int x, y;
Point *next;
Foo bar;
};
Point global;
void foo()
{
int x = 10;
Point a, b, *c;

View file

@ -0,0 +1,22 @@
<globals> {
FUNCTION Test(), line 1
FUNCTION foo(), line 15
VARIABLE global, line 13
}
Foo {
CONSTRUCTOR Foo(), line 4
STRUCT class, line 3
}
Point {
INSTANCEVARIABLE bar, line 10
INSTANCEVARIABLE next, line 9
STRUCT struct, line 7
INSTANCEVARIABLE x, line 8
INSTANCEVARIABLE y, line 8
}
<locals> {
x , line: 17
a Point, line: 18
b Point, line: 18
c Point pointer, line: 18
}

View file

@ -0,0 +1,5 @@
template<true, typename _Ty>
struct _CrtEnableIf<true, _Ty>
{
typedef _Ty _Type;
};

View file

@ -0,0 +1,8 @@
_CrtEnableIf<true, _Ty> {
STRUCTTEMPLATE struct, line 1
}
_CrtEnableIf<true, _Ty> ::_Type {
TYPEDEF typedef, line 4
}
<locals> {
}

View file

@ -2,7 +2,7 @@ uses
Core;
file
SpinLock.cpp;
SpinLock.cpp optimize_speed;
mainconfig
"" = "SSE2 MT";