diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-07-27 01:33:01 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-07-27 18:56:16 +0300 |
| commit | 9be35f82c1abf2ecbab489bca9eca138ea648312 (patch) | |
| tree | 69888506e34af447d9748c0d542de3ba1dd76210 /src/test/ui/methods/auxiliary | |
| parent | ca9faa52f5ada0054b1fa27d97aedf448afb059b (diff) | |
| download | rust-9be35f82c1abf2ecbab489bca9eca138ea648312.tar.gz rust-9be35f82c1abf2ecbab489bca9eca138ea648312.zip | |
tests: Move run-pass tests without naming conflicts to ui
Diffstat (limited to 'src/test/ui/methods/auxiliary')
| -rw-r--r-- | src/test/ui/methods/auxiliary/method_self_arg1.rs | 37 | ||||
| -rw-r--r-- | src/test/ui/methods/auxiliary/method_self_arg2.rs | 54 |
2 files changed, 91 insertions, 0 deletions
diff --git a/src/test/ui/methods/auxiliary/method_self_arg1.rs b/src/test/ui/methods/auxiliary/method_self_arg1.rs new file mode 100644 index 00000000000..8258fdd9ab9 --- /dev/null +++ b/src/test/ui/methods/auxiliary/method_self_arg1.rs @@ -0,0 +1,37 @@ +#![crate_type = "lib"] + +#![feature(box_syntax)] + +static mut COUNT: u64 = 1; + +pub fn get_count() -> u64 { unsafe { COUNT } } + +#[derive(Copy, Clone)] +pub struct Foo; + +impl Foo { + pub fn foo(self, x: &Foo) { + unsafe { COUNT *= 2; } + // Test internal call. + Foo::bar(&self); + Foo::bar(x); + + Foo::baz(self); + Foo::baz(*x); + + Foo::qux(box self); + Foo::qux(box *x); + } + + pub fn bar(&self) { + unsafe { COUNT *= 3; } + } + + pub fn baz(self) { + unsafe { COUNT *= 5; } + } + + pub fn qux(self: Box<Foo>) { + unsafe { COUNT *= 7; } + } +} diff --git a/src/test/ui/methods/auxiliary/method_self_arg2.rs b/src/test/ui/methods/auxiliary/method_self_arg2.rs new file mode 100644 index 00000000000..94a4a016c3e --- /dev/null +++ b/src/test/ui/methods/auxiliary/method_self_arg2.rs @@ -0,0 +1,54 @@ +#![crate_type = "lib"] + +#![feature(box_syntax)] + +static mut COUNT: u64 = 1; + +pub fn get_count() -> u64 { unsafe { COUNT } } + +#[derive(Copy, Clone)] +pub struct Foo; + +impl Foo { + pub fn run_trait(self) { + unsafe { COUNT *= 17; } + // Test internal call. + Bar::foo1(&self); + Bar::foo2(self); + Bar::foo3(box self); + + Bar::bar1(&self); + Bar::bar2(self); + Bar::bar3(box self); + } +} + +pub trait Bar : Sized { + fn foo1(&self); + fn foo2(self); + fn foo3(self: Box<Self>); + + fn bar1(&self) { + unsafe { COUNT *= 7; } + } + fn bar2(self) { + unsafe { COUNT *= 11; } + } + fn bar3(self: Box<Self>) { + unsafe { COUNT *= 13; } + } +} + +impl Bar for Foo { + fn foo1(&self) { + unsafe { COUNT *= 2; } + } + + fn foo2(self) { + unsafe { COUNT *= 3; } + } + + fn foo3(self: Box<Foo>) { + unsafe { COUNT *= 5; } + } +} |
