Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions formatTest/typeCheckedTests/input/attributes.re
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,21 @@ let x = [@attrEverything] (true && false);
/**
* How attribute parsings respond to other syntactic constructs.
*/
let add(a) { [@onRet] a };
let add = (a) => { [@onRet] a };
let add = fun(a) => [@onRet] a;
let add = [@onEntireFunction] (fun(a) => a);

let res = if (true) false else [@onFalse] false;
let res = [@onEntireIf] (if (true) false else false);


let add(a,b) = [@onEverything] ([@onA] a + b);
let add(a,b) = [@onEverything] ([@onA]a + ([@onB]b));
let add = (a,b) => [@onEverything] ([@onA] a + b);
let add = (a,b) => [@onEverything] ([@onA]a + ([@onB]b));
let add = (a,b) => a + [@onB]b;

let both = [@onEntireFunction](fun(a) => a);
let both(a,b) = [@onEverything]([@onA]a && b);
let both(a,b) = [@onA] a && [@onB] ([@onB] b);
let both = (a,b) => [@onEverything]([@onA]a && b);
let both = (a,b) => [@onA] a && [@onB] ([@onB] b);
let both = fun(a,b) => [@onEverything](a && b);

let thisVal = 10;
Expand All @@ -111,7 +111,7 @@ let x = - [@onFunctionCall] add(thisVal,thisVal);
let x = [@onEverything] (- add(thisVal,thisVal));


let bothTrue(x,y) = {contents: x && y};
let bothTrue = (x,y) => {contents: x && y};
let something = [@onEverythingToRightOfEquals](bothTrue(true,true)^);
let something = ([@onlyOnArgumentToBang]bothTrue(true,true))^;

Expand Down Expand Up @@ -168,7 +168,7 @@ and secondBinding = "second";
* Let bindings.
* ----------------------
*/
let showLets () = [@onOuterLet] {
let showLets = () => [@onOuterLet] {
let tmp = 20;
[@onFinalLet] {
let tmpTmp = tmp + tmp;
Expand Down
4 changes: 2 additions & 2 deletions formatTest/typeCheckedTests/input/basics.re
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let expectedPrecendence = 1 + 1 \=== 1 + 1 && 1 + 1 \!== 1 + 1;
let expectedPrecendence = 1 \+ 1 \=== 1 \+ 1 && 1 \+ 1 \!== 1 \+ 1;

module X: {let x: (~x: unit=?, unit) => unit;} = {
let x(~x=(),()) = ();
let x = (~x=(),()) => ();
};

let display (~message=("hello": string), ~person: string="Reason", time: float) = 1;
let display = (~message=("hello": string), ~person: string="Reason", time: float) => 1;
76 changes: 38 additions & 38 deletions formatTest/typeCheckedTests/input/jsx.re
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
type component = {displayName: string};

module Bar = {
let createElement(~c=?,~children,()) {displayName: "test"};
let createElement = (~c=?,~children,()) => {displayName: "test"};
};

module Nesting = {
let createElement(~children,()) {displayName: "test"};
let createElement = (~children,()) => {displayName: "test"};
};

module Much = {
let createElement(~children,()) {displayName: "test"};
let createElement = (~children,()) => {displayName: "test"};
};

module Foo = {
let createElement(~a=?,~b=?,~children,()) {displayName: "test"};
let createElement = (~a=?,~b=?,~children,()) => {displayName: "test"};
};

module One = {
let createElement(~test=?,~foo=?,~children,()) {displayName: "test"};
let createElementobvioustypo(~test,~children,()) {displayName: "test"};
let createElement = (~test=?,~foo=?,~children,()) => {displayName: "test"};
let createElementobvioustypo = (~test,~children,()) => {displayName: "test"};
};

module Two = {
let createElement(~foo=?,~children,()) {displayName: "test"};
let createElement = (~foo=?,~children,()) => {displayName: "test"};
};

module Sibling = {
let createElement(~foo=?,~children : list(component),()) = {displayName: "test"};
let createElement = (~foo=?,~children : list(component),()) => {displayName: "test"};
};

module Test = {
let createElement(~yo=?,~children,()) {displayName: "test"};
let createElement = (~yo=?,~children,()) => {displayName: "test"};
};

module So = {
let createElement(~children,()) {displayName: "test"};
let createElement = (~children,()) => {displayName: "test"};
};

module Foo2 = {
let createElement(~children,()) {displayName: "test"};
let createElement = (~children,()) => {displayName: "test"};
};

module Text = {
let createElement(~children,()) {displayName: "test"};
let createElement = (~children,()) => {displayName: "test"};
};

module Exp = {
let createElement(~children,()) {displayName: "test"};
let createElement = (~children,()) => {displayName: "test"};
};

module Pun = {
let createElement(~intended=?,~children,()) {displayName: "test"};
let createElement = (~intended=?,~children,()) => {displayName: "test"};
};

module Namespace = {
module Foo = {
let createElement(~intended=?,~anotherOptional as x=100,~children,()) {displayName: "test"};
let createElement = (~intended=?,~anotherOptional as x=100,~children,()) => {displayName: "test"};
};
};

module Optional1 = {
let createElement(~required,~children,()) {
let createElement = (~required,~children,()) => {
switch (required) {
| Some(a) => {displayName: a}
| None => {displayName: "nope"}
Expand All @@ -69,7 +69,7 @@ module Optional1 = {
};

module Optional2 = {
let createElement(~optional=?,~children,()) {
let createElement = (~optional=?,~children,()) => {
switch (optional) {
| Some(a) => {displayName: a}
| None => {displayName: "nope"}
Expand All @@ -78,7 +78,7 @@ module Optional2 = {
};

module DefaultArg = {
let createElement(~default=Some("foo"),~children,()) {
let createElement = (~default=Some("foo"),~children,()) => {
switch (default) {
| Some(a) => {displayName: a}
| None => {displayName: "nope"}
Expand All @@ -88,41 +88,41 @@ module DefaultArg = {


module LotsOfArguments = {
let createElement(~argument1=?,~argument2=?,~argument3=?,~argument4=?,~argument5=?,~argument6=?,~children,()) {displayName: "test"};
let createElement = (~argument1=?,~argument2=?,~argument3=?,~argument4=?,~argument5=?,~argument6=?,~children,()) => {displayName: "test"};
};

let div(~argument1=?,~children,()) {
let div = (~argument1=?,~children,()) => {
displayName: "test"
};

module List1 = {
let createElement(~children,()) {displayName: "test"};
let createElement = (~children,()) => {displayName: "test"};
};

module List2 = {
let createElement(~children,()) {displayName: "test"};
let createElement = (~children,()) => {displayName: "test"};
};

module List3 = {
let createElement(~children,()) {displayName: "test"};
let createElement = (~children,()) => {displayName: "test"};
};

module NotReallyJSX = {
let createElement(~foo,~bar,children) {displayName: "test"};
let createElement = (~foo,~bar,children) => {displayName: "test"};
};

let notReallyJSX(~foo,~bar,children) {
let notReallyJSX = (~foo,~bar,children) => {
displayName: "test"
};

let fakeRender (el:component) {
let fakeRender = (el:component) => {
el.displayName
};

/* end of setup */

let (/><)(a,b) = a + b;
let (><)(a,b) = a + b;
let (/><) = (a,b) => a + b;
let (><) = (a,b) => a + b;
let (/>) = fun(a,b) => a + b;
let ( ><\/ ) = fun(a,b) => a + b;

Expand Down Expand Up @@ -170,7 +170,7 @@ let jsxInList5 = [ <Foo> </Foo>, <Foo> </Foo> ];
let jsxInList6 = [ <Foo />, <Foo /> ];
let jsxInList7 = [ <Foo> </Foo>, <Foo> </Foo>];
let jsxInList8 = [ <Foo />, <Foo />];
let testFunc(b) = b;
let testFunc = (b) => b;
let jsxInFnCall = testFunc (<Foo />);
let lotsOfArguments = <LotsOfArguments argument1=1 argument2=2 argument3=3 argument4=4 argument5=5 argument6="test"> <Namespace.Foo /> </LotsOfArguments>;
let lowerCase = <div argument1=1 />;
Expand Down Expand Up @@ -208,7 +208,7 @@ let listOfItems3 = <List3>fragment11 fragment11</List3>;
/*
* Several sequential simple jsx expressions must be separated with a space.
*/
let thisIsRight(a,b) = ();
let thisIsRight = (a,b) => ();
let tagOne = fun(~children,()) => ();
let tagTwo = fun(~children,()) => ();
/* thisIsWrong <tagOne /><tagTwo />; */
Expand Down Expand Up @@ -276,17 +276,17 @@ type t('a) = [< thisType ] as 'a;
let asd = [@JSX] [@foo] One.createElement(~test=true, ~foo=2, ~children=["a", "b"],());
let asd2 = [@JSX] [@foo] One.createElementobvioustypo(~test=false, ~children=["a", "b"],());

let span(~test : bool,~foo : int,~children,()) = 1;
let span = (~test : bool,~foo : int,~children,()) => 1;
let asd = [@JSX] [@foo] span(~test=true, ~foo=2, ~children=["a", "b"],());
/* "video" call doesn't end with a list, so the expression isn't converted to JSX */
let video(~test: bool,children) = children;
let video = (~test: bool,children) => children;
let asd2 = [@JSX] [@foo] video(~test=false,10);


let div(~children) = 1;
let div = (~children) => 1;
([@JSX] (((fun () => div) ())(~children=[])));

let myFun () {
let myFun = () => {
<>
<Namespace.Foo intended=(true) anotherOptional=200 />
<Namespace.Foo intended=(true) anotherOptional=200 />
Expand All @@ -303,12 +303,12 @@ let myFun () {

};

let myFun () {
let myFun = () => {
<>
</>;
};

let myFun () {
let myFun = () => {
<>
<Namespace.Foo intended=(true) anotherOptional=200 />
<Namespace.Foo intended=(true) anotherOptional=200 />
Expand Down Expand Up @@ -378,7 +378,7 @@ module Metal = {
};

module OverEager = {
let createElement(~fiber,~children,()) {displayName: "test"};
let createElement = (~fiber,~children,()) => {displayName: "test"};
};

let element = <OverEager fiber=Metal.fiber />;
Expand All @@ -393,7 +393,7 @@ type style = {
};

module Window = {
let createElement(~style,~children,()) {displayName: "window"};
let createElement = (~style,~children,()) => {displayName: "window"};
};

let w =
Expand Down
4 changes: 2 additions & 2 deletions formatTest/typeCheckedTests/input/knownReIssues.re
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
The latter doesn't type-check with Error: Unbound value exc.
Warning 11 (unused match case) is also triggered.
*/
let f () = raise(Sys_error("error"));
let f = () => raise(Sys_error("error"));

switch (f ()) {
| x => ()
Expand All @@ -15,7 +15,7 @@ switch (f ()) {

exception Foo(string);

let g () = raise(Foo("bar errors"));
let g = () => raise(Foo("bar errors"));

switch (g ()) {
| x => ()
Expand Down
2 changes: 1 addition & 1 deletion formatTest/typeCheckedTests/input/lazy.re
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let myComputation = lazy {

type myRecord = {myRecordField: int};

let operateOnLazyValue (lazy {myRecordField}) {
let operateOnLazyValue = (lazy {myRecordField}) => {
let tmp = myRecordField;
tmp + tmp;
};
Expand Down
8 changes: 4 additions & 4 deletions formatTest/typeCheckedTests/input/oo.re
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ and secondRecursiveClass(init) {

type closedObj = {.};

let (<..>)(a,b) = a + b;
let (<..>) = (a,b) => a + b;
let five = 2 <..> 3;

type nestedObj = {. bar : {. a: int}};

let (>>)(a,b) = a > b;
let (>>) = (a,b) => a > b;

let bigger = 3 >> 2;

Expand Down Expand Up @@ -156,8 +156,8 @@ let coercedReturn = {
(tmp :> {. x: int})
};

let acceptsOpenAnonObjAsArg (o: {.. x: int, y:int}) = o#x + o#y;
let acceptsClosedAnonObjAsArg (o: {. x: int, y:int}) = o#x + o#y;
let acceptsOpenAnonObjAsArg = (o: {.. x: int, y:int}) => o#x + o#y;
let acceptsClosedAnonObjAsArg = (o: {. x: int, y:int}) => o#x + o#y;
let res = acceptsOpenAnonObjAsArg {
pub x = 0;
pub y = 10;
Expand Down
4 changes: 2 additions & 2 deletions formatTest/typeCheckedTests/input/patternMatching.re
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type point = {x: int, y: int};

let id(x) = x;
let id = (x) => x;

type myVariant =
| TwoCombos(inner, inner)
Expand All @@ -10,7 +10,7 @@ and inner =
| Unused
| HeresTwoConstructorArguments(int, int);

let computeTuple(a,b,c,d,e,f,g,h) = (
let computeTuple = (a,b,c,d,e,f,g,h) => (
a + b,
c + d,
e + f,
Expand Down
16 changes: 8 additions & 8 deletions formatTest/typeCheckedTests/input/reasonComments.re
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ let testingEndOfLineComments = [];/* Comment after entire let binding */
/* withFirstArg + andSecondArg /* before semi */ ; */
/* }; */

let myFunction
let myFunction =
(/* First arg */
withFirstArg,
/* Second Arg */
andSecondArg) {
andSecondArg) => {
withFirstArg + andSecondArg
}; /* After Semi */

Expand Down Expand Up @@ -331,7 +331,7 @@ type color =
| Green(int) /* After green end of line */
; /* On next line after color type def */

let blahCurriedX(x) =
let blahCurriedX = (x) =>
fun
| Red(10)
| Black(20)
Expand All @@ -341,17 +341,17 @@ let blahCurriedX(x) =
| Green(x) => 0 /* After second green */
; /* On next line after blahCurriedX def */

let name_equal(x,y) { x == y };
let name_equal = (x,y) => { x == y };

let equal(i1,i2) =
let equal = (i1,i2) =>
i1.contents === i2.contents && true; /* most unlikely first */

let equal(i1,i2) =
let equal = (i1,i2) =>
compare(compare(0,0),compare(1,1)); /* END OF LINE HERE */

let tuple_equal((i1, i2)) = i1 == i2;
let tuple_equal = ((i1, i2)) => i1 == i2;

let tuple_equal((csu, mgd)) =
let tuple_equal = ((csu, mgd)) =>
/* Some really long comments, see https://github.com/facebook/reason/issues/811 */
tuple_equal((csu, mgd));

Expand Down
Loading