on master help sign in
#1213 expanded D test file
commit5b2da2b08d5f34ca8e0fdf133f081f9b97c7bf92 authorFrank Schmitt <frankschmitt@gmx.de> dateMon 19 Oct 2020, 23:03 (6 years ago) parent5e0a608
2 files changed+56−14
tests/syntax-tests/highlighted/D/test.d+28−7 tests/syntax-tests/source/D/test.d+28−7
tests/syntax-tests/highlighted/D/test.d+28−7
@@ -1,11 +1,16 @@
1−import std.stdio;
1+// selective import
2+import std.stdio : writeln, writefln;
3+// non-selective import
24import std.algorithm;
3−import std.range;
45
56/* a multiline comment
67*
8+* this function is safe because it doesn't use pointer arithmetic
79*/
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 
914 return 42;
1015}
1116
@@ -16,8 +21,24 @@
1621
1722 // an int array declaration
1823 int[] arr1 = [1, 2, 3];
19− // a double
20− double d1 = 3.14;
21− // another function call 
22− writefln("%s\n%s\n%s\n", arr1, d1, the_ultimate_answer());
24+ // an immutable double
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) {
35+ // another function call 
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+ }
2344}
tests/syntax-tests/source/D/test.d+28−7
@@ -1,11 +1,16 @@
1−import std.stdio;
1+// selective import
2+import std.stdio : writeln, writefln;
3+// non-selective import
24import std.algorithm;
3−import std.range;
45
56/* a multiline comment
67*
8+* this function is safe because it doesn't use pointer arithmetic
79*/
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
914 return 42;
1015}
1116
@@ -16,8 +21,24 @@ void main()
1621
1722 // an int array declaration
1823 int[] arr1 = [1, 2, 3];
19− // a double
20− double d1 = 3.14;
21− // another function call
22− writefln("%s\n%s\n%s\n", arr1, d1, the_ultimate_answer());
24+ // an immutable double
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) {
35+ // another function call
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+ }
2344}