aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-02-10 18:33:46 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-02-10 18:33:46 -0800
commit123063bc5bdbebce5bafb79b89f507ba0a0c1488 (patch)
tree4d24a70e40d82e8e55568334e262a40ed8a69cce /tests/runner.py
parent4928f86a496bec355df44b2f54e080706b07fcce (diff)
force inputs to inttoptr to be i32 if they are i64; fixes #827
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index f06e1b62..71035b02 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -6308,6 +6308,53 @@ int main(int argc, char **argv) {
self.do_run(src, '789:123.46\n0:100.1')
+ def test_reinterpreted_ptrs(self):
+ if self.emcc_args is None: return self.skip('needs emcc and libc')
+
+ src = r'''
+#include <stdio.h>
+
+class Foo {
+private:
+ float bar;
+public:
+ int baz;
+
+ Foo(): bar(0), baz(4711) {};
+
+ int getBar() const;
+};
+
+int Foo::getBar() const {
+ return this->bar;
+};
+
+const Foo *magic1 = reinterpret_cast<Foo*>(0xDEAD111F);
+const Foo *magic2 = reinterpret_cast<Foo*>(0xDEAD888F);
+
+static void runTest() {
+
+ const Foo *a = new Foo();
+ const Foo *b = a;
+
+ if (a->getBar() == 0) {
+ if (a->baz == 4712)
+ b = magic1;
+ else
+ b = magic2;
+ }
+
+ printf("%s\n", (b == magic1 ? "magic1" : (b == magic2 ? "magic2" : "neither")));
+};
+
+extern "C" {
+ int main(int argc, char **argv) {
+ runTest();
+ }
+}
+'''
+ self.do_run(src, 'magic2')
+
def test_jansson(self):
return self.skip('currently broken')