From 3e5637b0aad29d8a5e93ad4fdff4074f8dbc9409 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 9 Dec 2012 12:09:26 +0100 Subject: Update test program. --- cells-test.cpp | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/cells-test.cpp b/cells-test.cpp index a88fe5b..539ee56 100644 --- a/cells-test.cpp +++ b/cells-test.cpp @@ -31,25 +31,32 @@ typedef formula_cell ucell; int main(int argc, char** argv) { - fcell x0, x1, x2, y, z; - ucell a, b; + fcell x0, x1, x2, y; + ucell b; - with_transaction([&](){ - x0.reset(10); - x1.reset([&](){ return *x0 + 5; }); - x2.reset([&](){ return *x0 * 2; }); - y.reset([&](){ return *x1 * *x2; }); - z.reset([&](){ return *x0 * *y; }); - a.reset([&]() -> unit { cout << "z is now " << *z << "." << endl; return unit(); }); - b.reset([&]() -> unit { cout << "x2 is now " << *x2 << "." << endl; return unit(); }); - }); - - x0.reset(15); - x0.reset(-20); - y.reset(-3); - x1.reset([&]() { return (double)*x0; }); - y.reset([&]() { return *x1 + *x2; }); + { + fcell z; + ucell a; + with_transaction([&](){ + x0.reset(10); + x1.reset([&](){ return *x0 + 5; }); + x2.reset([&](){ return *x0 * 2; }); + y.reset([&](){ return *x1 * *x2; }); + z.reset([&](){ return *x0 * *y; }); + a.reset([&]() -> unit { cout << "z is now " << *z << "." << endl; return unit(); }); + b.reset([&]() -> unit { cout << "x2 is now " << *x2 << "." << endl; return unit(); }); + }); + + x0.reset(15); + x0.reset(-20); + y.reset(-3); + x1.reset([&]() { return (double)*x0; }); + y.reset([&]() { return *x1 + *x2; }); + } + x0.reset(10); //z and a are not active anymore, so only b will + //produce output. + return EXIT_SUCCESS; } -- cgit v1.2.3