Skip to content

Commit 06118ee

Browse files
committed
AS3 Implement interface test with no public members.
Added files for some future Haxe tests.
1 parent 755a44c commit 06118ee

10 files changed

+209
-2
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11

2-
3-
/* INTERFACE $(Class) */
2+
$(BlankLine)/* INTERFACE $(Class) */

Tests/External/Plugins/ASCompletion.Tests/ASCompletion.Tests.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@
141141
<EmbeddedResource Include="Test Files\parser\haxe\IdentifiersWithUnicodeCharsTest.hx" />
142142
<EmbeddedResource Include="Test Files\generated\as3\BeforeImplementInterfacePublicMemberBehindPrivate.as" />
143143
<EmbeddedResource Include="Test Files\generated\as3\ImplementInterfacePublicMemberBehindPrivate.as" />
144+
<EmbeddedResource Include="Test Files\generated\as3\BeforeImplementInterfaceNoPublicMember.as" />
145+
<EmbeddedResource Include="Test Files\generated\as3\ImplementInterfaceNoPublicMember.as" />
146+
<EmbeddedResource Include="Test Files\generated\haxe\BeforeImplementInterfaceNoPublicMember.hx" />
147+
<EmbeddedResource Include="Test Files\generated\haxe\BeforeImplementInterfacePublicMemberBehindPrivate.hx" />
148+
<EmbeddedResource Include="Test Files\generated\haxe\ImplementInterfaceNoMembers.hx" />
149+
<EmbeddedResource Include="Test Files\generated\haxe\ImplementInterfaceNoPublicMember.hx" />
150+
<EmbeddedResource Include="Test Files\generated\haxe\ImplementInterfacePublicMemberBehindPrivate.hx" />
144151
</ItemGroup>
145152
<ItemGroup>
146153
<ProjectReference Include="..\..\..\..\External\Plugins\AS2Context\AS2Context.csproj">

Tests/External/Plugins/ASCompletion.Tests/Completion/ASGeneratorTests.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,54 @@ public void ImplementFromInterface_FullAs3WithPublicMemberBehindPrivate()
302302
ASGenerator.GenerateJob(GeneratorJobType.ImplementInterface, null, classModel, null, null);
303303
Assert.AreEqual(TestFile.ReadAllText("ASCompletion.Test_Files.generated.as3.ImplementInterfacePublicMemberBehindPrivate.as"), sci.Text);
304304
}
305+
306+
[Test]
307+
public void ImplementFromInterface_FullAs3WithoutPublicMember()
308+
{
309+
var interfaceModel = new Model.ClassModel { InFile = new Model.FileModel(), Name = "ITest", Type = "ITest" };
310+
var classModel = new Model.ClassModel { InFile = new Model.FileModel(), LineFrom = 1, LineTo = 10 };
311+
var pluginMain = Substitute.For<PluginMain>();
312+
var pluginUiMock = new PluginUIMock(pluginMain);
313+
pluginMain.MenuItems.Returns(new List<System.Windows.Forms.ToolStripItem>());
314+
pluginMain.Settings.Returns(new GeneralSettings());
315+
pluginMain.Panel.Returns(pluginUiMock);
316+
ASContext.GlobalInit(pluginMain);
317+
ASContext.Context = Substitute.For<IASContext>();
318+
ASContext.Context.ResolveType(null, null).ReturnsForAnyArgs(interfaceModel);
319+
ASContext.Context.Features.voidKey = "void";
320+
321+
var sci = GetBaseScintillaControl();
322+
sci.Text = TestFile.ReadAllText("ASCompletion.Test_Files.generated.as3.BeforeImplementInterfaceNoPublicMember.as");
323+
sci.ConfigurationLanguage = "as3";
324+
doc.SciControl.Returns(sci);
325+
326+
classModel.Members.Add(new Model.MemberList
327+
{
328+
new Model.MemberModel("privateMember", "String", Model.FlagType.Function, Model.Visibility.Private)
329+
{LineFrom = 3, LineTo = 5}
330+
});
331+
332+
interfaceModel.Members.Add(new Model.MemberList
333+
{
334+
new Model.MemberModel("getter", "String", Model.FlagType.Getter, Model.Visibility.Public),
335+
new Model.MemberModel("setter", "void", Model.FlagType.Setter, Model.Visibility.Public)
336+
{
337+
Parameters = new List<Model.MemberModel> { new Model.MemberModel("value", "String", Model.FlagType.Variable, Model.Visibility.Default) }
338+
},
339+
new Model.MemberModel("testMethod", "Number", Model.FlagType.Function, Model.Visibility.Public),
340+
new Model.MemberModel("testMethodArgs", "int", Model.FlagType.Function, Model.Visibility.Public)
341+
{
342+
Parameters = new List<Model.MemberModel>
343+
{
344+
new Model.MemberModel("arg", "Number", Model.FlagType.Variable, Model.Visibility.Default),
345+
new Model.MemberModel("arg2", "Boolean", Model.FlagType.Variable, Model.Visibility.Default)
346+
}
347+
}
348+
});
349+
350+
ASGenerator.GenerateJob(GeneratorJobType.ImplementInterface, null, classModel, null, null);
351+
Assert.AreEqual(TestFile.ReadAllText("ASCompletion.Test_Files.generated.as3.ImplementInterfaceNoPublicMember.as"), sci.Text);
352+
}
305353
}
306354

307355
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package generatortest {
2+
public class ImplementTest{
3+
4+
private function privateMember():String
5+
{
6+
}
7+
}
8+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package generatortest {
2+
public class ImplementTest{
3+
4+
private function privateMember():String
5+
{
6+
}
7+
8+
9+
/* INTERFACE ITest */
10+
11+
public function get getter():String {
12+
return _getter;
13+
}
14+
15+
public function set setter(value:String):void {
16+
_setter = value;
17+
}
18+
19+
public function testMethod():Number {
20+
21+
}
22+
23+
public function testMethodArgs(arg:Number, arg2:Boolean):int {
24+
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package generatortest {
2+
public class ImplementTest{
3+
4+
private function privateMember():String
5+
{
6+
}
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package generatortest {
2+
public class ImplementTest{
3+
4+
public function publicMember():void
5+
{
6+
}
7+
8+
private function privateMember():String
9+
{
10+
}
11+
}
12+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package generatortest;
2+
3+
class ImplementTest{
4+
5+
/* INTERFACE ITest */
6+
7+
public var normalVariable():Int;
8+
9+
public var ro(default, null):Int;
10+
11+
public var wo(null, default):Int;
12+
13+
@:isVar public var x(get, set):Int;
14+
15+
get_x():Int {
16+
return x;
17+
}
18+
19+
set_x(val:Int):Int {
20+
return x = val;
21+
}
22+
23+
public var y(get, never):Int;
24+
25+
function get_y():Int {
26+
return y;
27+
}
28+
29+
public function testMethod():Number {
30+
31+
}
32+
33+
public function testMethodArgs(arg:Float, arg2:Bool):Int {
34+
35+
}
36+
37+
private function testPrivateMethod(?arg:String, ?arg2:Int = 1):Number {
38+
39+
}
40+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package generatortest {
2+
public class ImplementTest{
3+
4+
private function privateMember():String
5+
{
6+
}
7+
8+
9+
/* INTERFACE ITest */
10+
11+
public function get getter():String {
12+
return _getter;
13+
}
14+
15+
public function set setter(value:String):void {
16+
_setter = value;
17+
}
18+
19+
public function testMethod():Number {
20+
21+
}
22+
23+
public function testMethodArgs(arg:Number, arg2:Boolean):int {
24+
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package generatortest {
2+
public class ImplementTest{
3+
4+
public function publicMember():void
5+
{
6+
}
7+
8+
9+
/* INTERFACE ITest */
10+
11+
public function get getter():String {
12+
return _getter;
13+
}
14+
15+
public function set setter(value:String):void {
16+
_setter = value;
17+
}
18+
19+
public function testMethod():Number {
20+
21+
}
22+
23+
public function testMethodArgs(arg:Number, arg2:Boolean):int {
24+
25+
}
26+
27+
private function privateMember():String
28+
{
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)