]>
Commit | Line | Data |
---|---|---|
eb39fafa DC |
1 | /** |
2 | * @fileoverview Tests for no-octal rule. | |
3 | * @author Ilya Volodin | |
4 | */ | |
5 | ||
6 | "use strict"; | |
7 | ||
8 | //------------------------------------------------------------------------------ | |
9 | // Requirements | |
10 | //------------------------------------------------------------------------------ | |
11 | ||
12 | const rule = require("../../../lib/rules/no-octal"), | |
13 | { RuleTester } = require("../../../lib/rule-tester"); | |
14 | ||
15 | //------------------------------------------------------------------------------ | |
16 | // Tests | |
17 | //------------------------------------------------------------------------------ | |
18 | ||
19 | const ruleTester = new RuleTester(); | |
20 | ||
21 | ruleTester.run("no-octal", rule, { | |
22 | valid: [ | |
23 | "var a = 'hello world';", | |
24 | "0x1234", | |
25 | "0X5;", | |
26 | "a = 0;", | |
27 | "0.1", | |
28 | "0.5e1" | |
29 | ], | |
30 | invalid: [ | |
31 | { | |
32 | code: "var a = 01234;", | |
33 | errors: [{ | |
8f9d1d4d | 34 | messageId: "noOctal", |
eb39fafa DC |
35 | type: "Literal" |
36 | }] | |
37 | }, | |
38 | { | |
39 | code: "a = 1 + 01234;", | |
40 | errors: [{ | |
8f9d1d4d | 41 | messageId: "noOctal", |
eb39fafa DC |
42 | type: "Literal" |
43 | }] | |
44 | }, | |
45 | { | |
46 | code: "00", | |
47 | errors: [{ | |
8f9d1d4d | 48 | messageId: "noOctal", |
eb39fafa DC |
49 | type: "Literal" |
50 | }] | |
51 | }, | |
52 | { | |
53 | code: "08", | |
54 | errors: [{ | |
8f9d1d4d | 55 | messageId: "noOctal", |
eb39fafa DC |
56 | type: "Literal" |
57 | }] | |
58 | }, | |
59 | { | |
60 | code: "09.1", | |
61 | errors: [{ | |
8f9d1d4d | 62 | messageId: "noOctal", |
eb39fafa DC |
63 | type: "Literal" |
64 | }] | |
65 | }, | |
66 | { | |
67 | code: "09e1", | |
68 | errors: [{ | |
8f9d1d4d | 69 | messageId: "noOctal", |
eb39fafa DC |
70 | type: "Literal" |
71 | }] | |
72 | }, | |
73 | { | |
74 | code: "09.1e1", | |
75 | errors: [{ | |
8f9d1d4d | 76 | messageId: "noOctal", |
eb39fafa DC |
77 | type: "Literal" |
78 | }] | |
79 | }, | |
80 | { | |
81 | code: "018", | |
82 | errors: [{ | |
8f9d1d4d | 83 | messageId: "noOctal", |
eb39fafa DC |
84 | type: "Literal" |
85 | }] | |
86 | }, | |
87 | { | |
88 | code: "019.1", | |
89 | errors: [{ | |
8f9d1d4d | 90 | messageId: "noOctal", |
eb39fafa DC |
91 | type: "Literal" |
92 | }] | |
93 | }, | |
94 | { | |
95 | code: "019e1", | |
96 | errors: [{ | |
8f9d1d4d | 97 | messageId: "noOctal", |
eb39fafa DC |
98 | type: "Literal" |
99 | }] | |
100 | }, | |
101 | { | |
102 | code: "019.1e1", | |
103 | errors: [{ | |
8f9d1d4d | 104 | messageId: "noOctal", |
eb39fafa DC |
105 | type: "Literal" |
106 | }] | |
107 | } | |
108 | ] | |
109 | }); |