aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@petroules.com>2014-04-01 11:52:08 -0400
committerJoerg Bornemann <joerg.bornemann@digia.com>2014-04-25 17:52:56 +0200
commit1dab72cfbf45ec6a47697d92fcad9f1b77a3e205 (patch)
tree39067ed2190262d25b92a6d0294c0cf2e2e43957 /tests/auto
parent7b81ad2adb32fe5d5b233bbc2bda8948224d778a (diff)
Add support for building and running TypeScript apps through Node.js.
Change-Id: I13f4d1e7d994cc5c52a0a0d80e1db1de0c710376 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/blackbox/testdata/typescript/animals.ts21
-rw-r--r--tests/auto/blackbox/testdata/typescript/extra.js3
-rw-r--r--tests/auto/blackbox/testdata/typescript/foo.ts5
-rw-r--r--tests/auto/blackbox/testdata/typescript/main.ts19
-rw-r--r--tests/auto/blackbox/testdata/typescript/typescript.qbs34
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp19
-rw-r--r--tests/auto/blackbox/tst_blackbox.h1
7 files changed, 102 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata/typescript/animals.ts b/tests/auto/blackbox/testdata/typescript/animals.ts
new file mode 100644
index 000000000..a33ae5c11
--- /dev/null
+++ b/tests/auto/blackbox/testdata/typescript/animals.ts
@@ -0,0 +1,21 @@
+export interface Mammal {
+ speak(): string;
+}
+
+export class Cat implements Mammal {
+ public speak() {
+ return "Meow"; // a cat says meow
+ }
+}
+
+export class Dog implements Mammal {
+ public speak() {
+ return "Woof"; // a dog says woof
+ }
+}
+
+export class Human implements Mammal {
+ public speak() {
+ return "Hello";
+ }
+}
diff --git a/tests/auto/blackbox/testdata/typescript/extra.js b/tests/auto/blackbox/testdata/typescript/extra.js
new file mode 100644
index 000000000..5500e4688
--- /dev/null
+++ b/tests/auto/blackbox/testdata/typescript/extra.js
@@ -0,0 +1,3 @@
+if (console) {
+ console.log("This doesn't do anything useful!");
+}
diff --git a/tests/auto/blackbox/testdata/typescript/foo.ts b/tests/auto/blackbox/testdata/typescript/foo.ts
new file mode 100644
index 000000000..3554d317a
--- /dev/null
+++ b/tests/auto/blackbox/testdata/typescript/foo.ts
@@ -0,0 +1,5 @@
+export class Greeter {
+ public getGreeting(): string {
+ return "guten Tag!";
+ }
+}
diff --git a/tests/auto/blackbox/testdata/typescript/main.ts b/tests/auto/blackbox/testdata/typescript/main.ts
new file mode 100644
index 000000000..c41eebea5
--- /dev/null
+++ b/tests/auto/blackbox/testdata/typescript/main.ts
@@ -0,0 +1,19 @@
+import Animals = require("animals");
+import Foo = require("foo");
+
+function main() {
+ var mammals: Animals.Mammal[] = [];
+ mammals.push(new Animals.Human());
+ mammals.push(new Animals.Dog());
+ mammals.push(new Animals.Cat());
+
+ // Make everyone speak
+ for (var i = 0; i < mammals.length; ++i) {
+ console.log(mammals[i].speak());
+ }
+
+ var greeting: string = (new Foo.Greeter()).getGreeting();
+ console.log(greeting);
+}
+
+main();
diff --git a/tests/auto/blackbox/testdata/typescript/typescript.qbs b/tests/auto/blackbox/testdata/typescript/typescript.qbs
new file mode 100644
index 000000000..8407d1203
--- /dev/null
+++ b/tests/auto/blackbox/testdata/typescript/typescript.qbs
@@ -0,0 +1,34 @@
+import qbs
+
+Project {
+ NodeJSApplication {
+ Depends { name: "typescript" }
+ Depends { name: "lib" }
+
+ typescript.warningLevel: ["pedantic"]
+ typescript.generateDeclarations: true
+ typescript.moduleLoader: "commonjs"
+ nodejs.applicationFile: "main.ts"
+
+ name: "animals"
+
+ files: [
+ "animals.ts",
+ "extra.js",
+ "main.ts"
+ ]
+ }
+
+ Product {
+ Depends { name: "typescript" }
+
+ typescript.generateDeclarations: true
+ typescript.moduleLoader: "commonjs"
+
+ name: "lib"
+
+ files: [
+ "foo.ts"
+ ]
+ }
+}
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index c980896db..dab91a2e0 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -2020,4 +2020,23 @@ void TestBlackbox::testNodeJs()
QVERIFY(QFile::exists(buildDir + "/hello.js"));
}
+void TestBlackbox::testTypeScript()
+{
+ if (!haveNodeJs()) {
+ SKIP_TEST("node.js is not installed");
+ return;
+ }
+
+ QDir::setCurrent(testDataDir + QLatin1String("/typescript"));
+
+ QbsRunParameters params;
+ params.command = QLatin1String("run");
+ params.arguments = QStringList() << "-p" << "animals";
+ QCOMPARE(runQbs(params), 0);
+
+ QVERIFY(QFile::exists(buildDir + "/animals.js"));
+ QVERIFY(QFile::exists(buildDir + "/extra.js"));
+ QVERIFY(QFile::exists(buildDir + "/main.js"));
+}
+
QTEST_MAIN(TestBlackbox)
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index 900b9d13e..6bc2e2fe3 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -170,6 +170,7 @@ private slots:
void testEmbedInfoPlist();
void testWiX();
void testNodeJs();
+ void testTypeScript();
private:
QByteArray m_qbsStderr;