diff options
author | randomdan <randomdan@localhost> | 2013-07-05 00:01:26 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2013-07-05 00:01:26 +0000 |
commit | 5507f618e094554f04f61a950d9c6d2b55865d3e (patch) | |
tree | 6f3a750f79ad26047ff5322522219798d19aa64c /project2/basics/tests | |
parent | Move remaining options out of environment (diff) | |
download | project2-5507f618e094554f04f61a950d9c6d2b55865d3e.tar.bz2 project2-5507f618e094554f04f61a950d9c6d2b55865d3e.tar.xz project2-5507f618e094554f04f61a950d9c6d2b55865d3e.zip |
Massive refactor to remove the appEngine and environment complication and instead have an execution context that's passed around from the original call site
Diffstat (limited to 'project2/basics/tests')
-rw-r--r-- | project2/basics/tests/compoundTest.cpp | 16 | ||||
-rw-r--r-- | project2/basics/tests/equals.cpp | 4 | ||||
-rw-r--r-- | project2/basics/tests/isdistinct.cpp | 6 | ||||
-rw-r--r-- | project2/basics/tests/isuniq.cpp | 8 | ||||
-rw-r--r-- | project2/basics/tests/validDateCheck.cpp | 8 |
5 files changed, 21 insertions, 21 deletions
diff --git a/project2/basics/tests/compoundTest.cpp b/project2/basics/tests/compoundTest.cpp index b361db5..119026e 100644 --- a/project2/basics/tests/compoundTest.cpp +++ b/project2/basics/tests/compoundTest.cpp @@ -20,11 +20,11 @@ class All : public CompoundTest { SourceObject(s), CompoundTest(s) { } - bool passes() const { + bool passes(ExecContext * ec) const { if (tests.empty()) { throw NoTestsToPerform(); } - return (std::find_if(tests.begin(), tests.end(), !boost::bind(&Test::passes, _1)) == tests.end()); + return (std::find_if(tests.begin(), tests.end(), !boost::bind(&Test::passes, _1, ec)) == tests.end()); } }; DECLARE_LOADER("all", All); @@ -35,11 +35,11 @@ class Any : public CompoundTest { SourceObject(s), CompoundTest(s) { } - bool passes() const { + bool passes(ExecContext * ec) const { if (tests.empty()) { throw NoTestsToPerform(); } - return (std::find_if(tests.begin(), tests.end(), boost::bind(&Test::passes, _1)) != tests.end()); + return (std::find_if(tests.begin(), tests.end(), boost::bind(&Test::passes, _1, ec)) != tests.end()); } }; DECLARE_LOADER("any", Any); @@ -50,11 +50,11 @@ class None : public CompoundTest { SourceObject(s), CompoundTest(s) { } - bool passes() const { + bool passes(ExecContext * ec) const { if (tests.empty()) { throw NoTestsToPerform(); } - return (std::find_if(tests.begin(), tests.end(), boost::bind(&Test::passes, _1)) == tests.end()); + return (std::find_if(tests.begin(), tests.end(), boost::bind(&Test::passes, _1, ec)) == tests.end()); } }; DECLARE_LOADER("none", None); @@ -67,11 +67,11 @@ class Not : public Test { { s->script->loader.addLoadTarget(s, Storer::into<ElementLoader>(&test)); } - bool passes() const { + bool passes(ExecContext * ec) const { if (!test) { throw NoTestsToPerform(); } - return !test->passes(); + return !test->passes(ec); } private: TestPtr test; diff --git a/project2/basics/tests/equals.cpp b/project2/basics/tests/equals.cpp index ba8c695..6c7a74f 100644 --- a/project2/basics/tests/equals.cpp +++ b/project2/basics/tests/equals.cpp @@ -13,8 +13,8 @@ class Equals : public Test { { } - bool passes() const { - return (a() == b()); + bool passes(ExecContext * ec) const { + return (a(ec) == b(ec)); } private: diff --git a/project2/basics/tests/isdistinct.cpp b/project2/basics/tests/isdistinct.cpp index ab7bf1b..303f88d 100644 --- a/project2/basics/tests/isdistinct.cpp +++ b/project2/basics/tests/isdistinct.cpp @@ -17,13 +17,13 @@ class IsDistinct : public Test, IHaveParameters { void loadComplete(const CommonObjects *) { - findComponent(scope())->registerFor(RowProcessor::Complete, boost::bind(&IsDistinct::reset, this)); + findComponent(scope(NULL))->registerFor(RowProcessor::Complete, boost::bind(&IsDistinct::reset, this)); } - bool passes() const { + bool passes(ExecContext * ec) const { Vars row; BOOST_FOREACH(const Parameters::value_type & p, parameters) { - row.push_back(p.second()); + row.push_back(p.second(ec)); } return previous.insert(row).second; } diff --git a/project2/basics/tests/isuniq.cpp b/project2/basics/tests/isuniq.cpp index c14ea84..e33aba8 100644 --- a/project2/basics/tests/isuniq.cpp +++ b/project2/basics/tests/isuniq.cpp @@ -17,21 +17,21 @@ class IsUniq : public Test, IHaveParameters { void loadComplete(const CommonObjects *) { - findComponent(scope())->registerFor(RowProcessor::Complete, boost::bind(&IsUniq::reset, this)); + findComponent(scope(NULL))->registerFor(RowProcessor::Complete, boost::bind(&IsUniq::reset, this)); } - bool passes() const { + bool passes(ExecContext * ec) const { if (previous.size() > 0) { Vars row; BOOST_FOREACH(const Parameters::value_type & p, parameters) { - row.push_back(p.second()); + row.push_back(p.second(ec)); } std::swap(row, previous); return row != previous; } else { BOOST_FOREACH(const Parameters::value_type & p, parameters) { - previous.push_back(p.second()); + previous.push_back(p.second(ec)); } return true; } diff --git a/project2/basics/tests/validDateCheck.cpp b/project2/basics/tests/validDateCheck.cpp index 8dffd9d..b1ab5a3 100644 --- a/project2/basics/tests/validDateCheck.cpp +++ b/project2/basics/tests/validDateCheck.cpp @@ -13,7 +13,7 @@ class ValidDateTest : public Test { Test(p), applyTo(p, "apply-to"), format(p, "format"), - warnLev(p->value("warn", true).as<bool>() ? LOG_WARNING : LOG_INFO) + warnLev(p->value("warn", true, NULL).as<bool>() ? LOG_WARNING : LOG_INFO) { } @@ -22,13 +22,13 @@ class ValidDateTest : public Test { } bool - passes() const + passes(ExecContext * ec) const { struct tm tm, ftm; memset(&tm, 0, sizeof(struct tm)); mktime(&tm); - const char * at = applyTo(); - const char * f = format(); + const char * at = applyTo(ec); + const char * f = format(ec); const char * s = strptime(at, f, &tm); if (!s || *s) { Logger()->messagef(warnLev, "%s: check failed (parse) for '%s' against '%s'", |