PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/src/test/run-pass/item-attributes.rs

http://github.com/jruderman/rust
Rust | 197 lines | 118 code | 38 blank | 41 comment | 0 complexity | fa54d86b96c99f14c50da8d8c4ec03b2 MD5 | raw file
  1// These are attributes of the implicit crate. Really this just needs to parse
  2// for completeness since .rs files linked from .rc files support this
  3// notation to specify their module's attributes
  4#[attr1 = "val"];
  5#[attr2 = "val"];
  6#[attr3];
  7#[attr4(attr5)];
  8
  9// Special linkage attributes for the crate
 10#[link(name = "std",
 11       vers = "0.1",
 12       uuid = "122bed0b-c19b-4b82-b0b7-7ae8aead7297",
 13       url = "http://rust-lang.org/src/std")];
 14
 15// These are are attributes of the following mod
 16#[attr1 = "val"]
 17#[attr2 = "val"]
 18mod test_first_item_in_file_mod { }
 19
 20mod test_single_attr_outer {
 21
 22    #[attr = "val"]
 23    const x: int = 10;
 24
 25    #[attr = "val"]
 26    fn f() { }
 27
 28    #[attr = "val"]
 29    mod mod1 { }
 30
 31    #[attr = "val"]
 32    #[abi = "cdecl"]
 33    extern mod rustrt { }
 34}
 35
 36mod test_multi_attr_outer {
 37
 38    #[attr1 = "val"]
 39    #[attr2 = "val"]
 40    const x: int = 10;
 41
 42    #[attr1 = "val"]
 43    #[attr2 = "val"]
 44    fn f() { }
 45
 46    #[attr1 = "val"]
 47    #[attr2 = "val"]
 48    mod mod1 { }
 49
 50    #[attr1 = "val"]
 51    #[attr2 = "val"]
 52    #[abi = "cdecl"]
 53    extern mod rustrt { }
 54
 55    #[attr1 = "val"]
 56    #[attr2 = "val"]
 57    type t = {x: int};
 58}
 59
 60mod test_stmt_single_attr_outer {
 61
 62    fn f() {
 63
 64        #[attr = "val"]
 65        const x: int = 10;
 66
 67        #[attr = "val"]
 68        fn f() { }
 69
 70        /* FIXME: Issue #493
 71        #[attr = "val"]
 72        mod mod1 {
 73        }
 74
 75        #[attr = "val"]
 76        #[abi = "cdecl"]
 77        extern mod rustrt {
 78        }
 79        */
 80    }
 81}
 82
 83mod test_stmt_multi_attr_outer {
 84
 85    fn f() {
 86
 87        #[attr1 = "val"]
 88        #[attr2 = "val"]
 89        const x: int = 10;
 90
 91        #[attr1 = "val"]
 92        #[attr2 = "val"]
 93        fn f() { }
 94
 95        /* FIXME: Issue #493
 96        #[attr1 = "val"]
 97        #[attr2 = "val"]
 98        mod mod1 {
 99        }
100
101        #[attr1 = "val"]
102        #[attr2 = "val"]
103        #[abi = "cdecl"]
104        extern mod rustrt {
105        }
106        */
107    }
108}
109
110mod test_attr_inner {
111
112    mod m {
113        // This is an attribute of mod m
114        #[attr = "val"];
115    }
116}
117
118mod test_attr_inner_then_outer {
119
120    mod m {
121        // This is an attribute of mod m
122        #[attr = "val"];
123        // This is an attribute of fn f
124        #[attr = "val"]
125        fn f() { }
126    }
127}
128
129mod test_attr_inner_then_outer_multi {
130    mod m {
131        // This is an attribute of mod m
132        #[attr1 = "val"];
133        #[attr2 = "val"];
134        // This is an attribute of fn f
135        #[attr1 = "val"]
136        #[attr2 = "val"]
137        fn f() { }
138    }
139}
140
141mod test_distinguish_syntax_ext {
142
143    use std;
144
145    fn f() {
146        fmt!{"test%s", ~"s"};
147        #[attr = "val"]
148        fn g() { }
149    }
150}
151
152mod test_other_forms {
153    #[attr]
154    #[attr(word)]
155    #[attr(attr(word))]
156    #[attr(key1 = "val", key2 = "val", attr)]
157    fn f() { }
158}
159
160mod test_foreign_items {
161    #[abi = "cdecl"]
162    extern mod rustrt {
163        #[attr];
164
165        #[attr]
166        fn get_task_id() -> libc::intptr_t;
167    }
168}
169
170mod test_literals {
171    #[str = "s"];
172    #[char = 'c'];
173    #[int = 100];
174    #[uint = 100u];
175    #[mach_int = 100u32];
176    #[float = 1.0];
177    #[mach_float = 1.0f32];
178    #[nil = ()];
179    #[bool = true];
180    mod m { }
181}
182
183fn test_fn_inner() {
184    #[inner_fn_attr];
185}
186
187fn main() { }
188
189//
190// Local Variables:
191// mode: rust
192// fill-column: 78;
193// indent-tabs-mode: nil
194// c-basic-offset: 4
195// buffer-file-coding-system: utf-8-unix
196// End:
197//