summaryrefslogtreecommitdiff
path: root/test/syntax/code/d
diff options
context:
space:
mode:
Diffstat (limited to 'test/syntax/code/d')
-rw-r--r--test/syntax/code/d44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/syntax/code/d b/test/syntax/code/d
new file mode 100644
index 00000000..92cc8d84
--- /dev/null
+++ b/test/syntax/code/d
@@ -0,0 +1,44 @@
+#!/usr/bin/rdmd
+// Computes average line length for standard input.
+import std.stdio;
+
+/+
+ this is a /+ nesting +/ comment
++/
+
+enum COMPILED_ON = __TIMESTAMP__; // special token
+
+enum character = '©';
+enum copy_valid = '©';
+enum backslash_escaped = '\\';
+
+// string literals
+enum str = `hello "world"!`;
+enum multiline = r"lorem
+ipsum
+dolor"; // wysiwyg string, no escapes here allowed
+enum multiline2 = "sit
+amet
+\"adipiscing\"
+elit.";
+enum hex = x"66 6f 6f"; // same as "foo"
+
+#line 5
+
+// float literals
+enum f = [3.14f, .1, 1., 1e100, 0xc0de.01p+100];
+
+static if (something == true) {
+ import std.algorithm;
+}
+
+void main() pure nothrow @safe {
+ ulong lines = 0;
+ double sumLength = 0;
+ foreach (line; stdin.byLine()) {
+ ++lines;
+ sumLength += line.length;
+ }
+ writeln("Average line length: ",
+ lines ? sumLength / lines : 0);
+}