Skip to content

Commit 63537ff

Browse files
committed
Introduce three SpecTypes: COMPILE, RUN, FAIL
1 parent fd423bc commit 63537ff

File tree

5 files changed

+45
-36
lines changed

5 files changed

+45
-36
lines changed

dspec_tester.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ int main(string[] args)
118118

119119
alias SpecType = Tuple!(string, "key", CompileConfig.TestMode, "mode");
120120
auto specTypes = [
121-
SpecType("$(SPEC_RUNNABLE_EXAMPLE", CompileConfig.TestMode.compile),
121+
SpecType("$(SPEC_RUNNABLE_EXAMPLE_COMPILE", CompileConfig.TestMode.compile),
122122
SpecType("$(SPEC_RUNNABLE_EXAMPLE_RUN", CompileConfig.TestMode.run),
123123
SpecType("$(SPEC_RUNNABLE_EXAMPLE_FAIL", CompileConfig.TestMode.fail),
124124
];

ebook.ddoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ RUNNABLE_EXAMPLE=$0
5858
RUNNABLE_EXAMPLE_STDIN=
5959
RUNNABLE_EXAMPLE_ARGS=
6060
SPEC_RUNNABLE_EXAMPLE=$0
61+
SPEC_RUNNABLE_EXAMPLE_COMPILE=$0
62+
SPEC_RUNNABLE_EXAMPLE_RUN=$0
63+
SPEC_RUNNABLE_EXAMPLE_FAIL=$0
6164
SPEC_SUBNAV_NEXT=
6265
SPEC_SUBNAV_PREV_NEXT=
6366
SPEC_SUBNAV_PREV=

latex.ddoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ SHY=\-
263263
SINGLEQUOTE=`$0'
264264
SMALL=\small{$0}
265265
SPEC_RUNNABLE_EXAMPLE=$0
266+
SPEC_RUNNABLE_EXAMPLE_COMPILE=$0
267+
SPEC_RUNNABLE_EXAMPLE_RUN=$0
268+
SPEC_RUNNABLE_EXAMPLE_FAIL=$0
266269
SPEC_S=$(LAYOUT , $1, $(ARGS $+))
267270
SPEC_SUBNAV_NEXT=
268271
SPEC_SUBNAV_PREV=

spec/function.dd

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ pure int foo(int i,
252252
references of the result may be assumed to not refer to any object that
253253
existed before the function call. For example:)
254254

255-
$(SPEC_RUNNABLE_EXAMPLE
255+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
256256
---
257257
struct List { int payload; List* next; }
258258
pure List* make(int a, int b)
@@ -322,7 +322,7 @@ $(H2 $(LNAME2 auto-functions, Auto Functions))
322322
If there are no $(I ReturnStatement)s, the return type is inferred
323323
to be $(D_KEYWORD void).)
324324

325-
$(SPEC_RUNNABLE_EXAMPLE
325+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
326326
---
327327
auto foo(int x) { return x + 3; } // inferred to be int
328328
auto bar(int x) { return x; return 2.5; } // inferred to be double
@@ -337,7 +337,7 @@ $(H2 $(LNAME2 auto-ref-functions, Auto Ref Functions))
337337
if all return expressions are lvalues,
338338
and it would not be a reference to a local or a parameter.)
339339

340-
$(SPEC_RUNNABLE_EXAMPLE
340+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
341341
---
342342
auto ref f1(int x) { return x; } // value return
343343
auto ref f2() { return 3; } // value return
@@ -350,7 +350,7 @@ $(H2 $(LNAME2 auto-ref-functions, Auto Ref Functions))
350350
$(P The ref-ness of a function is determined from all
351351
$(GLINK2 statement, ReturnStatement)s in the function body:)
352352

353-
$(SPEC_RUNNABLE_EXAMPLE
353+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
354354
---
355355
auto ref f1(ref int x) { return 3; return x; } // ok, value return
356356
auto ref f2(ref int x) { return x; return 3; } // ok, value return
@@ -375,7 +375,7 @@ $(H2 $(LNAME2 inout-functions, Inout Functions))
375375
$(P Functions that deal with mutable, const, or immutable types with
376376
equanimity often need to transmit their type to the return value:)
377377

378-
$(SPEC_RUNNABLE_EXAMPLE
378+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
379379
---
380380
int[] f1(int[] a, int x, int y) { return a[x .. y]; }
381381

@@ -389,7 +389,7 @@ $(H2 $(LNAME2 inout-functions, Inout Functions))
389389
To indicate that these can be one function, the $(D_KEYWORD inout)
390390
type constructor is employed:)
391391

392-
$(SPEC_RUNNABLE_EXAMPLE
392+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
393393
---
394394
inout(int)[] foo(inout(int)[] a, int x, int y) { return a[x .. y]; }
395395
---
@@ -433,7 +433,7 @@ $(H2 $(LNAME2 inout-functions, Inout Functions))
433433
$(P The inout in the return type is then rewritten to be the inout matched
434434
qualifiers:)
435435

436-
$(SPEC_RUNNABLE_EXAMPLE
436+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
437437
---
438438
int[] ma;
439439
const(int)[] ca;
@@ -485,7 +485,7 @@ $(H2 $(LNAME2 optional-parenthesis, Optional Parentheses))
485485
$(RELATIVE_LINK2 property-functions, property function).
486486
)
487487

488-
$(SPEC_RUNNABLE_EXAMPLE
488+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
489489
---
490490
void foo() {} // no arguments
491491
void fun(int x = 10) { }
@@ -523,7 +523,7 @@ $(H2 $(LNAME2 optional-parenthesis, Optional Parentheses))
523523
returned value is to be called.
524524
)
525525

526-
$(SPEC_RUNNABLE_EXAMPLE
526+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
527527
---
528528
struct S {
529529
int function() callfp() { return &numfp; }
@@ -592,7 +592,7 @@ $(H2 $(LNAME2 property-functions, Property Functions))
592592
$(P A simple property would be:)
593593

594594

595-
$(SPEC_RUNNABLE_EXAMPLE
595+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
596596
---
597597
struct Foo
598598
{
@@ -704,7 +704,7 @@ void func()
704704
that is derived from the type returned by the overridden function:
705705
)
706706

707-
$(SPEC_RUNNABLE_EXAMPLE
707+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
708708
------
709709
class A { }
710710
class B : A { }
@@ -731,7 +731,7 @@ class Bar : Foo
731731
base class name before the member function name. For example:
732732
)
733733

734-
$(SPEC_RUNNABLE_EXAMPLE
734+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
735735
------
736736
class B
737737
{
@@ -924,7 +924,7 @@ void test()
924924
$(GLINK FunctionAttributes), the missing attributes will be
925925
automatically compensated by the compiler.)
926926

927-
$(SPEC_RUNNABLE_EXAMPLE
927+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
928928
------
929929
class B
930930
{
@@ -951,7 +951,7 @@ void main()
951951
when it is virtual.
952952
)
953953

954-
$(SPEC_RUNNABLE_EXAMPLE
954+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
955955
------
956956
class B
957957
{
@@ -1055,7 +1055,7 @@ $(H3 $(LNAME2 overload-sets, Overload Sets))
10551055
at module level:
10561056
)
10571057

1058-
$(SPEC_RUNNABLE_EXAMPLE
1058+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
10591059
---
10601060
module A;
10611061
void foo() { }
@@ -1067,7 +1067,7 @@ void foo(long i) { }
10671067
A different module can also define functions with the same name:
10681068
)
10691069

1070-
$(SPEC_RUNNABLE_EXAMPLE
1070+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
10711071
---
10721072
module B;
10731073
class C { }
@@ -1166,7 +1166,7 @@ int foo(in int x, out int y, ref int z, int q);
11661166
$(TROW $(D inout), argument is implicitly converted to an inout type)
11671167
)
11681168

1169-
$(SPEC_RUNNABLE_EXAMPLE
1169+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
11701170
------
11711171
void foo(out int x)
11721172
{
@@ -1208,7 +1208,7 @@ def(z);
12081208
a $(D lazy) argument can be executed 0 or more times. A $(D lazy) parameter
12091209
cannot be an lvalue.)
12101210

1211-
$(SPEC_RUNNABLE_EXAMPLE
1211+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
12121212
---
12131213
void dotimes(int n, lazy void exp)
12141214
{
@@ -1374,7 +1374,7 @@ $(H4 $(LNAME2 d_style_variadic_functions, D-style Variadic Functions))
13741374
It has D linkage, and need not have any non-variadic parameters
13751375
declared:)
13761376

1377-
$(SPEC_RUNNABLE_EXAMPLE
1377+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
13781378
------
13791379
int abc(char c, ...); // one required parameter: c
13801380
int def(...); // ok
@@ -1416,7 +1416,7 @@ void foo(int x, int y, ...)
14161416
$(D _arguments) gives the number of arguments and the type
14171417
of each, enabling type safety to be checked at run time.)
14181418

1419-
$(SPEC_RUNNABLE_EXAMPLE
1419+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
14201420
------
14211421
import std.stdio;
14221422
import core.vararg;
@@ -1500,7 +1500,7 @@ $(H4 $(LNAME2 typesafe_variadic_functions, Typesafe Variadic Functions))
15001500

15011501
$(P For arrays:)
15021502

1503-
$(SPEC_RUNNABLE_EXAMPLE
1503+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
15041504
------
15051505
int main()
15061506
{
@@ -1681,7 +1681,7 @@ $(H3 $(LEGACY_LNAME2 Local Static Variables, local-static-variables, Local Stati
16811681
As such, their value persists beyond the exit of the function.
16821682
)
16831683

1684-
$(SPEC_RUNNABLE_EXAMPLE
1684+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
16851685
---
16861686
void foo()
16871687
{
@@ -1717,7 +1717,7 @@ $(H2 $(LNAME2 nested, Nested Functions))
17171717

17181718
$(P Functions may be nested within other functions:)
17191719

1720-
$(SPEC_RUNNABLE_EXAMPLE
1720+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
17211721
------
17221722
int bar(int a)
17231723
{
@@ -1789,7 +1789,7 @@ void test()
17891789
This access includes both the ability to read and write them.
17901790
)
17911791

1792-
$(SPEC_RUNNABLE_EXAMPLE
1792+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
17931793
------
17941794
int bar(int a)
17951795
{
@@ -1815,7 +1815,7 @@ void test()
18151815

18161816
$(P This access can span multiple nesting levels:)
18171817

1818-
$(SPEC_RUNNABLE_EXAMPLE
1818+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
18191819
------
18201820
int bar(int a)
18211821
{
@@ -1857,7 +1857,7 @@ int bar(int a)
18571857

18581858
$(P Functions can be nested within member functions:)
18591859

1860-
$(SPEC_RUNNABLE_EXAMPLE
1860+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
18611861
------
18621862
struct Foo
18631863
{
@@ -1915,7 +1915,7 @@ void test()
19151915
$(LI Declare one or more of the functions to be function templates
19161916
even if they take no specific template arguments:)
19171917

1918-
$(SPEC_RUNNABLE_EXAMPLE
1918+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
19191919
------
19201920
void test()
19211921
{
@@ -1927,7 +1927,7 @@ void test()
19271927

19281928
$(LI Declare the functions inside of a mixin template:)
19291929

1930-
$(SPEC_RUNNABLE_EXAMPLE
1930+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
19311931
------
19321932
mixin template T()
19331933
{
@@ -1944,7 +1944,7 @@ void main()
19441944

19451945
$(LI Use a delegate:)
19461946

1947-
$(SPEC_RUNNABLE_EXAMPLE
1947+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
19481948
------
19491949
void test()
19501950
{
@@ -1964,7 +1964,7 @@ $(H2 $(LNAME2 closures, Delegates, Function Pointers, and Closures))
19641964

19651965
$(P A function pointer can point to a static nested function:)
19661966

1967-
$(SPEC_RUNNABLE_EXAMPLE
1967+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
19681968
------
19691969
int function() fp;
19701970

@@ -1989,7 +1989,7 @@ void bar()
19891989
distinct function pointer values. The compiler is free to merge
19901990
functions bodies into one if they compile to identical code.)
19911991

1992-
$(SPEC_RUNNABLE_EXAMPLE
1992+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
19931993
------
19941994
int abc(int x) { return x + 1; }
19951995
int def(int y) { return y + 1; }
@@ -2003,7 +2003,7 @@ int delegate(int) fp2 = &def;
20032003

20042004
$(P A delegate can be set to a non-static nested function:)
20052005

2006-
$(SPEC_RUNNABLE_EXAMPLE
2006+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
20072007
------
20082008
int delegate() dg;
20092009

@@ -2047,7 +2047,7 @@ int* bar()
20472047
the same type:
20482048
)
20492049

2050-
$(SPEC_RUNNABLE_EXAMPLE
2050+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
20512051
------
20522052
struct Foo
20532053
{
@@ -2118,7 +2118,7 @@ $(H2 $(LNAME2 function-templates, Function Templates))
21182118
For example:
21192119
)
21202120

2121-
$(SPEC_RUNNABLE_EXAMPLE
2121+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
21222122
---
21232123
// Only one copy of func needs to be written
21242124
void func(T)(T x)
@@ -2260,7 +2260,7 @@ static assert(countTen(12) == 12); // invalid, modifies y.
22602260
$(LI argument for a template value parameter)
22612261
)
22622262

2263-
$(SPEC_RUNNABLE_EXAMPLE
2263+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
22642264
---
22652265
template eval( A... )
22662266
{

spec/spec.ddoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ $(SUBNAV_TEMPLATE
8989
)
9090
)
9191
SPEC_RUNNABLE_EXAMPLE=$(RUNNABLE_EXAMPLE $0)
92+
SPEC_RUNNABLE_EXAMPLE_COMPILE=$(RUNNABLE_EXAMPLE $0)
93+
SPEC_RUNNABLE_EXAMPLE_FAIL=$(RUNNABLE_EXAMPLE $0)
94+
SPEC_RUNNABLE_EXAMPLE_RUN=$(RUNNABLE_EXAMPLE $0)
9295
SPEC_SUBNAV_NEXT=
9396
$(SPEC_NEXT $(LINK2 $(ROOT_DIR)spec/$1.html, $2))
9497
$(CLEAR)

0 commit comments

Comments
 (0)