Skip to content

Commit 5627584

Browse files
authored
Merge pull request #1419 from plotly/more-syntax-tests
More syntax tests
2 parents 5406829 + 9f1c6c4 commit 5627584

File tree

79 files changed

+155
-96
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+155
-96
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
"open": "0.0.5",
126126
"prepend-file": "^1.3.1",
127127
"prettysize": "0.0.3",
128+
"read-last-lines": "^1.1.0",
128129
"requirejs": "^2.3.1",
129130
"through2": "^2.0.3",
130131
"uglify-js": "^2.7.5",

src/traces/parcoords/shaders/pick_vertex.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void main() {
5151
mat4 pB = mat4(p4, p5, p6, p7);
5252
mat4 pC = mat4(p8, p9, pa, pb);
5353
mat4 pD = mat4(pc, pd, pe, abs(pf));
54-
54+
5555
float show = float(mshow(pA, loA, hiA) &&
5656
mshow(pB, loB, hiB) &&
5757
mshow(pC, loC, hiC) &&

src/traces/parcoords/shaders/vertex.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void main() {
5151
mat4 pB = mat4(p4, p5, p6, p7);
5252
mat4 pC = mat4(p8, p9, pa, pb);
5353
mat4 pD = mat4(pc, pd, pe, abs(pf));
54-
54+
5555
float show = float(mshow(pA, loA, hiA) &&
5656
mshow(pB, loB, hiB) &&
5757
mshow(pC, loC, hiC) &&

tasks/test_syntax.js

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var fs = require('fs');
44
var falafel = require('falafel');
55
var glob = require('glob');
66
var madge = require('madge');
7+
var readLastLines = require('read-last-lines');
78

89
var constants = require('./util/constants');
910
var srcGlob = path.join(constants.pathToSrc, '**/*.js');
@@ -17,6 +18,7 @@ var EXIT_CODE = 0;
1718
assertJasmineSuites();
1819
assertSrcContents();
1920
assertFileNames();
21+
assertTrailingNewLine();
2022
assertCircularDeps();
2123

2224

@@ -90,24 +92,80 @@ function assertSrcContents() {
9092

9193
// check that all file names are in lower case
9294
function assertFileNames() {
95+
var pattern = combineGlobs([
96+
path.join(constants.pathToRoot, '*.*'),
97+
path.join(constants.pathToSrc, '**/*.*'),
98+
path.join(constants.pathToLib, '**/*.*'),
99+
path.join(constants.pathToDist, '**/*.*'),
100+
path.join(constants.pathToRoot, 'test', '**/*.*'),
101+
path.join(constants.pathToRoot, 'tasks', '**/*.*'),
102+
path.join(constants.pathToRoot, 'devtools', '**/*.*')
103+
]);
104+
93105
var logs = [];
94106

95-
glob(combineGlobs([srcGlob, libGlob, testGlob, bundleTestGlob]), function(err, files) {
107+
glob(pattern, function(err, files) {
96108
files.forEach(function(file) {
97109
var base = path.basename(file);
98110

111+
if(
112+
base === 'README.md' ||
113+
base === 'CONTRIBUTING.md' ||
114+
base === 'CHANGELOG.md' ||
115+
base === 'SECURITY.md' ||
116+
file.indexOf('mathjax') !== -1
117+
) return;
118+
99119
if(base !== base.toLowerCase()) {
100120
logs.push([
101-
file, ' :',
121+
file, ':',
102122
'has a file name containing some',
103123
'non-lower-case characters'
104-
]);
124+
].join(' '));
105125
}
106126
});
107127

108128
log('lower case only file names', logs);
109129
});
130+
}
131+
132+
// check that all files have a trailing new line character
133+
function assertTrailingNewLine() {
134+
var pattern = combineGlobs([
135+
path.join(constants.pathToSrc, '**/*.glsl'),
136+
path.join(constants.pathToRoot, 'test', 'image', 'mocks', '*')
137+
]);
138+
139+
var regexNewLine = /\r?\n$/;
140+
var regexEmptyNewLine = /^\r?\n$/;
141+
var promises = [];
142+
var logs = [];
143+
144+
glob(pattern, function(err, files) {
145+
files.forEach(function(file) {
146+
var promise = readLastLines.read(file, 1);
110147

148+
promises.push(promise);
149+
150+
promise.then(function(lines) {
151+
if(!regexNewLine.test(lines)) {
152+
logs.push([
153+
file, ':',
154+
'does not have a trailing new line character'
155+
].join(' '));
156+
} else if(regexEmptyNewLine.test(lines)) {
157+
logs.push([
158+
file, ':',
159+
'has more than one trailing new line'
160+
].join(' '));
161+
}
162+
});
163+
});
164+
165+
Promise.all(promises).then(function() {
166+
log('trailing new line character', logs);
167+
});
168+
});
111169
}
112170

113171
// check circular dependencies
@@ -137,6 +195,7 @@ function combineGlobs(arr) {
137195
function log(name, logs) {
138196
if(logs.length) {
139197
console.error('test-syntax error [' + name + ']');
198+
console.error(logs.join('\n'));
140199
EXIT_CODE = 1;
141200
} else {
142201
console.log('ok ' + name);

test/image/mocks/1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,4 +868,4 @@
868868
"separators": ".,",
869869
"hidesources": false
870870
}
871-
}
871+
}

test/image/mocks/12.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,4 +854,4 @@
854854
"separators": ".,",
855855
"hidesources": false
856856
}
857-
}
857+
}

test/image/mocks/13.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,4 +643,4 @@
643643
"separators": ".,",
644644
"hidesources": false
645645
}
646-
}
646+
}

test/image/mocks/14.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,4 +430,4 @@
430430
"separators": ".,",
431431
"hidesources": false
432432
}
433-
}
433+
}

test/image/mocks/18.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5861,4 +5861,4 @@
58615861
"autorange": true
58625862
}
58635863
}
5864-
}
5864+
}

test/image/mocks/19.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,4 @@
277277
"autorange": true
278278
}
279279
}
280-
}
280+
}

test/image/mocks/21.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,4 +1190,4 @@
11901190
"separators": ".,",
11911191
"hidesources": false
11921192
}
1193-
}
1193+
}

test/image/mocks/23.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,4 @@
207207
"separators": ".,",
208208
"hidesources": false
209209
}
210-
}
210+
}

test/image/mocks/24.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,4 @@
207207
"separators": ".,",
208208
"hidesources": false
209209
}
210-
}
210+
}

test/image/mocks/25.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,4 +551,4 @@
551551
"separators": ".,",
552552
"hidesources": false
553553
}
554-
}
554+
}

test/image/mocks/27.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,4 +362,4 @@
362362
"separators": ".",
363363
"hidesources": false
364364
}
365-
}
365+
}

test/image/mocks/28.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,4 +1016,4 @@
10161016
"separators": ".",
10171017
"hidesources": false
10181018
}
1019-
}
1019+
}

test/image/mocks/30.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,4 +356,4 @@
356356
"separators": ".,",
357357
"hidesources": false
358358
}
359-
}
359+
}

test/image/mocks/32.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,4 +1183,4 @@
11831183
"separators": ".,",
11841184
"hidesources": false
11851185
}
1186-
}
1186+
}

test/image/mocks/benchmarks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,4 +362,4 @@
362362
"bargap": 0.25,
363363
"bargroupgap": 0
364364
}
365-
}
365+
}

test/image/mocks/colorbar_enumerated_ticks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@
3737
"height": 300,
3838
"width": 400
3939
}
40-
}
40+
}

test/image/mocks/contour_valid_ses.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,3 @@
7070
"autosize": true
7171
}
7272
}
73-

test/image/mocks/gl2d_10.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,4 @@
181181
"separators": ".,",
182182
"hidesources": false
183183
}
184-
}
184+
}

test/image/mocks/gl2d_12.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,4 +854,4 @@
854854
"separators": ".,",
855855
"hidesources": false
856856
}
857-
}
857+
}

test/image/mocks/gl2d_14.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,4 +242,4 @@
242242
"separators": ".,",
243243
"hidesources": false
244244
}
245-
}
245+
}

test/image/mocks/gl2d_17.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,4 +715,4 @@
715715
"separators": ".,",
716716
"hidesources": false
717717
}
718-
}
718+
}

test/image/mocks/gl2d_axes_booleans.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@
7171
"autorange": true
7272
}
7373
}
74-
}
74+
}

test/image/mocks/gl2d_axes_labels.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@
8787
"exponentformat": "e"
8888
}
8989
}
90-
}
90+
}

test/image/mocks/gl2d_axes_lines.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@
7777
"linewidth": 6
7878
}
7979
}
80-
}
80+
}

test/image/mocks/gl2d_axes_range_manual.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@
6565
]
6666
}
6767
}
68-
}
68+
}

test/image/mocks/gl2d_axes_range_mode.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
"rangemode": "nonnegative"
2626
}
2727
}
28-
}
28+
}

test/image/mocks/gl2d_axes_range_type.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@
6161
"autorange": true
6262
}
6363
}
64-
}
64+
}

test/image/mocks/gl2d_date_axes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@
7474
"title": "Mayan"
7575
}
7676
}
77-
}
77+
}

test/image/mocks/gl2d_fonts.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,4 +467,4 @@
467467
"boxgroupgap": 0.3,
468468
"hidesources": false
469469
}
470-
}
470+
}

test/image/mocks/gl2d_parcoords.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@
7474
}
7575
]
7676
}]
77-
}
77+
}

test/image/mocks/gl2d_parcoords_1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
}
2626
]
2727
}]
28-
}
28+
}

test/image/mocks/gl2d_parcoords_2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@
3535
}
3636
]
3737
}]
38-
}
38+
}

test/image/mocks/gl2d_parcoords_large.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@
7474
}
7575
]
7676
}]
77-
}
77+
}

test/image/mocks/gl2d_pointcloud-basic.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@
6969
"autosize": true,
7070
"showlegend": false
7171
}
72-
}
72+
}

test/image/mocks/gl2d_scatter-colorscale-colorbar.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,4 @@
168168
"autosize": true,
169169
"showlegend": false
170170
}
171-
}
171+
}

test/image/mocks/gl2d_size_margins.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@
4040
"paper_bgcolor": "#7f7f7f",
4141
"plot_bgcolor": "#c7c7c7"
4242
}
43-
}
43+
}

test/image/mocks/gl3d_chrisp-nan-1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81997,4 +81997,4 @@
8199781997
"type": "surface"
8199881998
}
8199981999
]
82000-
}
82000+
}

test/image/mocks/gl3d_world-cals.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,4 @@
126126
"width": 800,
127127
"height": 700
128128
}
129-
}
129+
}

0 commit comments

Comments
 (0)