on master help sign in
Added a JavaScript test file
commitec842e8d51f835a1f1f50ec8a716fc413a0b59a6 authorDanielVip3 <danieledemartino.72004@gmail.com> dateMon 5 Oct 2020, 15:08 (6 years ago) parent6d6e390
2 files changed+228
tests/syntax-tests/highlighted/JavaScript/test.js+114 tests/syntax-tests/source/JavaScript/test.js+114
tests/syntax-tests/highlighted/JavaScript/test.jsnew file+114
@@ -0,0 +1,114 @@
1+let letNumber = 1000;
2+const constNumber = 10;
3+var varNumber = -1234;
4+const constNegativeFloat = -1.23;
5+var tooMuch = Infinity;
6+nothing = null;
7+let listofthings = ["thing", 'thing2', `foo`, ["bar"]];
8+
9+// Simple comment
10+
11+/**
12+* #########
13+* Multiline
14+* comment
15+* #########
16+*/
17+
18+let test;
19+for (let i = 0; i < constNumber; i++) {
20+ if (test) continue;
21+ else test += 1; // random things
22+}
23+
24+while(test < 100 && typeof test === "number") {
25+ test = test > 30 ? test+5 : test+1;
26+}
27+
28+function weatherSays(when=Date.now()) {
29+ return "rain";
30+}
31+
32+const thereAreClouds = true;
33+const cloudsCount = 20;
34+
35+switch(weatherSays(Date.now())) {
36+ case 'rain':
37+ break;
38+ case 'sun':
39+ default:
40+ break;
41+}
42+
43+let rain = false;
44+if ((thereAreClouds && cloudsCount >= 20) || weatherSays() === "rain") {
45+ rain = false;
46+} else if (thereAreClouds && weatherSays() == "rain") { // oh no, unsafe two equals checking!
47+ rain = true;
48+} else {
49+ rain = !!cloudsCount;
50+}
51+
52+class Forecast {
53+ constructor(where, isGonnaRainA=true, isGonnaRainB=false, isGonnaRainC=false, ...randomArgs) {
54+ this.station = {
55+ location: [where.x, where.y, where.z],
56+ surroundings: {
57+ zoneA: {
58+ location: [1, 2, 3],
59+ isGonnaRain: isGonnaRainA
60+ },
61+ zoneB: {
62+ location: [-1, 2, 2],
63+ isGonnaRain: isGonnaRainB
64+ },
65+ zoneC: {
66+ location: [-2, 0, 0],
67+ isGonnaRainC: isGonnaRainC
68+ },
69+ }
70+ };
71+ }
72+ 
73+ async getLocalPrevisions() {
74+ const rainZones = [this.station.surroundings.zoneA.isGonnaRain, this.station.surroundings.zoneB.isGonnaRain, this.station.surroundings.zoneC.isGonnaRain];
75+ return await rainZones.filter(z => !!z).length > (rainZones.length / 2);
76+ }
77+ 
78+ communicatePrevisions(isGonnaRain=undefined) {
79+ if (isGonnaRain) console.log("Take the umbrella.");
80+ }
81+ 
82+ destroy() {
83+ delete this.station;
84+ }
85+ 
86+ static startHiring() {
87+ console.log("We're looking for weather presenters.");
88+ console.log("A lot of presenters came. Hiring stops.");
89+ }
90+ 
91+ /* This forecasting station is magic. It can generate rain, but this method is secret because it's a generator function - nobody uses them! */
92+ * generateRainInZoneC(clouds=[1, 2, 3]) {
93+ this.station.surroundings.zoneC.isGonnaRain = true;
94+ const makeRain = () => { return "raining!"; };
95+ 
96+ yield clouds; // first, keeps clouds
97+ do {
98+ console.log(makeRain());
99+ yield clouds.pop(); // then all clouds do rain
100+ } while(clouds.length >= 1);
101+ }
102+}
103+
104+Forecast.startHiring();
105+const forecasting = new Forecast([3, 3, 3]);
106+(async() => {
107+ const raining = forecasting.generateRainInZoneC();
108+ raining.next();
109+ forecasting.communicatePrevisions(await forecasting.getLocalPrevisions());
110+ raining.next();
111+ raining.next();
112+ raining.return("stop!");
113+ forecasting.destroy();
114+})();
tests/syntax-tests/source/JavaScript/test.jsnew file+114
@@ -0,0 +1,114 @@
1+let letNumber = 1000;
2+const constNumber = 10;
3+var varNumber = -1234;
4+const constNegativeFloat = -1.23;
5+var tooMuch = Infinity;
6+nothing = null;
7+let listofthings = ["thing", 'thing2', `foo`, ["bar"]];
8+
9+// Simple comment
10+
11+/**
12+* #########
13+* Multiline
14+* comment
15+* #########
16+*/
17+
18+let test;
19+for (let i = 0; i < constNumber; i++) {
20+ if (test) continue;
21+ else test += 1; // random things
22+}
23+
24+while(test < 100 && typeof test === "number") {
25+ test = test > 30 ? test+5 : test+1;
26+}
27+
28+function weatherSays(when=Date.now()) {
29+ return "rain";
30+}
31+
32+const thereAreClouds = true;
33+const cloudsCount = 20;
34+
35+switch(weatherSays(Date.now())) {
36+ case 'rain':
37+ break;
38+ case 'sun':
39+ default:
40+ break;
41+}
42+
43+let rain = false;
44+if ((thereAreClouds && cloudsCount >= 20) || weatherSays() === "rain") {
45+ rain = false;
46+} else if (thereAreClouds && weatherSays() == "rain") { // oh no, unsafe two equals checking!
47+ rain = true;
48+} else {
49+ rain = !!cloudsCount;
50+}
51+
52+class Forecast {
53+ constructor(where, isGonnaRainA=true, isGonnaRainB=false, isGonnaRainC=false, ...randomArgs) {
54+ this.station = {
55+ location: [where.x, where.y, where.z],
56+ surroundings: {
57+ zoneA: {
58+ location: [1, 2, 3],
59+ isGonnaRain: isGonnaRainA
60+ },
61+ zoneB: {
62+ location: [-1, 2, 2],
63+ isGonnaRain: isGonnaRainB
64+ },
65+ zoneC: {
66+ location: [-2, 0, 0],
67+ isGonnaRainC: isGonnaRainC
68+ },
69+ }
70+ };
71+ }
72+
73+ async getLocalPrevisions() {
74+ const rainZones = [this.station.surroundings.zoneA.isGonnaRain, this.station.surroundings.zoneB.isGonnaRain, this.station.surroundings.zoneC.isGonnaRain];
75+ return await rainZones.filter(z => !!z).length > (rainZones.length / 2);
76+ }
77+
78+ communicatePrevisions(isGonnaRain=undefined) {
79+ if (isGonnaRain) console.log("Take the umbrella.");
80+ }
81+
82+ destroy() {
83+ delete this.station;
84+ }
85+
86+ static startHiring() {
87+ console.log("We're looking for weather presenters.");
88+ console.log("A lot of presenters came. Hiring stops.");
89+ }
90+
91+ /* This forecasting station is magic. It can generate rain, but this method is secret because it's a generator function - nobody uses them! */
92+ * generateRainInZoneC(clouds=[1, 2, 3]) {
93+ this.station.surroundings.zoneC.isGonnaRain = true;
94+ const makeRain = () => { return "raining!"; };
95+
96+ yield clouds; // first, keeps clouds
97+ do {
98+ console.log(makeRain());
99+ yield clouds.pop(); // then all clouds do rain
100+ } while(clouds.length >= 1);
101+ }
102+}
103+
104+Forecast.startHiring();
105+const forecasting = new Forecast([3, 3, 3]);
106+(async() => {
107+ const raining = forecasting.generateRainInZoneC();
108+ raining.next();
109+ forecasting.communicatePrevisions(await forecasting.getLocalPrevisions());
110+ raining.next();
111+ raining.next();
112+ raining.return("stop!");
113+ forecasting.destroy();
114+})();