Skip to content

Commit

Permalink
update tests with single line comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dxu committed Apr 17, 2016
1 parent 6530e39 commit 1a0d7c7
Show file tree
Hide file tree
Showing 17 changed files with 1,987 additions and 463 deletions.
92 changes: 70 additions & 22 deletions formatTest/typeCheckedTests/expected_output/attributes.re
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,44 @@ type itemText = int [@@itemAttributeOnTypeDef];

type nodeText = int;

type nodeAndItemText = int [@@itemAttributeOnTypeDef];
type nodeAndItemText = int
[@@itemAttributeOnTypeDef];

type itemDoc = int [@@itemAttributeOnTypeDef];

type nodeDoc = int [@@itemAttributeOnTypeDef];

type nodeAndItemDoc = int [@@itemAttributeOnTypeDef];
type nodeAndItemDoc = int
[@@itemAttributeOnTypeDef];

type x = int [@@itemAttributeOnTypeDef];

type attributedInt = int [@onTopLevelTypeDef];

type attributedIntsInTuple = (int [@onInt], float [@onFloat]) [@@onTopLevelTypeDef];
type attributedIntsInTuple = (
int [@onInt],
float [@onFloat]
)
[@@onTopLevelTypeDef];

type myDataType 'x 'y = | MyDataType of 'x 'y;

type myType =
(myDataType ((option int) [@onOptionInt]) ((option float) [@onOption])) [@onEntireType];
(
myDataType
((option int) [@onOptionInt])
((option float) [@onOption])
)
[@onEntireType];

let thisInst: myType = MyDataType (Some 10) (Some 10.0) [@attOnEntireDatatype];
let thisInst: myType =
MyDataType (Some 10) (Some 10.0)
[@attOnEntireDatatype];

let thisInst: myType =
MyDataType (Some 10 [@onFirstParam]) (Some 10.0) [@attOnEntireDatatype];
MyDataType
(Some 10 [@onFirstParam]) (Some 10.0)
[@attOnEntireDatatype];

let x = "hello" [@onHello];

Expand Down Expand Up @@ -112,7 +127,8 @@ let res =

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

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

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

Expand All @@ -126,25 +142,34 @@ let both a b => (a && b) [@onEverything];

let thisVal = 10;

let x = 20 + (- (add thisVal thisVal [@onFunctionCall]));
let x = 20 + (
- (add thisVal thisVal [@onFunctionCall])
);

let x = (20 + (- (add thisVal thisVal))) [@onEverything];
let x =
(20 + (- (add thisVal thisVal)))
[@onEverything];

let x = - (add thisVal thisVal [@onFunctionCall]);

let x = (- (add thisVal thisVal)) [@onEverything];

let bothTrue x y => {contents: x && y};

let something = !(bothTrue true true) [@onEverythingToRightOfEquals];
let something =
!(bothTrue true true)
[@onEverythingToRightOfEquals];

let res = add 2 4 [@appliesToEntireFunctionApplication];
let res =
add 2 4 [@appliesToEntireFunctionApplication];

add 2 4 [@appliesToEntireFunctionApplication];

let myObj = {method p () => {method z () => 10}};

let result = (myObj#p () [@attOnFirstSend])#z () [@onSecondSend];
let result =
(myObj#p () [@attOnFirstSend])#z
() [@onSecondSend];

type recordFunctions = {
p: unit => recordFunctions [@onUnit],
Expand All @@ -153,17 +178,29 @@ type recordFunctions = {
[@@onRecordFunctions]
and unusedType = unit [@@onUnusedType];

let rec myRecord = {p: fun () => myRecord, q: fun () => ()}
let rec myRecord = {
p: fun () => myRecord,
q: fun () => ()
}
and unused = ();

let result = (myRecord.p () [@attOnFirstSend]).q () [@onSecondSend];
let result =
(myRecord.p () [@attOnFirstSend]).q
() [@onSecondSend];

type variantType = | Foo of int [@onInt] | Bar of (int [@onInt]) | Baz [@@onVariantType];
type variantType =
| Foo of int [@onInt]
| Bar of (int [@onInt])
| Baz
[@@onVariantType];

type gadtType 'x =
| Foo of int :(gadtType int) [@onFirstRow]
| Bar of (int [@onInt]) :(gadtType unit) [@onSecondRow]
| Baz :(gadtType (unit [@onUnit])) [@onThirdRow]
| Bar of
(int [@onInt])
:(gadtType unit) [@onSecondRow]
| Baz
:(gadtType (unit [@onUnit])) [@onThirdRow]
[@@onVariantType];

[@@@floatingTopLevelStructureItem hello];
Expand Down Expand Up @@ -235,7 +272,10 @@ class tupleClass 'a 'b (init: ('a, 'b)) => {
class type addablePointClassType = {
method x: int;
method y: int;
method add: addablePointClassType => addablePointClassType => int
method add:
addablePointClassType =>
addablePointClassType =>
int
}
[@@structureItem]
and anotherClassType = {
Expand All @@ -244,7 +284,9 @@ and anotherClassType = {
}
[@@structureItem];

let module NestedModule = {[@@@floatingNestedStructureItem hello];};
let module NestedModule = {
[@@@floatingNestedStructureItem hello];
};

module type HasAttrs = {
type t = int [@@onTypeDef];
Expand All @@ -261,13 +303,19 @@ type s = | S of string;

let S (str [@onStr]) = S ("hello" [@onHello]);

let S str [@onConstruction] = S "hello" [@onConstruction];
let S str [@onConstruction] =
S "hello" [@onConstruction];

type xy = | X of string | Y of string;

let myFun (X hello [@onConstruction] | Y hello [@onConstruction]) => hello;
let myFun
(
X hello [@onConstruction] |
Y hello [@onConstruction]
) => hello;

let myFun (X (hello [@onHello]) | Y (hello [@onHello])) => hello;
let myFun
(X (hello [@onHello]) | Y (hello [@onHello])) => hello;

/* Another bug: Cannot have an attribute on or pattern
let myFun = fun ((X hello | Y hello) [@onOrPattern]) => hello;
Expand Down
9 changes: 6 additions & 3 deletions formatTest/typeCheckedTests/expected_output/basics.re
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
type reasonXyz = | X | Y of int int int | Z of int int | Q | R;
type reasonXyz =
| X | Y of int int int | Z of int int | Q | R;

let reasonBarAs =
fun | ((Y _ | Z _) as t, _) => {
Expand Down Expand Up @@ -42,6 +43,8 @@ let (\+) = (+);

let (\===) = (===);

let expectedPrecendence = 1 + 1 \=== 1 + 1 && 1 + 1 !== 1 + 1;
let expectedPrecendence =
1 + 1 \=== 1 + 1 && 1 + 1 !== 1 + 1;

let expectedPrecendence = 1 \+ 1 \=== 1 \+ 1 && 1 \+ 1 !== 1 \+ 1;
let expectedPrecendence =
1 \+ 1 \=== 1 \+ 1 && 1 \+ 1 !== 1 \+ 1;
8 changes: 6 additions & 2 deletions formatTest/typeCheckedTests/expected_output/mlSyntax.re
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
/*
* Testing pattern matching using ml syntax to exercise nesting of cases.
*/
type xyz = | X | Y of int int int | Z of int int | Q | R;
type xyz =
| X | Y of int int int | Z of int int | Q | R;

let doubleBar =
fun | X
Expand Down Expand Up @@ -76,6 +77,9 @@ let nestedSome = Some (1, 2, Some (1, 2, 3));

let nestedSomeSimple = Some (Some (1, 2, 3));

let module EM = {/* Exception */exception E of int int;};
let module EM = {
/* Exception */
exception E of int int;
};

exception Ealias = EM.E;
5 changes: 4 additions & 1 deletion formatTest/typeCheckedTests/expected_output/mlVariants.re
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
type polyVariantsInMl = [ | `IntTuple of (int, int) | `StillAnIntTuple of (int, int)];
type polyVariantsInMl = [
| `IntTuple of (int, int)
| `StillAnIntTuple of (int, int)
];

let intTuple = `IntTuple (1, 2);

Expand Down
10 changes: 8 additions & 2 deletions formatTest/typeCheckedTests/expected_output/mutation.re
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ switch numberToSwitchOn {
| (-1) => ()
| 0 => holdsAUnit.contents = ()
| 1 => holdsAUnit.contents = holdsAnInt := 0
| 2 => true ? holdsAUnit.contents = () : holdsABool.contents ? () : ()
| 3 => true ? holdsAUnit := () : holdsABool.contents ? () : ()
| 2 =>
true ?
holdsAUnit.contents = () :
holdsABool.contents ? () : ()
| 3 =>
true ?
holdsAUnit := () :
holdsABool.contents ? () : ()
| 4 => true ? holdsAnInt := 40 : ()
| 5 => holdsAnInt := 40
| _ => ()
Expand Down
Loading

0 comments on commit 1a0d7c7

Please sign in to comment.