Skip to content

Commit 4dbb917

Browse files
committed
fix rebase conflicts and bugs
1 parent 1927257 commit 4dbb917

File tree

6 files changed

+290
-351
lines changed

6 files changed

+290
-351
lines changed

formatTest/unit_tests/expected_output/basicStructures.re

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
1+
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
22
let run () => TestUtils.printSection "Basic Structures";
33

44
while something {
@@ -36,7 +36,7 @@ let x = !(!foo).bar;
3636

3737
let x = !(!foo)#bar;
3838

39-
// Prefix operator
39+
/* Prefix operator */
4040
let x = !!foo.bar;
4141

4242
let x = !!foo#bar;
@@ -64,9 +64,9 @@ let x = !!foo.bar;
6464

6565
let x = !!foo#bar;
6666

67-
// Comments
68-
//Below is an empty comment
69-
//
67+
/* Comments */
68+
/*Below is an empty comment*/
69+
/**/
7070
/** IF
7171
*============================================================================
7272
*/
@@ -109,7 +109,7 @@ let loop appTime frameTime => {
109109
process appTime frameTime
110110
};
111111

112-
// These parens should be kept around the entire last if/then/else
112+
/* These parens should be kept around the entire last if/then/else */
113113
if something {
114114
if somethingElse {
115115
()
@@ -118,7 +118,7 @@ if something {
118118
}
119119
};
120120

121-
// These parens should be kept around just the last if/then
121+
/* These parens should be kept around just the last if/then*/
122122
if something {
123123
if somethingElse {
124124
()
@@ -137,7 +137,7 @@ if true {
137137
}
138138
};
139139

140-
// Should print two
140+
/* Should print two */
141141
if true {
142142
if false {
143143
print_string "one"
@@ -146,7 +146,7 @@ if true {
146146
}
147147
};
148148

149-
// Should not print
149+
/* Should not print */
150150
if false {
151151
if true {
152152
print_string "one"
@@ -209,7 +209,7 @@ if printIfFirstArgGreater {
209209
}
210210
};
211211

212-
// Should Be Parsed As: Cleary a type error, but at least the parsing makes that clear
212+
/* Should Be Parsed As: Cleary a type error, but at least the parsing makes that clear */
213213
if printIfFirstArgGreater {
214214
fun a b =>
215215
if (a > b) {
@@ -227,7 +227,7 @@ fun a b =>
227227
print_string "a > b"
228228
};
229229

230-
// What you probably wanted was:
230+
/* What you probably wanted was: */
231231
if printIfFirstArgGreater {
232232
fun a b =>
233233
if (a > b) {
@@ -240,7 +240,7 @@ if printIfFirstArgGreater {
240240
}
241241
};
242242

243-
// Mutative if statement: Not used to evaluate to something.
243+
/* Mutative if statement: Not used to evaluate to something. */
244244
if (10 < 100) {
245245
let msg = "If there was any doubt, 10 is in fact less than 100.";
246246
print_string msg
@@ -266,12 +266,12 @@ let x: int = 10;
266266

267267
let x: int = (10: int);
268268

269-
// let (x:int) = (10:string);
270-
// let (x:string) = ("hello":int);
269+
/* let (x:int) = (10:string); */
270+
/* let (x:string) = ("hello":int); */
271271
/** TUPLES
272272
*============================================================================
273273
*/
274-
// In Reason, types look like the data they model! Tuples are no exception.
274+
/* In Reason, types look like the data they model! Tuples are no exception. */
275275
type pairOfInts = (int, int);
276276

277277
let letBindingWithTypeConstraint: int = 10;
@@ -281,22 +281,22 @@ let (tupleItem: int, withTypeConstraint: int) = (
281281
20
282282
);
283283

284-
// To make sure that tuple field annotations are annotating the entire field
284+
/* To make sure that tuple field annotations are annotating the entire field */
285285
let _dummyFunc x => 10;
286286

287287
let annotatingFuncApplication = (
288288
_dummyFunc "a": int,
289289
_dummyFunc "a": int
290290
);
291291

292-
// Pretty printer might stick the [int] at the label.
292+
/* Pretty printer might stick the [int] at the label. */
293293
let annotatingSingleFuncApplication: int = _dummyFunc "a";
294294

295-
// So lets try a place where it won't
295+
/* So lets try a place where it won't */
296296
let annotatingSingleFuncApplication = {
297-
// Commenting a let binding.
297+
/* Commenting a let binding. */
298298
let a = 100;
299-
// Commenting another let binding.
299+
/* Commenting another let binding. */
300300
let int = 200;
301301
/*
302302
* This demonstrates why named arguments cannot simply have the form (func
@@ -324,31 +324,31 @@ let (tupleItem, withOutsideTypeConstraint): (
324324
/** Immutable Lists
325325
* ============================================================================
326326
*/
327-
// Anatomy: -Head- --------- Tail--------- nil: You can't see nil
327+
/* Anatomy: -Head- --------- Tail--------- nil: You can't see nil */
328328
let x: list int = [1, 2, 3, 4, 5, 6, 7, 8, 9];
329329

330330
let hd = "appendedToHead";
331331

332332
let tl = ["listTo", "append", "to"];
333333

334-
// To push *one* and only *one* item to the front of a list - use [hd, ...tl]
334+
/* To push *one* and only *one* item to the front of a list - use [hd, ...tl] */
335335
let result: list string = [hd, ...tl];
336336

337-
// Is the same as writing
337+
/* Is the same as writing */
338338
let result: list string = [
339339
"appendedToHead",
340340
"listTo",
341341
"append",
342342
"to"
343343
];
344344

345-
// To operate on lists, use pattern matching
345+
/* To operate on lists, use pattern matching */
346346
let rec size =
347347
fun
348348
| [] => 0
349349
| [hd, ...tl] => 1 + size tl;
350350

351-
// Optimize for tail recursion
351+
/* Optimize for tail recursion */
352352
let rec size soFar lst =>
353353
switch lst {
354354
| [] => 0
@@ -410,15 +410,15 @@ let MyThing _ as ppp | YourThing _ as ppp = ppp;
410410
* But this isn't needed in Reason because OR patterns have much lower
411411
* precedence - they should be pretty printed in the same way.
412412
*/
413-
// TODO:
414-
// let rec nestedMatch lstLst => match lstLst with {
415-
// hd::tl: match tl with {
416-
// []: 0 + 0,
417-
// tlHd::tlTl: 0 + 1,
418-
// },
419-
// []: 0
420-
// };
421-
//
413+
/* TODO: */
414+
/* let rec nestedMatch lstLst => match lstLst with { */
415+
/* hd::tl: match tl with { */
416+
/* []: 0 + 0, */
417+
/* tlHd::tlTl: 0 + 1, */
418+
/* }, */
419+
/* []: 0 */
420+
/* }; */
421+
/* */
422422
/** ARRAYS
423423
* ============================================================================
424424
* Arrays are weird looking. Usually you want lists because they support pattern
@@ -433,11 +433,11 @@ let arrayWithTwo = [|10, 10|];
433433

434434
let secondItem = arrayWithTwo.(1);
435435

436-
// Getting And Setting: Yeah, we should really change this
437-
// Get an array item at index 1
436+
/* Getting And Setting: Yeah, we should really change this */
437+
/* Get an array item at index 1 */
438438
let secondItem = arrayWithTwo.(1);
439439

440-
// Set an array item at index 1
440+
/* Set an array item at index 1 */
441441
arrayWithTwo.(1) = 300;
442442

443443
/**
@@ -447,7 +447,7 @@ arrayWithTwo.(1) = 300;
447447
*/
448448
let myString = "asdf";
449449

450-
// Replacing a character: I could do without this sugar
450+
/* Replacing a character: I could do without this sugar */
451451
myString.[2] = '9';
452452

453453
/* FUNCTIONS
@@ -460,20 +460,20 @@ let one = 900;
460460

461461
let two = 10000;
462462

463-
// Tuple expressions can be annotated without additional paren wrapping
463+
/* Tuple expressions can be annotated without additional paren wrapping */
464464
let myTuple = (one: int, two: int);
465465

466466
type myTupleType = (int, int);
467467

468468
let myTuple: myTupleType = myTuple;
469469

470-
// Anything *outside* of a tuple, must still be annotated within parens.
470+
/* Anything *outside* of a tuple, must still be annotated within parens. */
471471
let myTuple: myTupleType = (one: int, two: int);
472472

473-
// Now functions that accept a single argument being a tuple look familiar
473+
/* Now functions that accept a single argument being a tuple look familiar */
474474
let addValues (a: int, b: int) => a + b;
475475

476-
// Impossible to annotate return values of fun lambdas - just like in OCaml
476+
/* Impossible to annotate return values of fun lambdas - just like in OCaml */
477477
let addValues (a: int, b: int) => a + b;
478478

479479
let functionReturnValueType
@@ -489,7 +489,7 @@ let curriedFormTwo (i: int, x: int) :(int, int) => (
489489
x
490490
);
491491

492-
// let nonCurriedFormTwo = fun (i:int, x:int) (:(int, int)) => (i, x);
492+
/* let nonCurriedFormTwo = fun (i:int, x:int) (:(int, int)) => (i, x); */
493493
let curriedFormThree
494494
(i: int, (a: int, b: int): (int, int))
495495
:(int, int, int) => (
@@ -498,7 +498,7 @@ let curriedFormThree
498498
b
499499
);
500500

501-
// let nonCurriedFormThree = fun (i:int, (a:int, b:int):(int, int)) (:(int, int, int)) => (i, a, b);
501+
/* let nonCurriedFormThree = fun (i:int, (a:int, b:int):(int, int)) (:(int, int, int)) => (i, a, b); */
502502
/** TODO: But this, however doesn't work.
503503
* let (myCurriedFunc: int => int) a => a;
504504
* Note: This is likely because only "simple patterns" are accepted as constraints

formatTest/unit_tests/expected_output/comments.re

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,17 @@ let testPostComment = "";
2323
let testMultiline a =>
2424
switch a {
2525
// single line comment
26-
| `Thingy x => {
27-
print_string
28-
/* multiline comment should be fine */
29-
"matched thingy x";
30-
let zz = 10;
31-
// post line single line comment
32-
zz
33-
}
34-
| `Other x => {
35-
// single line comment above
36-
print_string "matched other x";
37-
x
38-
}
26+
| `Thingy x =>
27+
print_string
28+
/* multiline comment should be fine */
29+
"matched thingy x";
30+
let zz = 10;
31+
// post line single line comment
32+
zz
33+
| `Other x =>
34+
// single line comment above
35+
print_string "matched other x";
36+
x
3937
};
4038

4139
// single line comment below
@@ -66,14 +64,18 @@ let a = 10;
6664
let b = 20;
6765

6866
/*A*/
69-
let named /* a::a */ a::a /* b::b */ b::b => /* a + b */ a + b;
67+
let named /* a::a */ a::a /* b::b */ b::b =>
68+
/* a + b */
69+
a + b;
7070

7171
/*B*/
7272
let namedAlias
7373
/* a::aa */
7474
a::aa
7575
/* b::bb */
76-
b::bb => /* aa + bb */ aa + bb;
76+
b::bb =>
77+
/* aa + bb */
78+
aa + bb;
7779

7880
/*C*/
7981
let namedAnnot

0 commit comments

Comments
 (0)