on master help sign in
#1213 expanded D test file
5b2da2bFrank Schmitt
tests/syntax-tests/highlighted/D/test.d+28−7
@@ -1,11 +1,16 @@
1+// selective import
1−import std.stdio;
2+import std.stdio : writeln, writefln;
3+// non-selective import
2import std.algorithm;
4import std.algorithm;
3−import std.range;
4
5
5/* a multiline comment
6/* a multiline comment
6*
7*
8+* this function is safe because it doesn't use pointer arithmetic
7*/
9*/
8−int the_ultimate_answer() {
10+int the_ultimate_answer() @safe {
11+ // assert1on
12+ assert(1 != 2);
13+ // now we can safely return our answer 
9 return 42;
14 return 42;
10}
15}
11
16
@@ -16,8 +21,24 @@
16
21
17 // an int array declaration
22 // an int array declaration
18 int[] arr1 = [1, 2, 3];
23 int[] arr1 = [1, 2, 3];
19− // a double
24+ // an immutable double
20− double d1 = 3.14;
25+ immutable double pi = 3.14;
21− // another function call 
26+ // a mutable double
27+ double d1 = pi;
28+ // a pointer
29+ double* dp1 = &d1;
30+ // another pointer to the same thingy
31+ auto a1 = &d1;
32+ // a constant bool
33+ const bool b1 = true;
34+ if (b1) {
35+ // another function call 
22− writefln("%s\n%s\n%s\n", arr1, d1, the_ultimate_answer());
36+ writefln("%s\n%s\n%s\n", arr1, d1, the_ultimate_answer());
37+ }
38+ else if (!b1) {
39+ writeln("this seems wrong");
40+ }
41+ else {
42+ writeln("I'm giving up, this is too crazy for me");
43+ }
23}
44}
tests/syntax-tests/source/D/test.d+28−7
@@ -1,11 +1,16 @@
1+// selective import
1−import std.stdio;
2+import std.stdio : writeln, writefln;
3+// non-selective import
2import std.algorithm;
4import std.algorithm;
3−import std.range;
4
5
5/* a multiline comment
6/* a multiline comment
6*
7*
8+* this function is safe because it doesn't use pointer arithmetic
7*/
9*/
8−int the_ultimate_answer() {
10+int the_ultimate_answer() @safe {
11+ // assert1on
12+ assert(1 != 2);
13+ // now we can safely return our answer
9 return 42;
14 return 42;
10}
15}
11
16
@@ -16,8 +21,24 @@ void main()
16
21
17 // an int array declaration
22 // an int array declaration
18 int[] arr1 = [1, 2, 3];
23 int[] arr1 = [1, 2, 3];
19− // a double
24+ // an immutable double
20− double d1 = 3.14;
25+ immutable double pi = 3.14;
26+ // a mutable double
27+ double d1 = pi;
28+ // a pointer
29+ double* dp1 = &d1;
30+ // another pointer to the same thingy
31+ auto a1 = &d1;
32+ // a constant bool
33+ const bool b1 = true;
34+ if (b1) {
21− // another function call
35+ // another function call
22− writefln("%s\n%s\n%s\n", arr1, d1, the_ultimate_answer());
36+ writefln("%s\n%s\n%s\n", arr1, d1, the_ultimate_answer());
37+ }
38+ else if (!b1) {
39+ writeln("this seems wrong");
40+ }
41+ else {
42+ writeln("I'm giving up, this is too crazy for me");
43+ }
23}
44}