]> git.lizzy.rs Git - rust.git/blob - tests/ui-fulldeps/fluent-messages/test.rs
make more pleasant to read
[rust.git] / tests / ui-fulldeps / fluent-messages / test.rs
1 // normalize-stderr-test "note.*" -> "note: os-specific message"
2
3 #![feature(rustc_private)]
4 #![crate_type = "lib"]
5
6 extern crate rustc_macros;
7 use rustc_macros::fluent_messages;
8
9 /// Copy of the relevant `DiagnosticMessage` variant constructed by `fluent_messages` as it
10 /// expects `crate::DiagnosticMessage` to exist.
11 pub enum DiagnosticMessage {
12     FluentIdentifier(std::borrow::Cow<'static, str>, Option<std::borrow::Cow<'static, str>>),
13 }
14
15 /// Copy of the relevant `SubdiagnosticMessage` variant constructed by `fluent_messages` as it
16 /// expects `crate::SubdiagnosticMessage` to exist.
17 pub enum SubdiagnosticMessage {
18     FluentAttr(std::borrow::Cow<'static, str>),
19 }
20
21 mod missing_absolute {
22     use super::fluent_messages;
23
24     fluent_messages! {
25         missing_absolute => "/definitely_does_not_exist.ftl",
26 //~^ ERROR could not open Fluent resource
27     }
28 }
29
30 mod missing_relative {
31     use super::fluent_messages;
32
33     fluent_messages! {
34         missing_relative => "../definitely_does_not_exist.ftl",
35 //~^ ERROR could not open Fluent resource
36     }
37 }
38
39 mod missing_message {
40     use super::fluent_messages;
41
42     fluent_messages! {
43         missing_message => "./missing-message.ftl",
44 //~^ ERROR could not parse Fluent resource
45     }
46 }
47
48 mod duplicate {
49     use super::fluent_messages;
50
51     fluent_messages! {
52 //~^ ERROR the name `a_b_key` is defined multiple times
53         a => "./duplicate-a.ftl",
54         a_b => "./duplicate-a-b.ftl",
55 //~^ ERROR overrides existing message: `a_b_key`
56     }
57 }
58
59 mod slug_with_hyphens {
60     use super::fluent_messages;
61
62     fluent_messages! {
63         slug_with_hyphens => "./slug-with-hyphens.ftl",
64 //~^ ERROR name `slug_with_hyphens_this-slug-has-hyphens` contains a '-' character
65     }
66 }
67
68 mod label_with_hyphens {
69     use super::fluent_messages;
70
71     fluent_messages! {
72         label_with_hyphens => "./label-with-hyphens.ftl",
73 //~^ ERROR attribute `label-has-hyphens` contains a '-' character
74     }
75 }
76
77 mod valid {
78     use super::fluent_messages;
79
80     fluent_messages! {
81         valid => "./valid.ftl",
82     }
83
84     use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, valid_key};
85 }
86
87 mod missing_crate_name {
88     use super::fluent_messages;
89
90     fluent_messages! {
91         test_crate => "./missing-crate-name.ftl",
92 //~^ ERROR name `test-crate_foo` contains a '-' character
93 //~| ERROR name `with-hyphens` contains a '-' character
94 //~| ERROR name `with-hyphens` does not start with the crate name
95     }
96
97     use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, test_crate_foo, with_hyphens};
98 }