Add special case for comment at top of file; regenerate snapshots

This commit is contained in:
James Long committed 2017-01-09 21:49:26 -05:00
1 parent 74fc539e1a
commit a4643f1bae
365 files changed
+7437 -6418

No files matched your search

+19 -11
View File
@@ -58,27 +58,24 @@ function from_test() {
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
// Error
/* Adapted from the following source:
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
*/
/* Added later, because the above is insufficient */
// acc is element type of array when no init is provided
// error, string ~> number
// error, string ~> number
function foo(x: string) {}
var a = [ 0 ];
var b = a.map(function(x) {
foo(x);
return \"\" + x;
});
var c: number = a[0];
var d: number = b[0];
var e: Array<string> = a.reverse();
var f = [ \"\" ];
var g: number = f.map(function() {
return 0;
})[0];
var h: Array<number> = [ 1, 2, 3 ];
var i: Array<string> = [ \"a\", \"b\", \"c\" ];
var j: Array<number | string> = h.concat(i);
@@ -86,25 +83,37 @@ var k: Array<number> = h.concat(h);
var l: Array<number> = h.concat(1, 2, 3);
var m: Array<number | string> = h.concat(\"a\", \"b\", \"c\");
var n: Array<number> = h.concat(\"a\", \"b\", \"c\");
// Error
function reduce_test() {
/* Adapted from the following source:
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
*/
[ 0, 1, 2, 3, 4 ].reduce(function(previousValue, currentValue, index, array) {
return previousValue + currentValue + array[index];
});
[ 0, 1, 2, 3, 4 ].reduce(
function(previousValue, currentValue, index, array) {
return previousValue + currentValue + array[index];
},
10
);
var total = [ 0, 1, 2, 3 ].reduce(function(a, b) {
return a + b;
});
var flattened = [ [ 0, 1 ], [ 2, 3 ], [ 4, 5 ] ].reduce(function(a, b) {
return a.concat(b);
});
/* Added later, because the above is insufficient */
// acc is element type of array when no init is provided
[ \"\" ].reduce((acc, str) => acc * str.length);
[ \"\" ].reduceRight((acc, str) => acc * str.length);
// error, string ~> number
[ \"\" ].reduceRight((acc, str) => acc * str.length); // error, string ~> number
}
function from_test() {
var a: Array<string> = Array.from([ 1, 2, 3 ], function(val, index) {
return index % 2 ? \"foo\" : String(val);
@@ -112,6 +121,5 @@ function from_test() {
var b: Array<string> = Array.from([ 1, 2, 3 ], function(val) {
return String(val);
});
}
"
}"
`;