Skip to content

Commit de9e343

Browse files
committed
fix: run formatter prettier
1 parent 71989bd commit de9e343

37 files changed

Lines changed: 11536 additions & 10751 deletions

xmodule/capa/tests/test_files/js/mersenne-twister-min.js

Lines changed: 87 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -65,137 +65,150 @@
6565
*/
6666

6767
/* eslint-disable */
68-
var MersenneTwister = function(seed) {
68+
var MersenneTwister = function (seed) {
6969
if (seed == undefined) {
7070
seed = new Date().getTime();
71-
}
72-
/* Period parameters */
71+
}
72+
/* Period parameters */
7373
this.N = 624;
7474
this.M = 397;
75-
this.MATRIX_A = 0x9908b0df; /* constant vector a */
75+
this.MATRIX_A = 0x9908b0df; /* constant vector a */
7676
this.UPPER_MASK = 0x80000000; /* most significant w-r bits */
7777
this.LOWER_MASK = 0x7fffffff; /* least significant r bits */
78-
78+
7979
this.mt = new Array(this.N); /* the array for the state vector */
80-
this.mti=this.N+1; /* mti==N+1 means mt[N] is not initialized */
80+
this.mti = this.N + 1; /* mti==N+1 means mt[N] is not initialized */
8181

8282
this.init_genrand(seed);
83-
}
84-
83+
};
84+
8585
/* initializes mt[N] with a seed */
86-
MersenneTwister.prototype.init_genrand = function(s) {
86+
MersenneTwister.prototype.init_genrand = function (s) {
8787
this.mt[0] = s >>> 0;
88-
for (this.mti=1; this.mti<this.N; this.mti++) {
89-
var s = this.mt[this.mti-1] ^ (this.mt[this.mti-1] >>> 30);
90-
this.mt[this.mti] = (((((s & 0xffff0000) >>> 16) * 1812433253) << 16) + (s & 0x0000ffff) * 1812433253)
91-
+ this.mti;
92-
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
93-
/* In the previous versions, MSBs of the seed affect */
94-
/* only MSBs of the array mt[]. */
95-
/* 2002/01/09 modified by Makoto Matsumoto */
96-
this.mt[this.mti] >>>= 0;
97-
/* for >32 bit machines */
88+
for (this.mti = 1; this.mti < this.N; this.mti++) {
89+
var s = this.mt[this.mti - 1] ^ (this.mt[this.mti - 1] >>> 30);
90+
this.mt[this.mti] = ((((s & 0xffff0000) >>> 16) * 1812433253) << 16) + (s & 0x0000ffff) * 1812433253 + this.mti;
91+
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
92+
/* In the previous versions, MSBs of the seed affect */
93+
/* only MSBs of the array mt[]. */
94+
/* 2002/01/09 modified by Makoto Matsumoto */
95+
this.mt[this.mti] >>>= 0;
96+
/* for >32 bit machines */
9897
}
99-
}
100-
98+
};
99+
101100
/* initialize by an array with array-length */
102101
/* init_key is the array for initializing keys */
103102
/* key_length is its length */
104103
/* slight change for C++, 2004/2/26 */
105-
MersenneTwister.prototype.init_by_array = function(init_key, key_length) {
104+
MersenneTwister.prototype.init_by_array = function (init_key, key_length) {
106105
var i, j, k;
107106
this.init_genrand(19650218);
108-
i=1; j=0;
109-
k = (this.N>key_length ? this.N : key_length);
107+
i = 1;
108+
j = 0;
109+
k = this.N > key_length ? this.N : key_length;
110110
for (; k; k--) {
111-
var s = this.mt[i-1] ^ (this.mt[i-1] >>> 30)
112-
this.mt[i] = (this.mt[i] ^ (((((s & 0xffff0000) >>> 16) * 1664525) << 16) + ((s & 0x0000ffff) * 1664525)))
113-
+ init_key[j] + j; /* non linear */
111+
var s = this.mt[i - 1] ^ (this.mt[i - 1] >>> 30);
112+
this.mt[i] =
113+
(this.mt[i] ^ (((((s & 0xffff0000) >>> 16) * 1664525) << 16) + (s & 0x0000ffff) * 1664525)) +
114+
init_key[j] +
115+
j; /* non linear */
114116
this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */
115-
i++; j++;
116-
if (i>=this.N) { this.mt[0] = this.mt[this.N-1]; i=1; }
117-
if (j>=key_length) j=0;
117+
i++;
118+
j++;
119+
if (i >= this.N) {
120+
this.mt[0] = this.mt[this.N - 1];
121+
i = 1;
122+
}
123+
if (j >= key_length) j = 0;
118124
}
119-
for (k=this.N-1; k; k--) {
120-
var s = this.mt[i-1] ^ (this.mt[i-1] >>> 30);
121-
this.mt[i] = (this.mt[i] ^ (((((s & 0xffff0000) >>> 16) * 1566083941) << 16) + (s & 0x0000ffff) * 1566083941))
122-
- i; /* non linear */
125+
for (k = this.N - 1; k; k--) {
126+
var s = this.mt[i - 1] ^ (this.mt[i - 1] >>> 30);
127+
this.mt[i] =
128+
(this.mt[i] ^ (((((s & 0xffff0000) >>> 16) * 1566083941) << 16) + (s & 0x0000ffff) * 1566083941)) -
129+
i; /* non linear */
123130
this.mt[i] >>>= 0; /* for WORDSIZE > 32 machines */
124131
i++;
125-
if (i>=this.N) { this.mt[0] = this.mt[this.N-1]; i=1; }
132+
if (i >= this.N) {
133+
this.mt[0] = this.mt[this.N - 1];
134+
i = 1;
135+
}
126136
}
127137

128-
this.mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */
129-
}
130-
138+
this.mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */
139+
};
140+
131141
/* generates a random number on [0,0xffffffff]-interval */
132-
MersenneTwister.prototype.genrand_int32 = function() {
142+
MersenneTwister.prototype.genrand_int32 = function () {
133143
var y;
134144
var mag01 = new Array(0x0, this.MATRIX_A);
135145
/* mag01[x] = x * MATRIX_A for x=0,1 */
136146

137-
if (this.mti >= this.N) { /* generate N words at one time */
147+
if (this.mti >= this.N) {
148+
/* generate N words at one time */
138149
var kk;
139150

140-
if (this.mti == this.N+1) /* if init_genrand() has not been called, */
151+
if (this.mti == this.N + 1)
152+
/* if init_genrand() has not been called, */
141153
this.init_genrand(5489); /* a default initial seed is used */
142154

143-
for (kk=0;kk<this.N-this.M;kk++) {
144-
y = (this.mt[kk]&this.UPPER_MASK)|(this.mt[kk+1]&this.LOWER_MASK);
145-
this.mt[kk] = this.mt[kk+this.M] ^ (y >>> 1) ^ mag01[y & 0x1];
155+
for (kk = 0; kk < this.N - this.M; kk++) {
156+
y = (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK);
157+
this.mt[kk] = this.mt[kk + this.M] ^ (y >>> 1) ^ mag01[y & 0x1];
146158
}
147-
for (;kk<this.N-1;kk++) {
148-
y = (this.mt[kk]&this.UPPER_MASK)|(this.mt[kk+1]&this.LOWER_MASK);
149-
this.mt[kk] = this.mt[kk+(this.M-this.N)] ^ (y >>> 1) ^ mag01[y & 0x1];
159+
for (; kk < this.N - 1; kk++) {
160+
y = (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK);
161+
this.mt[kk] = this.mt[kk + (this.M - this.N)] ^ (y >>> 1) ^ mag01[y & 0x1];
150162
}
151-
y = (this.mt[this.N-1]&this.UPPER_MASK)|(this.mt[0]&this.LOWER_MASK);
152-
this.mt[this.N-1] = this.mt[this.M-1] ^ (y >>> 1) ^ mag01[y & 0x1];
163+
y = (this.mt[this.N - 1] & this.UPPER_MASK) | (this.mt[0] & this.LOWER_MASK);
164+
this.mt[this.N - 1] = this.mt[this.M - 1] ^ (y >>> 1) ^ mag01[y & 0x1];
153165

154166
this.mti = 0;
155167
}
156168

157169
y = this.mt[this.mti++];
158170

159171
/* Tempering */
160-
y ^= (y >>> 11);
172+
y ^= y >>> 11;
161173
y ^= (y << 7) & 0x9d2c5680;
162174
y ^= (y << 15) & 0xefc60000;
163-
y ^= (y >>> 18);
175+
y ^= y >>> 18;
164176

165177
return y >>> 0;
166-
}
167-
178+
};
179+
168180
/* generates a random number on [0,0x7fffffff]-interval */
169-
MersenneTwister.prototype.genrand_int31 = function() {
170-
return (this.genrand_int32()>>>1);
171-
}
172-
181+
MersenneTwister.prototype.genrand_int31 = function () {
182+
return this.genrand_int32() >>> 1;
183+
};
184+
173185
/* generates a random number on [0,1]-real-interval */
174-
MersenneTwister.prototype.genrand_real1 = function() {
175-
return this.genrand_int32()*(1.0/4294967295.0);
176-
/* divided by 2^32-1 */
177-
}
186+
MersenneTwister.prototype.genrand_real1 = function () {
187+
return this.genrand_int32() * (1.0 / 4294967295.0);
188+
/* divided by 2^32-1 */
189+
};
178190

179191
/* generates a random number on [0,1)-real-interval */
180-
MersenneTwister.prototype.random = function() {
181-
return this.genrand_int32()*(1.0/4294967296.0);
192+
MersenneTwister.prototype.random = function () {
193+
return this.genrand_int32() * (1.0 / 4294967296.0);
182194
/* divided by 2^32 */
183-
}
184-
195+
};
196+
185197
/* generates a random number on (0,1)-real-interval */
186-
MersenneTwister.prototype.genrand_real3 = function() {
187-
return (this.genrand_int32() + 0.5)*(1.0/4294967296.0);
198+
MersenneTwister.prototype.genrand_real3 = function () {
199+
return (this.genrand_int32() + 0.5) * (1.0 / 4294967296.0);
188200
/* divided by 2^32 */
189-
}
190-
201+
};
202+
191203
/* generates a random number on [0,1) with 53-bit resolution*/
192-
MersenneTwister.prototype.genrand_res53 = function() {
193-
var a=this.genrand_int32()>>>5, b=this.genrand_int32()>>>6;
194-
return(a*67108864.0+b)*(1.0/9007199254740992.0);
195-
}
204+
MersenneTwister.prototype.genrand_res53 = function () {
205+
var a = this.genrand_int32() >>> 5,
206+
b = this.genrand_int32() >>> 6;
207+
return (a * 67108864.0 + b) * (1.0 / 9007199254740992.0);
208+
};
196209

197210
/* These real versions are due to Isaku Wada, 2002/01/09 added */
198-
if(typeof exports == 'undefined'){
211+
if (typeof exports == "undefined") {
199212
var root = this;
200213
} else {
201214
var root = exports;

xmodule/capa/tests/test_files/js/test_problem_display.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,41 @@
88
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
99
*/
1010
class MinimaxProblemDisplay extends XProblemDisplay {
11-
1211
constructor(state, submission, evaluation, container, submissionField, parameters) {
13-
1412
{
1513
// Hack: trick Babel/TypeScript into allowing this before super.
16-
if (false) { super(); }
17-
let thisFn = (() => { this; }).toString();
18-
let thisName = thisFn.slice(thisFn.indexOf('{') + 1, thisFn.indexOf(';')).trim();
14+
if (false) {
15+
super();
16+
}
17+
let thisFn = (() => {
18+
this;
19+
}).toString();
20+
let thisName = thisFn.slice(thisFn.indexOf("{") + 1, thisFn.indexOf(";")).trim();
1921
eval(`${thisName} = this;`);
2022
}
2123
this.state = state;
2224
this.submission = submission;
2325
this.evaluation = evaluation;
2426
this.container = container;
2527
this.submissionField = submissionField;
26-
if (parameters == null) { parameters = {}; }
28+
if (parameters == null) {
29+
parameters = {};
30+
}
2731
this.parameters = parameters;
2832
super(this.state, this.submission, this.evaluation, this.container, this.submissionField, this.parameters);
2933
}
3034

3135
render() {}
3236

3337
createSubmission() {
34-
3538
this.newSubmission = {};
3639

3740
if (this.submission != null) {
3841
return (() => {
3942
const result = [];
4043
for (let id in this.submission) {
4144
const value = this.submission[id];
42-
result.push(this.newSubmission[id] = value);
45+
result.push((this.newSubmission[id] = value));
4346
}
4447
return result;
4548
})();
@@ -51,5 +54,5 @@ class MinimaxProblemDisplay extends XProblemDisplay {
5154
}
5255
}
5356

54-
const root = typeof exports !== 'undefined' && exports !== null ? exports : this;
57+
const root = typeof exports !== "undefined" && exports !== null ? exports : this;
5558
root.TestProblemDisplay = TestProblemDisplay;

xmodule/capa/tests/test_files/js/test_problem_generator.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,31 @@
66
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
77
*/
88
class TestProblemGenerator extends XProblemGenerator {
9-
109
constructor(seed, parameters) {
11-
1210
{
1311
// Hack: trick Babel/TypeScript into allowing this before super.
14-
if (false) { super(); }
15-
let thisFn = (() => { this; }).toString();
16-
let thisName = thisFn.slice(thisFn.indexOf('{') + 1, thisFn.indexOf(';')).trim();
12+
if (false) {
13+
super();
14+
}
15+
let thisFn = (() => {
16+
this;
17+
}).toString();
18+
let thisName = thisFn.slice(thisFn.indexOf("{") + 1, thisFn.indexOf(";")).trim();
1719
eval(`${thisName} = this;`);
1820
}
19-
if (parameters == null) { parameters = {}; }
21+
if (parameters == null) {
22+
parameters = {};
23+
}
2024
this.parameters = parameters;
2125
super(seed, this.parameters);
2226
}
2327

2428
generate() {
25-
2629
this.problemState.value = this.parameters.value;
2730

2831
return this.problemState;
2932
}
3033
}
3134

32-
const root = typeof exports !== 'undefined' && exports !== null ? exports : this;
35+
const root = typeof exports !== "undefined" && exports !== null ? exports : this;
3336
root.generatorClass = TestProblemGenerator;

xmodule/capa/tests/test_files/js/test_problem_grader.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,41 @@
77
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
88
*/
99
class TestProblemGrader extends XProblemGrader {
10-
1110
constructor(submission, problemState, parameters) {
12-
1311
{
1412
// Hack: trick Babel/TypeScript into allowing this before super.
15-
if (false) { super(); }
16-
let thisFn = (() => { this; }).toString();
17-
let thisName = thisFn.slice(thisFn.indexOf('{') + 1, thisFn.indexOf(';')).trim();
13+
if (false) {
14+
super();
15+
}
16+
let thisFn = (() => {
17+
this;
18+
}).toString();
19+
let thisName = thisFn.slice(thisFn.indexOf("{") + 1, thisFn.indexOf(";")).trim();
1820
eval(`${thisName} = this;`);
1921
}
2022
this.submission = submission;
2123
this.problemState = problemState;
22-
if (parameters == null) { parameters = {}; }
24+
if (parameters == null) {
25+
parameters = {};
26+
}
2327
this.parameters = parameters;
2428
super(this.submission, this.problemState, this.parameters);
2529
}
2630

2731
solve() {
28-
29-
return this.solution = {0: this.problemState.value};
32+
return (this.solution = { 0: this.problemState.value });
3033
}
3134

3235
grade() {
33-
34-
if ((this.solution == null)) {
36+
if (this.solution == null) {
3537
this.solve();
3638
}
3739

3840
let allCorrect = true;
3941

4042
for (let id in this.solution) {
4143
const value = this.solution[id];
42-
const valueCorrect = (this.submission != null) ? (value === this.submission[id]) : false;
44+
const valueCorrect = this.submission != null ? value === this.submission[id] : false;
4345
this.evaluation[id] = valueCorrect;
4446
if (!valueCorrect) {
4547
allCorrect = false;
@@ -50,5 +52,5 @@ class TestProblemGrader extends XProblemGrader {
5052
}
5153
}
5254

53-
const root = typeof exports !== 'undefined' && exports !== null ? exports : this;
55+
const root = typeof exports !== "undefined" && exports !== null ? exports : this;
5456
root.graderClass = TestProblemGrader;

0 commit comments

Comments
 (0)