Skip to content

Commit

Permalink
adding tests for indent formatting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
m0rkeulv committed Feb 4, 2024
1 parent 2889a94 commit aea8bd8
Show file tree
Hide file tree
Showing 6 changed files with 379 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog
## 1.4.30
* Fixed: Issue where classes with identical names as Enum values would resolve to enum value
* Added: Indent options under haxe code style (PR #1148 from virtulis)
*
## 1.4.30
* Fixed: Resolver bug

## 1.4.29
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,19 @@ public void testCommentAlignmentKeepLeft() throws Exception {
myTestStyleSettings.KEEP_FIRST_COLUMN_COMMENT = true;
doTest();
}
@Test
public void testIndentTabs() throws Exception {
myTestStyleSettings.getIndentOptions().USE_TAB_CHARACTER = true;
myTestStyleSettings.getIndentOptions().INDENT_SIZE = 1;
myTestStyleSettings.getIndentOptions().TAB_SIZE = 1;
doTest();
}
@Test
public void testIndentSpaces() throws Exception {
myTestStyleSettings.getIndentOptions().USE_TAB_CHARACTER = false;
myTestStyleSettings.getIndentOptions().INDENT_SIZE = 3;
doTest();
}

@Test
public void testLineFeedsWithComments() throws Exception {
Expand Down
91 changes: 91 additions & 0 deletions src/test/resources/testData/formatter/IndentSpaces.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import com.Foo;using com.utils.MathUtil;class Foo{
// function fBar (x,y);
function fOne(argA:Int,
argB, argC, argD,
argE, argF, argG, argH ){
var numbers:Array< String> = ['one',
'two',
'three', 'four', 'five', 'six'];
var x = ("" + argA) + argB +
argC + argD + argE + argF + argG + argH;
try {
this.fTwo (argA, argB, argC,
this.fThree( "", argE, argF, argG, argH));
} catch (ignored:String) {

}
var z = argA == 'Some string' ? 'yes' : 'no';
var colors = ['red', 'green', 'blue', 'black', 'white', 'gray'];
for (colorIndex in 0...colors.length) {
var colorString = numbers[colorIndex];
}
do {
colors.pop ();
}
while (colors. length > 0);
}

function fTwo(strA, strB, strC, strD) {
if (true)
return strC;
if (strA == 'one' || strB == 'two') {
return strA + strB;
}else
if (true)
return strD;
throw strD;
}

function fThree ( strA , strB, strC, strD, strE ){
return strA + strB + strC + strD + strE;
}
public function new ( ) {
switch( v ) {
case 0:
e1();
case foo(1):
break;
case 65, 90:
e3();
default:
return;
}
}


static public function getBrowser(browserAgent:String):String {
if (browserAgent != null)
{
if (browserAgent.indexOf("Firefox")
>= 0) {

_browser = Browser_firefox;
}

else
if (browserAgent.indexOf("Safari") >= 0) {
_browser = Browser_safari;
}

else
if (browserAgent.indexOf("MSIE") >= 0) {
_browser = Browser_ie;
}

else if (browserAgent.indexOf("Opera") >= 0) {
_browser = Browser_opera;
}

else {
_browser = Browser_unknown;
}

}

else {
_browser = Browser_unknown;
}

return browser;
}
}
90 changes: 90 additions & 0 deletions src/test/resources/testData/formatter/IndentSpaces.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import com.Foo;
using com.utils.MathUtil;
class Foo {
// function fBar (x,y);
function fOne(argA:Int,
argB, argC, argD,
argE, argF, argG, argH) {
var numbers:Array< String> = ['one',
'two',
'three', 'four', 'five', 'six'];
var x = ("" + argA) + argB +
argC + argD + argE + argF + argG + argH;
try {
this.fTwo(argA, argB, argC,
this.fThree("", argE, argF, argG, argH));
} catch (ignored:String) {

}
var z = argA == 'Some string' ? 'yes' : 'no';
var colors = ['red', 'green', 'blue', 'black', 'white', 'gray'];
for (colorIndex in 0...colors.length) {
var colorString = numbers[colorIndex];
}
do {
colors.pop();
}
while (colors. length > 0);
}

function fTwo(strA, strB, strC, strD) {
if (true)
return strC;
if (strA == 'one' || strB == 'two') {
return strA + strB;
} else if (true)
return strD;
throw strD;
}

function fThree(strA, strB, strC, strD, strE) {
return strA + strB + strC + strD + strE;
}

public function new() {
switch( v ) {
case 0:
e1();
case foo(1):
break;
case 65, 90:
e3();
default:
return;
}
}


static public function getBrowser(browserAgent:String):String {
if (browserAgent != null) {
if (browserAgent.indexOf("Firefox")
>= 0) {

_browser = Browser_firefox;
}

else if (browserAgent.indexOf("Safari") >= 0) {
_browser = Browser_safari;
}

else if (browserAgent.indexOf("MSIE") >= 0) {
_browser = Browser_ie;
}

else if (browserAgent.indexOf("Opera") >= 0) {
_browser = Browser_opera;
}

else {
_browser = Browser_unknown;
}

}

else {
_browser = Browser_unknown;
}

return browser;
}
}
91 changes: 91 additions & 0 deletions src/test/resources/testData/formatter/IndentTabs.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import com.Foo;using com.utils.MathUtil;class Foo{
// function fBar (x,y);
function fOne(argA:Int,
argB, argC, argD,
argE, argF, argG, argH ){
var numbers:Array< String> = ['one',
'two',
'three', 'four', 'five', 'six'];
var x = ("" + argA) + argB +
argC + argD + argE + argF + argG + argH;
try {
this.fTwo (argA, argB, argC,
this.fThree( "", argE, argF, argG, argH));
} catch (ignored:String) {

}
var z = argA == 'Some string' ? 'yes' : 'no';
var colors = ['red', 'green', 'blue', 'black', 'white', 'gray'];
for (colorIndex in 0...colors.length) {
var colorString = numbers[colorIndex];
}
do {
colors.pop ();
}
while (colors. length > 0);
}

function fTwo(strA, strB, strC, strD) {
if (true)
return strC;
if (strA == 'one' || strB == 'two') {
return strA + strB;
}else
if (true)
return strD;
throw strD;
}

function fThree ( strA , strB, strC, strD, strE ){
return strA + strB + strC + strD + strE;
}
public function new ( ) {
switch( v ) {
case 0:
e1();
case foo(1):
break;
case 65, 90:
e3();
default:
return;
}
}


static public function getBrowser(browserAgent:String):String {
if (browserAgent != null)
{
if (browserAgent.indexOf("Firefox")
>= 0) {

_browser = Browser_firefox;
}

else
if (browserAgent.indexOf("Safari") >= 0) {
_browser = Browser_safari;
}

else
if (browserAgent.indexOf("MSIE") >= 0) {
_browser = Browser_ie;
}

else if (browserAgent.indexOf("Opera") >= 0) {
_browser = Browser_opera;
}

else {
_browser = Browser_unknown;
}

}

else {
_browser = Browser_unknown;
}

return browser;
}
}
90 changes: 90 additions & 0 deletions src/test/resources/testData/formatter/IndentTabs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import com.Foo;
using com.utils.MathUtil;
class Foo {
// function fBar (x,y);
function fOne(argA:Int,
argB, argC, argD,
argE, argF, argG, argH) {
var numbers:Array< String> = ['one',
'two',
'three', 'four', 'five', 'six'];
var x = ("" + argA) + argB +
argC + argD + argE + argF + argG + argH;
try {
this.fTwo(argA, argB, argC,
this.fThree("", argE, argF, argG, argH));
} catch (ignored:String) {

}
var z = argA == 'Some string' ? 'yes' : 'no';
var colors = ['red', 'green', 'blue', 'black', 'white', 'gray'];
for (colorIndex in 0...colors.length) {
var colorString = numbers[colorIndex];
}
do {
colors.pop();
}
while (colors. length > 0);
}

function fTwo(strA, strB, strC, strD) {
if (true)
return strC;
if (strA == 'one' || strB == 'two') {
return strA + strB;
} else if (true)
return strD;
throw strD;
}

function fThree(strA, strB, strC, strD, strE) {
return strA + strB + strC + strD + strE;
}

public function new() {
switch( v ) {
case 0:
e1();
case foo(1):
break;
case 65, 90:
e3();
default:
return;
}
}


static public function getBrowser(browserAgent:String):String {
if (browserAgent != null) {
if (browserAgent.indexOf("Firefox")
>= 0) {

_browser = Browser_firefox;
}

else if (browserAgent.indexOf("Safari") >= 0) {
_browser = Browser_safari;
}

else if (browserAgent.indexOf("MSIE") >= 0) {
_browser = Browser_ie;
}

else if (browserAgent.indexOf("Opera") >= 0) {
_browser = Browser_opera;
}

else {
_browser = Browser_unknown;
}

}

else {
_browser = Browser_unknown;
}

return browser;
}
}

0 comments on commit aea8bd8

Please sign in to comment.