Skip to content
This repository was archived by the owner on Aug 24, 2022. It is now read-only.
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
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,32 @@
}
);

$.Method({ Static: true, Public: true }, "Repeat",
new JSIL.MethodSignature(
$jsilcore.TypeRef("System.Collections.Generic.IEnumerable`1", ["!!0"]),
["!!0", "System.Int32"],
["TResult"]),
function Repeat$b1(TResult, element, count) {
var i = 0;

return new (JSIL.AbstractEnumerable.Of(TResult))(
function getNext(result) {
if (i < count) {
i++;
result.set(element);
return true;
}
return false;
},
function reset() {
i = 0;
},
function dispose() {
}
);
}
);

$.Method({ Static: true, Public: true }, "Where",
new JSIL.MethodSignature($jsilcore.TypeRef("System.Collections.Generic.IEnumerable`1", ["!!0"]), [$jsilcore.TypeRef("System.Collections.Generic.IEnumerable`1", ["!!0"]), $jsilcore.TypeRef("System.Func`2", ["!!0", $.Boolean])], ["TSource"]),
function Where$b1(TSource, source, predicate) {
Expand Down
13 changes: 13 additions & 0 deletions Tests/SimpleTestCases/EnumerableRepeat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public static class Program {
public static void Main () {

foreach (var x in Enumerable.Repeat("x", 5))
Console.WriteLine(x);

}
}
1 change: 1 addition & 0 deletions Tests/SimpleTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@
<None Include="SimpleTestCases\EnumInPlaceAdd.cs" />
<None Include="SimpleTestCases\EnumerableStringMethod.cs" />
<None Include="SimpleTestCases\EnumerableSkip.cs" />
<None Include="SimpleTestCases\EnumerableRepeat.cs" />
<None Include="SimpleTestCases\UnboxBoolean.cs" />
<None Include="SimpleTestCases\MathIntrinsics.cs" />
<None Include="SimpleTestCases\StringSplitDefaultSeparators.cs" />
Expand Down