diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-04-24 17:41:11 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-04-24 17:46:21 -0700 |
commit | 763177a52d0f48198192375f1b912c8a37230425 (patch) | |
tree | 74691a9074b6c2327eb960f5a56578ffe9b9ea0c | |
parent | 0689e43ae61723dde87ec9a2b6210a349d080b31 (diff) |
improve test_polymorph
-rw-r--r-- | tests/core/test_polymorph.in | 8 | ||||
-rw-r--r-- | tests/core/test_polymorph.out | 4 |
2 files changed, 11 insertions, 1 deletions
diff --git a/tests/core/test_polymorph.in b/tests/core/test_polymorph.in index 1f24a1aa..af07dc05 100644 --- a/tests/core/test_polymorph.in +++ b/tests/core/test_polymorph.in @@ -16,6 +16,8 @@ struct Child : Parent { struct Other { int one() { return 11; } int two() { return 22; } + virtual int three() { return 33; } + virtual int four() { return 44; } }; int main() { @@ -24,10 +26,16 @@ int main() { printf("*%d,%d,%d,%d*\n", x->getit(), y->getit(), x->implme(), y->implme()); Other *o = new Other; + int (Other::*Ls)() = &Other::one; printf("*%d*\n", (o->*(Ls))()); Ls = &Other::two; printf("*%d*\n", (o->*(Ls))()); + Ls = &Other::three; + printf("*%d*\n", (o->*(Ls))()); + Ls = &Other::four; + printf("*%d*\n", (o->*(Ls))()); + return 0; } diff --git a/tests/core/test_polymorph.out b/tests/core/test_polymorph.out index 0d036bf0..5163ea8e 100644 --- a/tests/core/test_polymorph.out +++ b/tests/core/test_polymorph.out @@ -1,3 +1,5 @@ *11,74,32,1012* *11* -*22*
\ No newline at end of file +*22* +*33* +*44* |