File tree Expand file tree Collapse file tree 2 files changed +76
-1
lines changed
branches/try2/src/test/run-pass Expand file tree Collapse file tree 2 files changed +76
-1
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
5
5
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
- refs/heads/try2: eb598e5344bde56b0ba12681e7d46c25b2dd1c88
8
+ refs/heads/try2: fe8e591147857a0f5ad10570e7cc3f304e9b2cd2
9
9
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
10
10
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
11
11
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Original file line number Diff line number Diff line change
1
+ // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // Test method calls with self as an argument
12
+
13
+ static mut COUNT : u64 = 1 ;
14
+
15
+ struct Foo ;
16
+
17
+ trait Bar {
18
+ fn foo1 ( & self ) ;
19
+ fn foo2 ( self ) ;
20
+ fn foo3 ( self : Box < Self > ) ;
21
+
22
+ fn bar1 ( & self ) {
23
+ unsafe { COUNT *= 7 ; }
24
+ }
25
+ fn bar2 ( self ) {
26
+ unsafe { COUNT *= 11 ; }
27
+ }
28
+ fn bar3 ( self : Box < Self > ) {
29
+ unsafe { COUNT *= 13 ; }
30
+ }
31
+ }
32
+
33
+ impl Bar for Foo {
34
+ fn foo1 ( & self ) {
35
+ unsafe { COUNT *= 2 ; }
36
+ }
37
+
38
+ fn foo2 ( self ) {
39
+ unsafe { COUNT *= 3 ; }
40
+ }
41
+
42
+ fn foo3 ( self : Box < Foo > ) {
43
+ unsafe { COUNT *= 5 ; }
44
+ }
45
+ }
46
+
47
+ impl Foo {
48
+ fn baz ( self ) {
49
+ unsafe { COUNT *= 17 ; }
50
+ // Test internal call.
51
+ Bar :: foo1 ( & self ) ;
52
+ Bar :: foo2 ( self ) ;
53
+ Bar :: foo3 ( box self ) ;
54
+
55
+ Bar :: bar1 ( & self ) ;
56
+ Bar :: bar2 ( self ) ;
57
+ Bar :: bar3 ( box self ) ;
58
+ }
59
+ }
60
+
61
+ fn main ( ) {
62
+ let x = Foo ;
63
+ // Test external call.
64
+ Bar :: foo1 ( & x) ;
65
+ Bar :: foo2 ( x) ;
66
+ Bar :: foo3 ( box x) ;
67
+
68
+ Bar :: bar1 ( & x) ;
69
+ Bar :: bar2 ( x) ;
70
+ Bar :: bar3 ( box x) ;
71
+
72
+ x. baz ( ) ;
73
+
74
+ unsafe { assert ! ( COUNT == 2u64 * 2 * 3 * 3 * 5 * 5 * 7 * 7 * 11 * 11 * 13 * 13 * 17 ) ; }
75
+ }
You can’t perform that action at this time.
0 commit comments