Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
TurkeyMan committed Nov 17, 2024
1 parent 7feff96 commit 044da06
Show file tree
Hide file tree
Showing 23 changed files with 32 additions and 154 deletions.
2 changes: 1 addition & 1 deletion compiler/test/compilable/fix21647.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
REQUIRED_ARGS: -preview=rvaluerefparam
REQUIRED_ARGS:
TEST_OUTPUT:
---
cast(void)0
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/compilable/issue20704.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
https://issues.dlang.org/show_bug.cgi?id=20704
REQUIRED_ARGS: -preview=rvaluerefparam
REQUIRED_ARGS:
*/

void f1(T)(const auto ref T arg = T.init) {}
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/compilable/issue20705.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRED_ARGS: -preview=rvaluerefparam
// REQUIRED_ARGS:
struct Foo
{
int[] a;
Expand Down
1 change: 0 additions & 1 deletion compiler/test/compilable/previewhelp.d
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Upcoming language changes listed by -preview=name:
=bitfields add C-like bitfields (https://github.com/dlang/dlang.org/pull/3190)
=fieldwise use fieldwise comparisons for struct equality (https://dlang.org/changelog/2.085.0.html#no-cmpsb)
=fixAliasThis when a symbol is resolved, check alias this scope before going to upper scopes (https://github.com/dlang/dmd/pull/8885)
=rvaluerefparam enable rvalue arguments to ref parameters (https://gist.github.com/andralex/e5405a5d773f07f73196c05f8339435a)
=nosharedaccess disable access to shared memory objects (https://dlang.org/spec/const3.html#shared)
=in `in` on parameters means `scope const [ref]` and accepts rvalues (https://dlang.org/spec/function.html#in-params)
=inclusiveincontracts 'in' contracts of overridden methods must be a superset of parent contract (https://dlang.org/changelog/2.095.0.html#inclusive-incontracts)
Expand Down
1 change: 1 addition & 0 deletions compiler/test/compilable/reverthelp.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ Revertable language changes listed by -revert=name:
=dip1000 revert DIP1000 changes (Scoped Pointers) (https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1000.md)
=intpromote revert integral promotions for unary + - ~ operators
=dtorfields don't destruct fields of partially constructed objects
=rvaluerefparam revert rvalue arguments to ref parameters (https://gist.github.com/andralex/e5405a5d773f07f73196c05f8339435a)
----
*/
2 changes: 1 addition & 1 deletion compiler/test/compilable/rvalueref.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* REQUIRED_ARGS: -preview=rvaluerefparam
/* REQUIRED_ARGS:
*/

struct AS
Expand Down
20 changes: 7 additions & 13 deletions compiler/test/fail_compilation/b20011.d
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
/*
TEST_OUTPUT:
---
fail_compilation/b20011.d(28): Error: cannot modify expression `S1(cast(ubyte)0u).member` because it is not an lvalue
fail_compilation/b20011.d(31): Error: cannot modify expression `S2(null).member` because it is not an lvalue
fail_compilation/b20011.d(32): Error: cannot modify expression `S2(null).member` because it is not an lvalue
fail_compilation/b20011.d(35): Error: cannot modify expression `U1(cast(ubyte)0u, ).m2` because it is not an lvalue
fail_compilation/b20011.d(40): Error: function `assignableByRef` is not callable using argument types `(ubyte)`
fail_compilation/b20011.d(40): cannot pass rvalue argument `S1(cast(ubyte)0u).member` of type `ubyte` to parameter `ref ubyte p`
fail_compilation/b20011.d(37): `b20011.main.assignableByRef(ref ubyte p)` declared here
fail_compilation/b20011.d(41): Error: function `assignableByOut` is not callable using argument types `(ubyte)`
fail_compilation/b20011.d(41): cannot pass rvalue argument `S1(cast(ubyte)0u).member` of type `ubyte` to parameter `out ubyte p`
fail_compilation/b20011.d(38): `b20011.main.assignableByOut(out ubyte p)` declared here
fail_compilation/b20011.d(42): Error: function `assignableByConstRef` is not callable using argument types `(ubyte)`
fail_compilation/b20011.d(42): cannot pass rvalue argument `S1(cast(ubyte)0u).member` of type `ubyte` to parameter `ref const(ubyte) p`
fail_compilation/b20011.d(39): `b20011.main.assignableByConstRef(ref const(ubyte) p)` declared here
fail_compilation/b20011.d(22): Error: cannot modify expression `S1(cast(ubyte)0u).member` because it is not an lvalue
fail_compilation/b20011.d(25): Error: cannot modify expression `S2(null).member` because it is not an lvalue
fail_compilation/b20011.d(26): Error: cannot modify expression `S2(null).member` because it is not an lvalue
fail_compilation/b20011.d(29): Error: cannot modify expression `U1(cast(ubyte)0u, ).m2` because it is not an lvalue
fail_compilation/b20011.d(35): Error: function `assignableByOut` is not callable using argument types `(ubyte)`
fail_compilation/b20011.d(35): cannot pass rvalue argument `S1(cast(ubyte)0u).member` of type `ubyte` to parameter `out ubyte p`
fail_compilation/b20011.d(32): `b20011.main.assignableByOut(out ubyte p)` declared here
---
*/
module b20011;
Expand Down
4 changes: 1 addition & 3 deletions compiler/test/fail_compilation/fail20183.d
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* REQUIRED_ARGS: -preview=dip1000
TEST_OUTPUT:
---
fail_compilation/fail20183.d(1016): Error: function `addr` is not callable using argument types `(int)`
fail_compilation/fail20183.d(1016): cannot pass rvalue argument `S(0).i` of type `int` to parameter `return ref int b`
fail_compilation/fail20183.d(1004): `fail20183.addr(return ref int b)` declared here
fail_compilation/fail20183.d(1016): Error: address of variable `__rvalue2` assigned to `p` with longer lifetime
fail_compilation/fail20183.d(1017): Error: address of expression temporary returned by `s()` assigned to `q` with longer lifetime
fail_compilation/fail20183.d(1018): Error: address of struct literal `S(0)` assigned to `r` with longer lifetime
---
Expand Down
7 changes: 0 additions & 7 deletions compiler/test/fail_compilation/fail7603a.d

This file was deleted.

2 changes: 1 addition & 1 deletion compiler/test/fail_compilation/fail7603b.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail7603b.d(7): Error: cannot create default argument for `ref` / `out` parameter from constant `true`
fail_compilation/fail7603b.d(7): Error: cannot create default argument for `out` parameter from constant `true`
---
*/
void test(out bool val = true) { }
8 changes: 0 additions & 8 deletions compiler/test/fail_compilation/fail7603c.d

This file was deleted.

10 changes: 0 additions & 10 deletions compiler/test/fail_compilation/fail9773.d

This file was deleted.

10 changes: 2 additions & 8 deletions compiler/test/fail_compilation/fail9891.d
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail9891.d(13): Error: expression `i` of type `immutable(int)` is not implicitly convertible to type `ref int` of parameter `n`
fail_compilation/fail9891.d(18): Error: expression `i` of type `immutable(int)` is not implicitly convertible to type `out int` of parameter `n`
fail_compilation/fail9891.d(23): Error: cannot create default argument for `ref` / `out` parameter from expression `prop()` because it is not an lvalue
fail_compilation/fail9891.d(12): Error: expression `i` of type `immutable(int)` is not implicitly convertible to type `ref int` of parameter `n`
fail_compilation/fail9891.d(17): Error: expression `i` of type `immutable(int)` is not implicitly convertible to type `out int` of parameter `n`
---
*/

Expand All @@ -19,8 +18,3 @@ void f2(out int n = i)
{
++n;
}

void f3(ref int n = prop)
{
++n;
}
39 changes: 0 additions & 39 deletions compiler/test/fail_compilation/issue20704.d

This file was deleted.

30 changes: 0 additions & 30 deletions compiler/test/fail_compilation/test21807.d
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,3 @@ class Foo
ca = getSArray();
}
}

/*
TEST_OUTPUT:
---
fail_compilation/test21807.d(117): Error: function `addr` is not callable using argument types `(int)`
fail_compilation/test21807.d(117): cannot pass rvalue argument `S(0).i` of type `int` to parameter `return ref int b`
fail_compilation/test21807.d(106): `test21807.addr(return ref int b)` declared here
---
*/
#line 100

struct S
{
int i;
}

int* addr(return ref int b)
{
return &b;
}

class Foo2
{
int* ptr;

this()
{
ptr = addr(S().i); // struct temporary
}
}
28 changes: 9 additions & 19 deletions compiler/test/fail_compilation/tolvalue.d
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
/**
TEST_OUTPUT:
---
fail_compilation/tolvalue.d(28): Error: cannot take address of template `templateFunc(T)()`, perhaps instantiate it first
fail_compilation/tolvalue.d(29): Error: cannot take address of type `int`
fail_compilation/tolvalue.d(30): Error: cannot take address of constant `3`
fail_compilation/tolvalue.d(31): Error: cannot take address of operator `$`
fail_compilation/tolvalue.d(32): Error: cannot take address of compiler-generated variable `__ctfe`
fail_compilation/tolvalue.d(33): Error: cannot take address of manifest constant `f`
fail_compilation/tolvalue.d(38): Error: cannot create default argument for `ref` / `out` parameter from constant `3`
fail_compilation/tolvalue.d(39): Error: cannot create default argument for `ref` / `out` parameter from compiler-generated variable `__ctfe`
fail_compilation/tolvalue.d(40): Error: cannot create default argument for `ref` / `out` parameter from manifest constant `f`
fail_compilation/tolvalue.d(45): Error: cannot modify constant `3`
fail_compilation/tolvalue.d(46): Error: cannot modify compiler-generated variable `__ctfe`
fail_compilation/tolvalue.d(47): Error: cannot modify manifest constant `f`
fail_compilation/tolvalue.d(25): Error: cannot take address of template `templateFunc(T)()`, perhaps instantiate it first
fail_compilation/tolvalue.d(26): Error: cannot take address of type `int`
fail_compilation/tolvalue.d(27): Error: cannot take address of constant `3`
fail_compilation/tolvalue.d(28): Error: cannot take address of operator `$`
fail_compilation/tolvalue.d(29): Error: cannot take address of compiler-generated variable `__ctfe`
fail_compilation/tolvalue.d(30): Error: cannot take address of manifest constant `f`
fail_compilation/tolvalue.d(35): Error: cannot modify constant `3`
fail_compilation/tolvalue.d(36): Error: cannot modify compiler-generated variable `__ctfe`
fail_compilation/tolvalue.d(37): Error: cannot modify manifest constant `f`
---
*/

Expand All @@ -33,13 +30,6 @@ void addr()
auto x6 = &E.f;
}

void refArg()
{
void f0(ref int = 3) {}
void f1(ref bool = __ctfe) {}
void f3(ref E = E.f) {}
}

void inc(int lz)
{
3++;
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/runnable/overload.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
REQUIRED_ARGS: -preview=rvaluerefparam
REQUIRED_ARGS:
EXTRA_SOURCES: imports/ovs1528a.d imports/ovs1528b.d
EXTRA_SOURCES: imports/template_ovs1.d imports/template_ovs2.d imports/template_ovs3.d
EXTRA_FILES: imports/m8668a.d imports/m8668b.d imports/m8668c.d
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/runnable/structlit.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
REQUIRED_ARGS: -preview=rvaluerefparam
REQUIRED_ARGS:
RUN_OUTPUT:
---
Success
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/runnable/template9.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
REQUIRED_ARGS: -preview=rvaluerefparam
REQUIRED_ARGS:
PERMUTE_ARGS:
EXTRA_FILES: imports/testmangle.d
TEST_OUTPUT:
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/runnable/testassign.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
REQUIRED_ARGS: -preview=rvaluerefparam
REQUIRED_ARGS:
TEST_OUTPUT:
---
\ S1 S2a S2b S3a S3b S4a S4b
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/runnable/xtest46.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// REQUIRED_ARGS: -preview=rvaluerefparam
// REQUIRED_ARGS:
//
/* TEST_OUTPUT:
---
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/runnable/xtest46_gc.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
REQUIRED_ARGS: -lowmem -Jrunnable -preview=rvaluerefparam
REQUIRED_ARGS: -lowmem -Jrunnable
EXTRA_FILES: xtest46.d
TEST_OUTPUT:
---
Expand Down
6 changes: 1 addition & 5 deletions druntime/test/stdcpp/src/string_test.d
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ unittest
str = "Hello again with a long long string woo";
assert(sumOfElements_val(str) == 10935);
assert(sumOfElements_ref(str) == 3645);
//assert(str == std_string("Hello again with a long long string woo")); // Needs -preview=rvaluerefparam.
{
auto tmp = std_string("Hello again with a long long string woo"); // Workaround.
assert(str == tmp);
}
assert(str == std_string("Hello again with a long long string woo"));

std_string str2 = std_string(Default);
assert(str2.size == 0);
Expand Down

0 comments on commit 044da06

Please sign in to comment.