-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hurricup/bugfixes #2891
Merged
Merged
Hurricup/bugfixes #2891
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright 2015-2024 Alexandr Evstigneev | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package unit.perl; | ||
|
||
import base.PerlLightTestCase; | ||
import com.intellij.testFramework.Parameterized; | ||
import com.perl5.lang.perl.util.PerlPackageUtil; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
|
||
@SuppressWarnings("Junit4RunWithInspection") | ||
@RunWith(Parameterized.class) | ||
public class PerlPackageUtilTest extends PerlLightTestCase { | ||
private final @Nullable String myFqn; | ||
private final @Nullable String myPackageName; | ||
private final @Nullable String mySubName; | ||
|
||
public PerlPackageUtilTest(@Nullable String fqn, @Nullable String packageName, @Nullable String subName) { | ||
myFqn = fqn; | ||
myPackageName = packageName; | ||
mySubName = subName; | ||
} | ||
|
||
@Test | ||
public void test() { | ||
var result = PerlPackageUtil.splitNames(myFqn); | ||
if (myFqn == null || myFqn.isEmpty()) { | ||
assertNull(result); | ||
} | ||
else { | ||
assertNotNull(result); | ||
assertEquals(myPackageName, result.getFirst()); | ||
assertEquals(mySubName, result.getSecond()); | ||
} | ||
} | ||
|
||
@org.junit.runners.Parameterized.Parameters(name = "{0}") | ||
public static Iterable<Object[]> fakeData() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Parameterized.Parameters(name = "{0}") | ||
public static Iterable<Object[]> realData(Class<?> clazz) { | ||
return Arrays.asList(new Object[][]{ | ||
{null, null, null}, | ||
{"", null, null}, | ||
{"::subname", "main", "subname"}, | ||
{"Foo::", "Foo", null}, | ||
{"Foo::subname", "Foo", "subname"}, | ||
}); | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
plugin/src/test/java/unit/perl/PerlStackFrameRenderingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright 2015-2024 Alexandr Evstigneev | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package unit.perl; | ||
|
||
import base.PerlLightTestCase; | ||
import com.intellij.testFramework.Parameterized; | ||
import com.intellij.testFramework.UsefulTestCase; | ||
import com.intellij.ui.SimpleTextAttributes; | ||
import com.perl5.lang.perl.debugger.PerlStackFrame; | ||
import com.perl5.lang.perl.debugger.protocol.PerlLoadedFileDescriptor; | ||
import com.perl5.lang.perl.debugger.protocol.PerlStackFrameDescriptor; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
|
||
@SuppressWarnings("Junit4RunWithInspection") | ||
@RunWith(Parameterized.class) | ||
public class PerlStackFrameRenderingTest extends PerlLightTestCase { | ||
private final @NotNull String myName; | ||
private final @NotNull PerlStackFrameDescriptor myFrameDescriptor; | ||
|
||
public PerlStackFrameRenderingTest(@NotNull String name, @NotNull PerlStackFrameDescriptor frameDescriptor) { | ||
myName = name; | ||
myFrameDescriptor = frameDescriptor; | ||
} | ||
|
||
@Override | ||
protected String getBaseDataPath() { | ||
return "unit/perl/stackframerendering"; | ||
} | ||
|
||
@Test | ||
public void test() { | ||
var result = new StringBuilder(); | ||
PerlStackFrame.doCustomizePresentation(myFrameDescriptor, (fragment, attributes) -> { | ||
Check warning Code scanning / QDJVM Statement lambda can be replaced with expression lambda Warning test
Statement lambda can be replaced with expression lambda
|
||
result.append(protectSpaces(fragment)).append(" - ").append(serialize(attributes)).append("\n"); | ||
}); | ||
UsefulTestCase.assertSameLinesWithFile(getTestResultsFilePath(), result.toString()); | ||
} | ||
|
||
protected static @NotNull String serialize(@NotNull SimpleTextAttributes attributes) { | ||
if (attributes == SimpleTextAttributes.REGULAR_ATTRIBUTES) { | ||
return "REGULAR_ATTRIBUTES"; | ||
} | ||
else if (attributes == SimpleTextAttributes.GRAYED_ATTRIBUTES) { | ||
return "GRAYED_ATTRIBUTES"; | ||
} | ||
return attributes.toString(); | ||
} | ||
|
||
@Override | ||
protected @NotNull String computeAnswerFileNameWithoutExtension(@NotNull String appendix) { | ||
return myName.replaceAll("\\W+", "_").toLowerCase() + appendix; | ||
} | ||
|
||
@org.junit.runners.Parameterized.Parameters(name = "{0}") | ||
public static Iterable<Object[]> fakeData() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Parameterized.Parameters(name = "{0}") | ||
public static Iterable<Object[]> realData(Class<?> clazz) { | ||
return Arrays.asList(new Object[][]{ | ||
{"File, fqn and line", new PerlStackFrameDescriptor(new PerlLoadedFileDescriptor("/path/to/file", "Proper::Fqn"), 42)}, | ||
{"File, main fqn and line", new PerlStackFrameDescriptor(new PerlLoadedFileDescriptor("/path/to/file", "::Fqn"), 42)}, | ||
{"fqn and line", new PerlStackFrameDescriptor(new PerlLoadedFileDescriptor("", "Proper::Fqn"), 42)}, | ||
{"File and line", new PerlStackFrameDescriptor(new PerlLoadedFileDescriptor("/path/to/file", null), 42)}, | ||
{"Eval file, fqn and line", | ||
new PerlStackFrameDescriptor(new PerlLoadedFileDescriptor("(eval 26)[eval/path/to/file:7]", "Proper::Fqn"), 42)}, | ||
{"Eval file and line", new PerlStackFrameDescriptor(new PerlLoadedFileDescriptor("(eval 26)[eval/path/to/file:7]", null), 42)}, | ||
}); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
plugin/src/test/resources/unit/perl/stackframerendering/eval_file_and_line.pl.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(eval␣26)[eval/path/to/file:7]:43 - REGULAR_ATTRIBUTES |
3 changes: 3 additions & 0 deletions
3
plugin/src/test/resources/unit/perl/stackframerendering/eval_file_fqn_and_line.pl.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Fqn:43 - REGULAR_ATTRIBUTES | ||
,␣Proper - REGULAR_ATTRIBUTES | ||
␣((eval␣26)[eval/path/to/file:7]) - GRAYED_ATTRIBUTES |
1 change: 1 addition & 0 deletions
1
plugin/src/test/resources/unit/perl/stackframerendering/file_and_line.pl.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/path/to/file:43 - REGULAR_ATTRIBUTES |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / QDJVM
Unused declaration Warning