diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-04 19:55:27 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-04 19:55:27 -0400 |
commit | 2d941730b1c60342be5b108d2d654723b3b7c2cb (patch) | |
tree | 6a3f4b7305857e85d2684670492007bafc3668d0 /test | |
parent | 73cf3b01fbd50c3a8a4fd96ff69643c28394d8fe (diff) | |
download | fork-ledger-2d941730b1c60342be5b108d2d654723b3b7c2cb.tar.gz fork-ledger-2d941730b1c60342be5b108d2d654723b3b7c2cb.tar.bz2 fork-ledger-2d941730b1c60342be5b108d2d654723b3b7c2cb.zip |
Largely removed all of Ledger's use of global variables, for the REPL's sake.
Diffstat (limited to 'test')
-rwxr-xr-x | test/convert.py | 2 | ||||
-rw-r--r-- | test/unit/t_amount.cc | 10 | ||||
-rw-r--r-- | test/unit/t_amount.h | 2 | ||||
-rw-r--r-- | test/unit/t_commodity.cc | 8 | ||||
-rw-r--r-- | test/unit/t_expr.cc | 6 | ||||
-rw-r--r-- | test/unit/t_times.cc | 4 |
6 files changed, 17 insertions, 15 deletions
diff --git a/test/convert.py b/test/convert.py index 9f322b2e..278bc76f 100755 --- a/test/convert.py +++ b/test/convert.py @@ -144,6 +144,8 @@ for line in fd.readlines(): line = re.sub('\.print\(([^)]+?)\)', '.print_(\\1)', line) line = re.sub('true', 'True', line) line = re.sub('false', 'False', line) + line = re.sub('CURRENT_TIME\(\)', 'datetime.now()', line) + line = re.sub('CURRENT_DATE\(\)', 'date.today()', line) line = re.sub('([0-9]+)[FL]', '\\1', line) line = re.sub('([0-9]+)UL', '\\1L', line) line = re.sub(';', '', line) diff --git a/test/unit/t_amount.cc b/test/unit/t_amount.cc index d7858064..33e2d85b 100644 --- a/test/unit/t_amount.cc +++ b/test/unit/t_amount.cc @@ -1097,6 +1097,8 @@ void AmountTestCase::testCommodityAbs() assertValid(x2); } +#ifndef NOT_FOR_PYTHON +#if 0 void AmountTestCase::testReduction() { amount_t x0; @@ -1115,11 +1117,13 @@ void AmountTestCase::testReduction() assertThrow(x0.reduce(), amount_error); assertThrow(x0.unreduce(), amount_error); - assertEqual(x2, x5); - assertEqual(x3, x6); - assertEqual(x4, x10); + assertEqual(x2, x5.reduce()); + assertEqual(x3, x6.reduce()); + assertEqual(x10, x4.reduce()); assertEqual(string("100.0h"), x4.unreduce().to_string()); } +#endif +#endif // NOT_FOR_PYTHON void AmountTestCase::testSign() { diff --git a/test/unit/t_amount.h b/test/unit/t_amount.h index f2ab38d6..3d63b2d7 100644 --- a/test/unit/t_amount.h +++ b/test/unit/t_amount.h @@ -32,7 +32,9 @@ class AmountTestCase : public CPPUNIT_NS::TestCase CPPUNIT_TEST(testCommodityNegation); CPPUNIT_TEST(testAbs); CPPUNIT_TEST(testCommodityAbs); +#if 0 CPPUNIT_TEST(testReduction); +#endif CPPUNIT_TEST(testSign); CPPUNIT_TEST(testCommoditySign); CPPUNIT_TEST(testTruth); diff --git a/test/unit/t_commodity.cc b/test/unit/t_commodity.cc index 9818c863..5f72c195 100644 --- a/test/unit/t_commodity.cc +++ b/test/unit/t_commodity.cc @@ -73,7 +73,7 @@ void CommodityTestCase::testPriceHistory() assertTrue(amt); assertEqual(amount_t("$1831.83"), *amt); - amt = x1.value(current_time); + amt = x1.value(CURRENT_TIME()); assertTrue(amt); assertEqual(string("$2124.12"), amt->to_string()); #ifdef INTEGER_MATH @@ -82,18 +82,18 @@ void CommodityTestCase::testPriceHistory() assertEqual(string("$2124.1220"), amt->to_fullstring()); #endif - amt = x1.value(current_time, euro); + amt = x1.value(CURRENT_TIME(), euro); assertTrue(amt); assertEqual(string("EUR 1366.87"), amt->rounded().to_string()); // Add a newer Euro pricing aapl.add_price(jan17_07, amount_t("EUR 23.00")); - amt = x1.value(current_time, euro); + amt = x1.value(CURRENT_TIME(), euro); assertTrue(amt); assertEqual(string("EUR 2302.30"), amt->to_string()); - amt = x1.value(current_time, cad); + amt = x1.value(CURRENT_TIME(), cad); assertTrue(amt); assertEqual(string("CAD 3223.22"), amt->to_string()); #endif // NOT_FOR_PYTHON diff --git a/test/unit/t_expr.cc b/test/unit/t_expr.cc index 209bb934..f9096cc5 100644 --- a/test/unit/t_expr.cc +++ b/test/unit/t_expr.cc @@ -9,16 +9,10 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ValueExprTestCase, "expr"); void ValueExprTestCase::setUp() { amount_t::initialize(); -#ifndef NOT_FOR_PYTHON - expr_t::initialize(); -#endif // NOT_FOR_PYTHON } void ValueExprTestCase::tearDown() { -#ifndef NOT_FOR_PYTHON - expr_t::shutdown(); -#endif // NOT_FOR_PYTHON amount_t::shutdown(); } diff --git a/test/unit/t_times.cc b/test/unit/t_times.cc index f93a1b36..f593eeac 100644 --- a/test/unit/t_times.cc +++ b/test/unit/t_times.cc @@ -66,8 +66,8 @@ void DateTimeTestCase::testConstructors() assertFalse(d4.is_not_a_date_time()); #endif // NOT_FOR_PYTHON - assertTrue(current_time > d1); - assertTrue(current_time > d4); + assertTrue(CURRENT_TIME() > d1); + assertTrue(CURRENT_TIME() > d4); #ifndef NOT_FOR_PYTHON assertEqual(d3, d15); |