scripts/CodeMirror/mode/rust/test.js (view raw)
1// CodeMirror, copyright (c) by Marijn Haverbeke and others
2// Distributed under an MIT license: https://codemirror.net/LICENSE
3
4(function() {
5 var mode = CodeMirror.getMode({indentUnit: 4}, "rust");
6 function MT(name) {test.mode(name, mode, Array.prototype.slice.call(arguments, 1));}
7
8 MT('integer_test',
9 '[number 123i32]',
10 '[number 123u32]',
11 '[number 123_u32]',
12 '[number 0xff_u8]',
13 '[number 0o70_i16]',
14 '[number 0b1111_1111_1001_0000_i32]',
15 '[number 0usize]');
16
17 MT('float_test',
18 '[number 123.0f64]',
19 '[number 0.1f64]',
20 '[number 0.1f32]',
21 '[number 12E+99_f64]');
22
23 MT('string-literals-test',
24 '[string "foo"]',
25 '[string r"foo"]',
26 '[string "\\"foo\\""]',
27 '[string r#""foo""#]',
28 '[string "foo #\\"# bar"]',
29
30 '[string b"foo"]',
31 '[string br"foo"]',
32 '[string b"\\"foo\\""]',
33 '[string br#""foo""#]',
34 '[string br##"foo #" bar"##]',
35
36 "[string-2 'h']",
37 "[string-2 b'h']");
38
39})();