Skip to content

Commit

Permalink
Yield - в инсталляторе!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
miks1965 committed Jul 9, 2016
1 parent c6eaba8 commit 88e9937
Show file tree
Hide file tree
Showing 14 changed files with 207 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Configuration/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "1";
public const string Build = "0";
public const string Revision = "1263";
public const string Revision = "1266";

public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
Expand Down
4 changes: 2 additions & 2 deletions Configuration/Version.defs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%COREVERSION%=0
%REVISION%=1263
%MINOR%=1
%REVISION%=1266
%COREVERSION%=0
%MAJOR%=3
2 changes: 1 addition & 1 deletion ReleaseGenerators/PascalABCNET_version.nsh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
!define VERSION '3.1.0.1263'
!define VERSION '3.1.0.1266'
6 changes: 5 additions & 1 deletion ReleaseGenerators/sect_Core.nsh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Section $(DESC_Core) Core
Section $(DESC_Core) Core
SectionIn 1 2 RO
SetOutPath "$INSTDIR"
File ExecHide.exe
Expand All @@ -11,6 +11,8 @@
File "..\bin\SemanticTree.dll"
File "..\bin\SyntaxTree.dll"
File "..\bin\SyntaxTreeConverters.dll"
File "..\bin\SyntaxVisitors.dll"
File "..\bin\YieldConversionSyntax.dll"
File "..\bin\YieldHelpers.dll"
File "..\bin\ICSharpCode.NRefactory.dll"
File "..\bin\TreeConverter.dll"
Expand Down Expand Up @@ -47,6 +49,8 @@
${AddFile} "SyntaxTree.dll"
${AddFile} "SyntaxTreeConverters.dll"
${AddFile} "YieldHelpers.dll"
${AddFile} "SyntaxVisitors.dll"
${AddFile} "YieldConversionSyntax.dll"
${AddFile} "ICSharpCode.NRefactory.dll"
${AddFile} "TreeConverter.dll"
${AddFile} "OptimizerConversion.dll"
Expand Down
31 changes: 31 additions & 0 deletions TestSuite/yield1.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
function Sq1: sequence of integer;
begin
yield 1;
yield 5;
end;

function Squares(n: integer): sequence of integer;
begin
for var i:=1 to n do
yield i*i;
yield 666;
begin
yield 777;
end;
end;

function Sq2(n: integer): sequence of integer;
begin
for var i:=1 to n do
begin
yield i;
yield i;
end;
end;


begin
Assert(Sq1.SequenceEqual(Seq(1,5)));
Assert(Squares(5).SequenceEqual(Seq(1,4,9,16,25,666,777)),'not Squares(5).SequenceEqual(Seq(1,4,9,16,25))');
Assert(Sq2(5).SequenceEqual(Seq(1,1,2,2,3,3,4,4,5,5)));
end.
21 changes: 21 additions & 0 deletions TestSuite/yieldcapture1.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
var z:=1;

type AAA = class
y: integer := 1;
function f(a: sequence of integer): sequence of integer;
begin
var k: integer = 1;
foreach var x in a do
yield x+y+z+k;
end;
end;

begin
var a1 := new AAA();

var q := a1.f(Range(1,4));

var sq := Seq(4,5,6,7);
Assert(q.Println.SequenceEqual(sq));
Assert(q.Println.SequenceEqual(sq));
end.
20 changes: 20 additions & 0 deletions TestSuite/yieldcase.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function Sq(n: integer): sequence of integer;
begin
for var i:=1 to n do
case i mod 3 of
0: yield 22;
1: yield 33;
2: yield 44;
end;
yield 55;
end;

procedure AssertSeq<T>(q,correct: sequence of T);
begin
Assert(q.SequenceEqual(correct),q.JoinIntoString);
end;


begin
AssertSeq(Sq(5).Println,Seq(33,44,22,33,44,55));
end.
28 changes: 28 additions & 0 deletions TestSuite/yieldcasediap.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function f(n: integer): sequence of integer;
begin
var m := n;
case m of
1: begin
yield 3;
for var i:=1 to 5 do
yield i;
end;
2: for var i:=1 to 5 do
case i of
1,2,3: yield 4;
4..20: yield -1
end;
else yield 5;
end;
end;

procedure AssertSeq<T>(q,correct: sequence of T);
begin
Assert(q.SequenceEqual(correct),q.JoinIntoString);
end;

begin
AssertSeq(f(1).Println,Seq(3,1,2,3,4,5));
AssertSeq(f(2).Println,Seq(4,4,4,-1,-1));
AssertSeq(f(3).Println,Seq(5));
end.
32 changes: 32 additions & 0 deletions TestSuite/yieldfor1.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function Sq1: sequence of integer;
begin
yield 1;
yield 5;
end;

function Squares(n: integer): sequence of integer;
begin
for var i:=1 to n do
yield i*i;
yield 666;
begin
yield 777;
end;
end;

function Sq2(n: integer): sequence of integer;
begin
yield(555);
for var i:=1 to n do
begin
yield i;
yield i;
end;
end;


begin
Assert(Sq1.SequenceEqual(Seq(1,5)),'1');
Assert(Squares(5).SequenceEqual(Seq(1,4,9,16,25,666,777)),'not Squares(5).SequenceEqual(Seq(1,4,9,16,25))');
Assert(Sq2(5).SequenceEqual(Seq(555,1,1,2,2,3,3,4,4,5,5)),'3');
end.
13 changes: 13 additions & 0 deletions TestSuite/yieldforfor.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function Sq(n: integer): sequence of integer;
begin
for var i:=1 to n do
for var j:=1 to n do
begin
yield i*j;
end;
end;


begin
Assert(Sq(3).SequenceEqual(Seq(1,2,3,2,4,6,3,6,9)),Sq(3).JoinIntoString);
end.
22 changes: 22 additions & 0 deletions TestSuite/yieldif.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function Sq(n: integer): sequence of integer;
begin
if n mod 2 = 0 then
yield 555
else yield 444;
end;

function Where1<T>(s: sequence of T; p: T->boolean): sequence of T;
begin
foreach var x in s do
//if p(x) then
yield x;
end;

begin
Assert(Sq(2).SequenceEqual(Seq(555)),Sq(2).JoinIntoString);
Assert(Sq(1).SequenceEqual(Seq(444)),Sq(2).JoinIntoString);
var q := Where1(Arr(1,2,3,4),x->x mod 2 <>0);
q.Println;
//q.Println;
//Assert(q.SequenceEqual(Seq(444)),q.JoinIntoString);
end.
13 changes: 13 additions & 0 deletions TestSuite/yieldquerytwice.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function f<T>(a: sequence of T): sequence of T;
begin
foreach var x in a do
yield x;
end;

begin
var q := f(Range(1,4));

var sq := Seq(1,2,3,4);
Assert(q.Println.SequenceEqual(sq));
Assert(q.Println.SequenceEqual(sq));
end.
18 changes: 18 additions & 0 deletions TestSuite/yieldwhilerepeat.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function Sq(n: integer): sequence of integer;
begin
var i:=1;
while i<=n do
begin
yield i;
i += 1;
end;
repeat
yield i;
i -= 1;
until i<=0;
end;


begin
Assert(Sq(3).SequenceEqual(Seq(1,2,3,4,3,2,1)),Sq(3).JoinIntoString);
end.
Binary file modified bin/Lib/PABCRtl.dll
Binary file not shown.

0 comments on commit 88e9937

Please sign in to comment.