Browse Source

[python] add tests for @:import

Dan Korostelev 11 years ago
parent
commit
33cdf17c39

+ 1 - 0
.gitignore

@@ -57,6 +57,7 @@ build.bat
 tests/unit/compile.php.hxml
 tests/unit/compile.php.hxml
 /extra/*.xml
 /extra/*.xml
 tests/optimization/testopt.js
 tests/optimization/testopt.js
+tests/unit/native_python/__pycache__
 tests/unit/unit.py
 tests/unit/unit.py
 tests/unit/unit.py.res1.txt
 tests/unit/unit.py.res1.txt
 tests/unit/unit.py.res2.bin
 tests/unit/unit.py.res2.bin

+ 24 - 0
tests/unit/TestPython.hx

@@ -84,6 +84,23 @@ private class B extends A {
     public function new() {}
     public function new() {}
 }
 }
 
 
+@:import("native_python.sample", "A")
+extern class ExternClass {
+	function new();
+	function f(v:Int):Int;
+}
+
+@:import("native_python.sample", "A.Nested")
+extern class ExternNestedClass {
+	function new();
+	function f(v:Int):Int;
+}
+
+@:import("native_python.sample")
+extern class ExternModule {
+	static function f(v:Int):Int;
+}
+
 class TestPython extends Test {
 class TestPython extends Test {
 
 
 	public function testDoWhileAsExpression () {
 	public function testDoWhileAsExpression () {
@@ -303,4 +320,11 @@ class TestPython extends Test {
 		eq(test4a(1), test4b(1));
 		eq(test4a(1), test4b(1));
 	}
 	}
 
 
+	function testExtern()
+	{
+		eq(new ExternClass().f(1), 2);
+		eq(new ExternNestedClass().f(1), 3);
+		eq(ExternModule.f(1), 4);
+	}
+
 }
 }

+ 0 - 0
tests/unit/native_python/__init__.py


+ 11 - 0
tests/unit/native_python/sample.py

@@ -0,0 +1,11 @@
+class A:
+
+    def f(self, v):
+        return v + 1
+
+    class Nested:
+        def f(self, v):
+            return v + 2
+
+def f(v):
+    return v + 3