Changeset View
Changeset View
Standalone View
Standalone View
autotests/html/test.ts.html
- This file was added.
1 | <!DOCTYPE html> | ||||
---|---|---|---|---|---|
2 | <html><head> | ||||
3 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> | ||||
4 | <title>test.ts</title> | ||||
5 | <meta name="generator" content="KF5::SyntaxHighlighting (TypeScript)"/> | ||||
6 | </head><body style="color:#1f1c1b"><pre> | ||||
7 | <span style="color:#898887;">/// </span><span style="color:#000000;font-weight:bold;"><reference</span><span style="color:#006e28;"> types=</span><span style="color:#0057ae;">"node"</span><span style="color:#006e28;"> </span><span style="color:#000000;font-weight:bold;">/></span> | ||||
8 | | ||||
9 | <span style="color:#898887;">// TypeScript Test</span> | ||||
10 | | ||||
11 | <span style="font-weight:bold;font-style:italic;">class</span> Student { | ||||
12 | fullName: <span style="color:#0057ae;">string</span>; | ||||
13 | <span style="font-weight:bold;font-style:italic;">constructor</span>(<span style="font-weight:bold;font-style:italic;">public</span> firstName: <span style="color:#0057ae;">string</span>, <span style="font-weight:bold;font-style:italic;">public</span> middleInitial: <span style="color:#0057ae;">string</span>, <span style="font-weight:bold;font-style:italic;">public</span> lastName: <span style="color:#0057ae;">string</span>) { | ||||
14 | <span style="font-weight:bold;">this</span>.<span style="color:#0057ae;">fullName</span> = firstName + <span style="color:#bf0303;">" "</span> + middleInitial + <span style="color:#bf0303;">" "</span> + lastName; | ||||
15 | } | ||||
16 | } | ||||
17 | | ||||
18 | <span style="font-weight:bold;font-style:italic;">interface</span> Person { | ||||
19 | firstName: <span style="color:#0057ae;">string</span>; | ||||
20 | lastName: <span style="color:#0057ae;">string</span>; | ||||
21 | } | ||||
22 | | ||||
23 | <span style="font-weight:bold;">function</span> <span style="color:#644a9b;">greeter</span>(person : Person) { | ||||
24 | <span style="font-weight:bold;">return</span> <span style="color:#bf0303;">"Hello, "</span> + <span style="color:#0057ae;">person</span>.<span style="color:#0057ae;">firstName</span> + <span style="color:#bf0303;">" "</span> + <span style="color:#0057ae;">person</span>.<span style="color:#0057ae;">lastName</span>; | ||||
25 | } | ||||
26 | | ||||
27 | <span style="font-weight:bold;font-style:italic;">let</span> user = <span style="font-weight:bold;">new</span> <span style="color:#644a9b;">Student</span>(<span style="color:#bf0303;">"Jane"</span>, <span style="color:#bf0303;">"M."</span>, <span style="color:#bf0303;">"User"</span>); | ||||
28 | | ||||
29 | <span style="color:#644a9b;font-weight:bold;">document</span>.<span style="color:#0057ae;font-style:italic;">body</span>.<span style="color:#0057ae;">innerHTML</span> = <span style="color:#644a9b;">greeter</span>(user); | ||||
30 | <span style="color:#644a9b;font-weight:bold;">JSON</span>.<span style="color:#644a9b;font-style:italic;">stringify</span>() | ||||
31 | <span style="color:#644a9b;font-weight:bold;">console</span>.<span style="color:#644a9b;font-style:italic;">log</span>(<span style="color:#bf0303;">"Hello world"</span>); | ||||
32 | | ||||
33 | <span style="color:#ff5500;">import</span> http =<span style="font-weight:bold;"> require</span>(<span style="color:#bf0303;">"http"</span>); | ||||
34 | <span style="color:#ff5500;">import</span> path =<span style="font-weight:bold;"> require</span>(<span style="color:#bf0303;">"path"</span>); | ||||
35 | <span style="color:#ff5500;">import</span> URL = <span style="color:#0057ae;">url</span>.<span style="color:#0057ae;">URL</span>; | ||||
36 | <span style="color:#ff5500;">import</span> { Readable, Writable } <span style="color:#ff5500;">from</span> <span style="color:#bf0303;">"stream"</span>; | ||||
37 | <span style="color:#ff5500;">import</span> { isBuffer, isString, isObject } <span style="color:#ff5500;">from</span> <span style="color:#bf0303;">"util"</span>; | ||||
38 | | ||||
39 | <span style="font-weight:bold;">const</span> port = <span style="color:#b08000;">8__88___8</span>; | ||||
40 | <span style="font-weight:bold;">const</span> baseUrl = <span style="font-weight:bold;">new</span> <span style="color:#644a9b;">URL</span>(<span style="color:#bf0303;">`http://localhost:</span><span style="color:#3daee9;">${</span>port<span style="color:#3daee9;">}</span><span style="color:#bf0303;">/`</span>); | ||||
41 | <span style="font-weight:bold;">const</span> rootDir = <span style="color:#0057ae;">path</span>.<span style="color:#644a9b;">dirname</span>(__dirname); | ||||
42 | | ||||
43 | <span style="font-weight:bold;">const</span> defaultBrowser = <span style="color:#0057ae;">os</span>.<span style="color:#644a9b;">platform</span>() === <span style="color:#bf0303;">"win32"</span> ? <span style="color:#bf0303;">"edge"</span> : <span style="color:#bf0303;">"chrome"</span>; | ||||
44 | <span style="font-weight:bold;font-style:italic;">let</span> browser: <span style="color:#bf0303;">"edge"</span> | <span style="color:#bf0303;">"chrome"</span> | <span style="color:#bf0303;">"none"</span> = defaultBrowser; | ||||
45 | <span style="font-weight:bold;font-style:italic;">let</span> grep: <span style="color:#0057ae;">string</span> | <span style="font-weight:bold;">undefined</span>; | ||||
46 | | ||||
47 | <span style="font-weight:bold;font-style:italic;">interface</span> FileBasedTestConfiguration { | ||||
48 | [setting: <span style="color:#0057ae;">string</span>]: <span style="color:#0057ae;">string</span>; | ||||
49 | } | ||||
50 | | ||||
51 | <span style="font-weight:bold;">function</span> <span style="color:#644a9b;">swapCase</span>(s: <span style="color:#0057ae;">string</span>): <span style="color:#0057ae;">string</span> { | ||||
52 | <span style="font-weight:bold;">return</span> <span style="color:#0057ae;">s</span>.<span style="color:#644a9b;">replace</span>(<span style="color:#ff5500;">/</span><span style="color:#3daee9;">\w</span><span style="color:#ff5500;">/g</span>, (ch) <span style="font-weight:bold;">=></span> { | ||||
53 | <span style="font-weight:bold;">const</span> up = <span style="color:#0057ae;">ch</span>.<span style="color:#644a9b;">toUpperCase</span>(); | ||||
54 | <span style="font-weight:bold;">return</span> ch === up ? <span style="color:#0057ae;">ch</span>.<span style="color:#644a9b;">toLowerCase</span>() : up; | ||||
55 | }); | ||||
56 | } | ||||
57 | </pre></body></html> |