From 0fbc754bcda494ea369f0f996da6d1d461e6ed42 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 12 Dec 2024 02:22:47 +0300 Subject: [PATCH 01/16] #3644: check existence --- eo-runtime/pom.xml | 2 + .../src/test/groovy/check-target-files.groovy | 43 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 eo-runtime/src/test/groovy/check-target-files.groovy diff --git a/eo-runtime/pom.xml b/eo-runtime/pom.xml index 208627d689..56a2406a6e 100644 --- a/eo-runtime/pom.xml +++ b/eo-runtime/pom.xml @@ -250,6 +250,8 @@ SOFTWARE. test ${project.basedir}/src/test/eo ${project.basedir}/target/eo-test + ${project.basedir}/target/eo-test/2-optimize + ${project.basedir}/target/eo-test/phi false true false diff --git a/eo-runtime/src/test/groovy/check-target-files.groovy b/eo-runtime/src/test/groovy/check-target-files.groovy new file mode 100644 index 0000000000..bad2a27ae7 --- /dev/null +++ b/eo-runtime/src/test/groovy/check-target-files.groovy @@ -0,0 +1,43 @@ +/** + * The MIT License (MIT) + * + * Copyright (c) 2016-2024 Objectionary.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +List expected = [ + 'eo/1-parse/bytes.xmir', + 'eo/1-parse/fs/dir.xmir', + 'eo/2-optimize/error.xmir', + 'eo/2-optimize/sys/os.xmir', + 'eo/6-lint/go.xmir', + 'eo/8-transpile/malloc.xmir', + 'eo/phi/number.phi', + 'eo-test/1-parse/bool-tests.xmir', + 'eo-test/2-optimize/go-tests.xmir', + 'eo-test/6-lint/dataized-tests.xmir', + 'eo-test/8-transpile/runtime-tests.xmir', + 'eo-test/phi/number-tests.phi', +] +for (path in expected) { + if (new File(path).exists()) { + fail(String.format("The file '%s' is not present", path)) + } +} From 34ac8af280e8489d98a5455465f85f910dd54e86 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 12 Dec 2024 02:25:52 +0300 Subject: [PATCH 02/16] #3644: fmt --- eo-runtime/src/test/groovy/check-target-files.groovy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/eo-runtime/src/test/groovy/check-target-files.groovy b/eo-runtime/src/test/groovy/check-target-files.groovy index bad2a27ae7..76bcd9dbc2 100644 --- a/eo-runtime/src/test/groovy/check-target-files.groovy +++ b/eo-runtime/src/test/groovy/check-target-files.groovy @@ -36,8 +36,9 @@ List expected = [ 'eo-test/8-transpile/runtime-tests.xmir', 'eo-test/phi/number-tests.phi', ] + for (path in expected) { - if (new File(path).exists()) { - fail(String.format("The file '%s' is not present", path)) - } + if (new File(path).exists()) { + fail("The file '${path}' is not present") + } } From 99bfa39cfe41b5406017cf86527790e5960932a2 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 12 Dec 2024 02:34:54 +0300 Subject: [PATCH 03/16] #3644: codenarc cfg --- .codenarc | 455 +++++++++++++++++++++++++++++++++ .github/workflows/codenarc.yml | 2 +- 2 files changed, 456 insertions(+), 1 deletion(-) create mode 100644 .codenarc diff --git a/.codenarc b/.codenarc new file mode 100644 index 0000000000..61b97d3b9b --- /dev/null +++ b/.codenarc @@ -0,0 +1,455 @@ +ruleset { + // rulesets/basic.xml + AssertWithinFinallyBlock + AssignmentInConditional + BigDecimalInstantiation + BitwiseOperatorInConditional + BooleanGetBoolean + BrokenNullCheck + BrokenOddnessCheck + ClassForName + ComparisonOfTwoConstants + ComparisonWithSelf + ConstantAssertExpression + ConstantIfExpression + ConstantTernaryExpression + DeadCode + DoubleNegative + DuplicateCaseStatement + DuplicateMapKey + DuplicateSetValue + EmptyCatchBlock + EmptyClass + EmptyElseBlock + EmptyFinallyBlock + EmptyForStatement + EmptyIfStatement + EmptyInstanceInitializer + EmptyMethod + EmptyStaticInitializer + EmptySwitchStatement + EmptySynchronizedStatement + EmptyTryBlock + EmptyWhileStatement + EqualsAndHashCode + EqualsOverloaded + ExplicitGarbageCollection + ForLoopShouldBeWhileLoop + HardCodedWindowsFileSeparator + HardCodedWindowsRootDirectory + IntegerGetInteger + MultipleUnaryOperators + ParameterAssignmentInFilterClosure + RandomDoubleCoercedToZero + RemoveAllOnSelf + ReturnFromFinallyBlock + ThrowExceptionFromFinallyBlock + + // rulesets/braces.xml + ElseBlockBraces + ForStatementBraces + IfStatementBraces + WhileStatementBraces + + // rulesets/comments.xml + ClassJavadoc + JavadocConsecutiveEmptyLines + JavadocEmptyAuthorTag + JavadocEmptyExceptionTag + JavadocEmptyFirstLine + JavadocEmptyLastLine + JavadocEmptyParamTag + JavadocEmptyReturnTag + JavadocEmptySeeTag + JavadocEmptySinceTag + JavadocEmptyThrowsTag + JavadocEmptyVersionTag + JavadocMissingExceptionDescription + JavadocMissingParamDescription + JavadocMissingThrowsDescription + SpaceAfterCommentDelimiter + SpaceBeforeCommentDelimiter + + // rulesets/concurrency.xml + BusyWait + DoubleCheckedLocking + InconsistentPropertyLocking + InconsistentPropertySynchronization + NestedSynchronization + NoScriptBindings + StaticCalendarField + StaticConnection + StaticDateFormatField + StaticMatcherField + StaticSimpleDateFormatField + SynchronizedMethod + SynchronizedOnBoxedPrimitive + SynchronizedOnGetClass + SynchronizedOnReentrantLock + SynchronizedOnString + SynchronizedOnThis + SynchronizedReadObjectMethod + SystemRunFinalizersOnExit + ThisReferenceEscapesConstructor + ThreadGroup + ThreadLocalNotStaticFinal + ThreadYield + UseOfNotifyMethod + VolatileArrayField + VolatileLongOrDoubleField + WaitOutsideOfWhileLoop + + // rulesets/convention.xml + CompileStatic + ConfusingTernary + CouldBeElvis + CouldBeSwitchStatement + FieldTypeRequired + HashtableIsObsolete + IfStatementCouldBeTernary + ImplicitClosureParameter + ImplicitReturnStatement + InvertedCondition + InvertedIfElse + LongLiteralWithLowerCaseL + MethodParameterTypeRequired + MethodReturnTypeRequired + NoDef + NoDouble + NoFloat + NoJavaUtilDate + NoTabCharacter + ParameterReassignment + PublicMethodsBeforeNonPublicMethods + StaticFieldsBeforeInstanceFields + StaticMethodsBeforeInstanceMethods + TernaryCouldBeElvis + TrailingComma + VariableTypeRequired + VectorIsObsolete + + // rulesets/design.xml + AbstractClassWithPublicConstructor + AbstractClassWithoutAbstractMethod + AssignmentToStaticFieldFromInstanceMethod + BooleanMethodReturnsNull + BuilderMethodWithSideEffects + CloneableWithoutClone + CloseWithoutCloseable + CompareToWithoutComparable + ConstantsOnlyInterface + EmptyMethodInAbstractClass + FinalClassWithProtectedMember + ImplementationAsType + Instanceof + LocaleSetDefault + NestedForLoop + OptionalCollectionReturnType + OptionalField + OptionalMethodParameter + PrivateFieldCouldBeFinal + PublicInstanceField + ReturnsNullInsteadOfEmptyArray + ReturnsNullInsteadOfEmptyCollection + SimpleDateFormatMissingLocale + StatelessSingleton + ToStringReturnsNull + + // rulesets/dry.xml + DuplicateListLiteral + DuplicateMapLiteral + DuplicateNumberLiteral + DuplicateStringLiteral + + // rulesets/enhanced.xml + CloneWithoutCloneable + JUnitAssertEqualsConstantActualValue + MissingOverrideAnnotation + UnsafeImplementationAsMap + + // rulesets/exceptions.xml + CatchArrayIndexOutOfBoundsException + CatchError + CatchException + CatchIllegalMonitorStateException + CatchIndexOutOfBoundsException + CatchNullPointerException + CatchRuntimeException + CatchThrowable + ConfusingClassNamedException + ExceptionExtendsError + ExceptionExtendsThrowable + ExceptionNotThrown + MissingNewInThrowStatement + ReturnNullFromCatchBlock + SwallowThreadDeath + ThrowError + ThrowException + ThrowNullPointerException + ThrowRuntimeException + ThrowThrowable + + // rulesets/formatting.xml + BlankLineBeforePackage + BlockEndsWithBlankLine + BlockStartsWithBlankLine + BracesForClass + BracesForForLoop + BracesForIfElse + BracesForMethod + BracesForTryCatchFinally + ClassEndsWithBlankLine + ClassStartsWithBlankLine + ClosureStatementOnOpeningLineOfMultipleLineClosure + ConsecutiveBlankLines + FileEndsWithoutNewline + Indentation + LineLength + MissingBlankLineAfterImports + MissingBlankLineAfterPackage + MissingBlankLineBeforeAnnotatedField + SpaceAfterCatch + SpaceAfterClosingBrace + SpaceAfterComma + SpaceAfterFor + SpaceAfterIf + SpaceAfterMethodCallName + SpaceAfterMethodDeclarationName + SpaceAfterNotOperator + SpaceAfterOpeningBrace + SpaceAfterSemicolon + SpaceAfterSwitch + SpaceAfterWhile + SpaceAroundClosureArrow + SpaceAroundMapEntryColon + SpaceAroundOperator + SpaceBeforeClosingBrace + SpaceBeforeOpeningBrace + SpaceInsideParentheses + TrailingWhitespace + + // rulesets/generic.xml + IllegalClassMember + IllegalClassReference + IllegalPackageReference + IllegalRegex + IllegalString + IllegalSubclass + RequiredRegex + RequiredString + StatelessClass + + // rulesets/grails.xml + GrailsDomainGormMethods + GrailsDomainHasEquals + GrailsDomainHasToString + GrailsDomainReservedSqlKeywordName + GrailsDomainStringPropertyMaxSize + GrailsDomainWithServiceReference + GrailsDuplicateConstraint + GrailsDuplicateMapping + GrailsMassAssignment + GrailsPublicControllerMethod + GrailsServletContextReference + GrailsStatelessService + + // rulesets/groovyism.xml + AssignCollectionSort + AssignCollectionUnique + ClosureAsLastMethodParameter + CollectAllIsDeprecated + ConfusingMultipleReturns + ExplicitArrayListInstantiation + ExplicitCallToAndMethod + ExplicitCallToCompareToMethod + ExplicitCallToDivMethod + ExplicitCallToEqualsMethod + ExplicitCallToGetAtMethod + ExplicitCallToLeftShiftMethod + ExplicitCallToMinusMethod + ExplicitCallToModMethod + ExplicitCallToMultiplyMethod + ExplicitCallToOrMethod + ExplicitCallToPlusMethod + ExplicitCallToPowerMethod + ExplicitCallToPutAtMethod + ExplicitCallToRightShiftMethod + ExplicitCallToXorMethod + ExplicitHashMapInstantiation + ExplicitHashSetInstantiation + ExplicitLinkedHashMapInstantiation + ExplicitLinkedListInstantiation + ExplicitStackInstantiation + ExplicitTreeSetInstantiation + GStringAsMapKey + GStringExpressionWithinString + GetterMethodCouldBeProperty + GroovyLangImmutable + UseCollectMany + UseCollectNested + + // rulesets/imports.xml + DuplicateImport + ImportFromSamePackage + ImportFromSunPackages + MisorderedStaticImports + NoWildcardImports + UnnecessaryGroovyImport + UnusedImport + + // rulesets/jdbc.xml + DirectConnectionManagement + JdbcConnectionReference + JdbcResultSetReference + JdbcStatementReference + + // rulesets/jenkins.xml + ClassNotSerializable + ClosureInGString + CpsCallFromNonCpsMethod + ExpressionInCpsMethodNotSerializable + ForbiddenCallInCpsMethod + ObjectOverrideOnlyNonCpsMethods + ParameterOrReturnTypeNotSerializable + + // rulesets/junit.xml + ChainedTest + CoupledTestCase + JUnitAssertAlwaysFails + JUnitAssertAlwaysSucceeds + JUnitFailWithoutMessage + JUnitLostTest + JUnitPublicField + JUnitPublicNonTestMethod + JUnitPublicProperty + JUnitSetUpCallsSuper + JUnitStyleAssertions + JUnitTearDownCallsSuper + JUnitTestMethodWithoutAssert + JUnitUnnecessarySetUp + JUnitUnnecessaryTearDown + JUnitUnnecessaryThrowsException + SpockIgnoreRestUsed + SpockMissingAssert + UnnecessaryFail + UseAssertEqualsInsteadOfAssertTrue + UseAssertFalseInsteadOfNegation + UseAssertNullInsteadOfAssertEquals + UseAssertSameInsteadOfAssertTrue + UseAssertTrueInsteadOfAssertEquals + UseAssertTrueInsteadOfNegation + + // rulesets/logging.xml + LoggerForDifferentClass + LoggerWithWrongModifiers + LoggingSwallowsStacktrace + MultipleLoggers + PrintStackTrace + Println + SystemErrPrint + SystemOutPrint + + // rulesets/naming.xml + AbstractClassName + ClassName + ClassNameSameAsFilename + ClassNameSameAsSuperclass + ConfusingMethodName + FactoryMethodName + FieldName + InterfaceName + InterfaceNameSameAsSuperInterface + MethodName + ObjectOverrideMisspelledMethodName + PackageName + PackageNameMatchesFilePath + ParameterName + PropertyName + VariableName + + // rulesets/security.xml + FileCreateTempFile + InsecureRandom + JavaIoPackageAccess + NonFinalPublicField + NonFinalSubclassOfSensitiveInterface + ObjectFinalize + PublicFinalizeMethod + SystemExit + UnsafeArrayDeclaration + + // rulesets/serialization.xml + EnumCustomSerializationIgnored + NonSerializableFieldInSerializableClass + SerialPersistentFields + SerialVersionUID + SerializableClassMustDefineSerialVersionUID + + // rulesets/size.xml + AbcMetric // Requires the GMetrics jar + ClassSize + CrapMetric // Requires the GMetrics jar and a Cobertura coverage file + CyclomaticComplexity // Requires the GMetrics jar + MethodCount + MethodSize + NestedBlockDepth + ParameterCount + + // rulesets/unnecessary.xml + AddEmptyString + ConsecutiveLiteralAppends + ConsecutiveStringConcatenation + UnnecessaryBigDecimalInstantiation + UnnecessaryBigIntegerInstantiation + UnnecessaryBooleanExpression + UnnecessaryBooleanInstantiation + UnnecessaryCallForLastElement + UnnecessaryCallToSubstring + UnnecessaryCast + UnnecessaryCatchBlock + UnnecessaryCollectCall + UnnecessaryCollectionCall + UnnecessaryConstructor + UnnecessaryDefInFieldDeclaration + UnnecessaryDefInMethodDeclaration + UnnecessaryDefInVariableDeclaration + UnnecessaryDotClass + UnnecessaryDoubleInstantiation + UnnecessaryElseStatement + UnnecessaryFinalOnPrivateMethod + UnnecessaryFloatInstantiation + UnnecessaryGString + UnnecessaryGetter + UnnecessaryIfStatement + UnnecessaryInstanceOfCheck + UnnecessaryInstantiationToGetClass + UnnecessaryIntegerInstantiation + UnnecessaryLongInstantiation + UnnecessaryModOne + UnnecessaryNullCheck + UnnecessaryNullCheckBeforeInstanceOf + UnnecessaryObjectReferences + UnnecessaryOverridingMethod + UnnecessaryPackageReference + UnnecessaryParenthesesForMethodCallWithClosure + UnnecessaryPublicModifier + UnnecessaryReturnKeyword + UnnecessarySafeNavigationOperator + UnnecessarySelfAssignment + UnnecessarySemicolon + UnnecessarySetter + UnnecessaryStringInstantiation + UnnecessaryTernaryExpression + UnnecessaryToString + UnnecessaryTransientModifier + + // rulesets/unused.xml + UnusedArray + UnusedMethodParameter + UnusedObject + UnusedPrivateField + UnusedPrivateMethod + UnusedPrivateMethodParameter + UnusedVariable + +} diff --git a/.github/workflows/codenarc.yml b/.github/workflows/codenarc.yml index 1b436eeaf1..0401b96d32 100644 --- a/.github/workflows/codenarc.yml +++ b/.github/workflows/codenarc.yml @@ -47,4 +47,4 @@ jobs: -maxPriority2Violations=50 \ -maxPriority3Violations=200 \ -failOnError=true \ - -rulesetfiles=rulesets/basic.xml,rulesets/braces.xml,rulesets/comments.xml,rulesets/concurrency.xml,rulesets/convention.xml,rulesets/design.xml,rulesets/dry.xml,rulesets/enhanced.xml,rulesets/exceptions.xml,rulesets/formatting.xml,rulesets/generic.xml,rulesets/groovyism.xml,rulesets/imports.xml,rulesets/logging.xml,rulesets/naming.xml,rulesets/size.xml,rulesets/unnecessary.xml,rulesets/unused.xml + -rulesetfiles=.codenarc From e97339aa7ab8ad4362cc61c81d4c0e21ced795e2 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 12 Dec 2024 02:41:23 +0300 Subject: [PATCH 04/16] #3644: path --- .github/workflows/codenarc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codenarc.yml b/.github/workflows/codenarc.yml index 0401b96d32..60e9626e7b 100644 --- a/.github/workflows/codenarc.yml +++ b/.github/workflows/codenarc.yml @@ -47,4 +47,4 @@ jobs: -maxPriority2Violations=50 \ -maxPriority3Violations=200 \ -failOnError=true \ - -rulesetfiles=.codenarc + -rulesetfiles=file:.codenarc From 89f953ffb3e8d3706fb5670e8b8da1087ac9fb01 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 12 Dec 2024 02:42:22 +0300 Subject: [PATCH 05/16] #3644: CompileStatic removed --- .codenarc | 1 - 1 file changed, 1 deletion(-) diff --git a/.codenarc b/.codenarc index 61b97d3b9b..5d2e7119db 100644 --- a/.codenarc +++ b/.codenarc @@ -100,7 +100,6 @@ ruleset { WaitOutsideOfWhileLoop // rulesets/convention.xml - CompileStatic ConfusingTernary CouldBeElvis CouldBeSwitchStatement From fa34f7e4848afa46dd9e2e9378fc686cb09f985d Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 12 Dec 2024 02:43:52 +0300 Subject: [PATCH 06/16] #3644: JavaIo is OK --- .codenarc | 1 - 1 file changed, 1 deletion(-) diff --git a/.codenarc b/.codenarc index 5d2e7119db..c7982e020f 100644 --- a/.codenarc +++ b/.codenarc @@ -369,7 +369,6 @@ ruleset { // rulesets/security.xml FileCreateTempFile InsecureRandom - JavaIoPackageAccess NonFinalPublicField NonFinalSubclassOfSensitiveInterface ObjectFinalize From 4c6eb7a1bfc4f8f89ee7c285633ef22d6e75260f Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 12 Dec 2024 02:44:08 +0300 Subject: [PATCH 07/16] #3644: Println is OK --- .codenarc | 1 - 1 file changed, 1 deletion(-) diff --git a/.codenarc b/.codenarc index c7982e020f..8045a011be 100644 --- a/.codenarc +++ b/.codenarc @@ -344,7 +344,6 @@ ruleset { LoggingSwallowsStacktrace MultipleLoggers PrintStackTrace - Println SystemErrPrint SystemOutPrint From 5b3635ef12f5fa5e8b45ed5e75c6eac4d9482c2e Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 12 Dec 2024 03:01:41 +0300 Subject: [PATCH 08/16] #3644: polished --- .../check-all-java-classes-compiled.groovy | 56 ++++++++----------- .../groovy/check-folders-numbering.groovy | 40 ++++++------- .../src/test/groovy/check-runtime-deps.groovy | 16 ++---- .../src/test/groovy/check-target-files.groovy | 37 +++++++----- eo-runtime/src/test/groovy/verify.groovy | 15 +++-- 5 files changed, 77 insertions(+), 87 deletions(-) diff --git a/eo-runtime/src/test/groovy/check-all-java-classes-compiled.groovy b/eo-runtime/src/test/groovy/check-all-java-classes-compiled.groovy index f8661aa232..ce31836349 100644 --- a/eo-runtime/src/test/groovy/check-all-java-classes-compiled.groovy +++ b/eo-runtime/src/test/groovy/check-all-java-classes-compiled.groovy @@ -26,41 +26,33 @@ import java.nio.file.Files import java.nio.file.Path import java.util.stream.Collectors -println 'Verify that all java classes were compiled successfully' - Path binaries = basedir.toPath() - .resolve("target") - .resolve("classes") - .resolve("org") - .resolve("eolang"); + .resolve("target") + .resolve("classes") + .resolve("org") + .resolve("eolang"); Path classes = basedir.toPath() - .resolve("src") - .resolve("main") - .resolve("java") - .resolve("org") - .resolve("eolang") + .resolve("src") + .resolve("main") + .resolve("java") + .resolve("org") + .resolve("eolang") Set expected = Files.walk(classes) - .filter(it -> { - it.toString().endsWith(".java") - }) - .map(Path::getFileName) - .map(Path::toString) - .map(it -> { - return it.replace(".java", ".class") - }).collect(Collectors.toSet()) + .filter(it -> { + it.toString().endsWith(".java") + }) + .map(Path::getFileName) + .map(Path::toString) + .map(it -> { + return it.replace(".java", ".class") + }).collect(Collectors.toSet()) Set actual = Files.walk(binaries) - .filter(it -> { - it.toString().endsWith(".class") - }) - .map(Path::getFileName) - .map(Path::toString) - .collect(Collectors.toSet()) + .filter(it -> { + it.toString().endsWith(".class") + }) + .map(Path::getFileName) + .map(Path::toString) + .collect(Collectors.toSet()) if (!actual.containsAll(expected)) { - throw new IllegalStateException( - String.format( - "Not all classes are compiled\nExpected %s\nActual %s", - expected, - actual - ) - ) + fail("Not all classes are compiled\nExpected ${expected}\nActual ${actual}") } diff --git a/eo-runtime/src/test/groovy/check-folders-numbering.groovy b/eo-runtime/src/test/groovy/check-folders-numbering.groovy index 8adaa73d50..21b3a07a85 100644 --- a/eo-runtime/src/test/groovy/check-folders-numbering.groovy +++ b/eo-runtime/src/test/groovy/check-folders-numbering.groovy @@ -26,28 +26,28 @@ import java.util.stream.Collectors target = basedir.toPath().resolve("target").resolve("eo") List directories = target.toFile().listFiles(new FileFilter() { - @Override - boolean accept(final File pathname) { - return pathname.isDirectory() - } + @Override + boolean accept(final File pathname) { + return pathname.isDirectory() + } }) -List allowed = [ - '1-parse', - '2-optimize', - '3-shake', - '4-pull', - '5-resolve', - '6-lint', - '7-pre', - '8-transpile', - 'phi' +var allowed = [ + '1-parse', + '2-optimize', + '3-shake', + '4-pull', + '5-resolve', + '6-lint', + '7-pre', + '8-transpile', + 'phi' ] List allowedDirs = allowed.stream() - .map { target.resolve(it).toFile() } - .collect(Collectors.toList()) + .map { target.resolve(it).toFile() } + .collect(Collectors.toList()) + for (dir in directories) { - if (!allowedDirs.contains(dir)) { - fail(String.format("The directory '%s' is not expected to be here. Allowed directories %s", dir.name, allowed)); - } + if (!allowedDirs.contains(dir)) { + fail("The directory '${dir.name}' is not expected to be here"); + } } -true diff --git a/eo-runtime/src/test/groovy/check-runtime-deps.groovy b/eo-runtime/src/test/groovy/check-runtime-deps.groovy index 2a17891e7b..7582bea862 100644 --- a/eo-runtime/src/test/groovy/check-runtime-deps.groovy +++ b/eo-runtime/src/test/groovy/check-runtime-deps.groovy @@ -29,19 +29,11 @@ */ import groovy.xml.XmlSlurper -def pom = new File("pom.xml").text +def pom = new File('pom.xml').text def project = new XmlSlurper().parseText(pom) -println 'Verify that there are no any dependencies in eo-runtime except those that are needed for tests' - project.dependencies.dependency.each { - if (it.scope.text() != 'test' && it.scope.text() != 'provided') - fail( - String.format( - 'Dependency %s.%s must be in "test" or "provided" scope', - it.groupId.text(), it.artifactId.text() - ) - ) + if (it.scope.text() != 'test' && it.scope.text() != 'provided') { + fail("Dependency ${it.groupId.text()}.${it.artifactId.text()} must be in either 'test' or 'provided' scope") + } } - -true diff --git a/eo-runtime/src/test/groovy/check-target-files.groovy b/eo-runtime/src/test/groovy/check-target-files.groovy index 76bcd9dbc2..854afb1038 100644 --- a/eo-runtime/src/test/groovy/check-target-files.groovy +++ b/eo-runtime/src/test/groovy/check-target-files.groovy @@ -1,3 +1,5 @@ +import java.nio.file.Paths + /** * The MIT License (MIT) * @@ -22,23 +24,28 @@ * SOFTWARE. */ -List expected = [ - 'eo/1-parse/bytes.xmir', - 'eo/1-parse/fs/dir.xmir', - 'eo/2-optimize/error.xmir', - 'eo/2-optimize/sys/os.xmir', - 'eo/6-lint/go.xmir', - 'eo/8-transpile/malloc.xmir', - 'eo/phi/number.phi', - 'eo-test/1-parse/bool-tests.xmir', - 'eo-test/2-optimize/go-tests.xmir', - 'eo-test/6-lint/dataized-tests.xmir', - 'eo-test/8-transpile/runtime-tests.xmir', - 'eo-test/phi/number-tests.phi', +var expected = [ + 'eo-foreign.csv', + 'eo/1-parse/org/eolang/bytes.xmir', + 'eo/1-parse/org/eolang/fs/dir.xmir', + 'eo/2-optimize/org/eolang/error.xmir', + 'eo/2-optimize/org/eolang/sys/os.xmir', + 'eo/6-lint/org/eolang/go.xmir', + 'eo/8-transpile/org/eolang/malloc.xmir', + 'eo/phi/org/eolang/number.phi', + 'eo-test/1-parse/org/eolang/bool-tests.xmir', + 'eo-test/2-optimize/org/eolang/go-tests.xmir', + 'eo-test/6-lint/org/eolang/dataized-tests.xmir', + 'eo-test/8-transpile/org/eolang/runtime-tests.xmir', + 'eo-test/phi/org/eolang/number-tests.phi', + 'generated-sources/EOorg/EOeolang/EOdataized.java', + 'generated-test-sources/EOorg/EOeolang/EOand_with_zeroTest.java', + 'classes/EO-SOURCES/org/eolang/false.eo', ] for (path in expected) { - if (new File(path).exists()) { - fail("The file '${path}' is not present") + var f = Paths.get('eo-runtime/target').resolve(path).toFile() + if (!f.exists()) { + fail("The file '${f}' is not present") } } diff --git a/eo-runtime/src/test/groovy/verify.groovy b/eo-runtime/src/test/groovy/verify.groovy index de9044a168..057510c3c3 100644 --- a/eo-runtime/src/test/groovy/verify.groovy +++ b/eo-runtime/src/test/groovy/verify.groovy @@ -29,14 +29,13 @@ import java.nio.file.Path * To add new validation create new script in this folder and add it * to the list below. */ -Path folder = basedir.toPath().resolve("src").resolve("test").resolve("groovy") -tests = [ - 'check-folders-numbering.groovy', - 'check-all-java-classes-compiled.groovy', - 'check-runtime-deps.groovy' +Path folder = basedir.toPath().resolve('src/test/groovy') +var tests = [ + 'check-folders-numbering.groovy', + 'check-all-java-classes-compiled.groovy', + 'check-runtime-deps.groovy', + 'check-target-files.groovy', ] for (it in tests) { - def res = evaluate folder.resolve(it).toFile() - println String.format('Verified with %s - OK. Result: %s', it, res) + evaluate folder.resolve(it).toFile() } -true \ No newline at end of file From 0b54bb49bb0cd06c8805022a20ddb37c1fa70aba Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 12 Dec 2024 03:13:27 +0300 Subject: [PATCH 09/16] #3644: xmir to and backward --- eo-runtime/pom.xml | 16 +++++++++------- .../src/test/groovy/check-target-files.groovy | 2 ++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/eo-runtime/pom.xml b/eo-runtime/pom.xml index 56a2406a6e..61770d3c41 100644 --- a/eo-runtime/pom.xml +++ b/eo-runtime/pom.xml @@ -205,10 +205,11 @@ SOFTWARE. eo-maven-plugin ${project.version} - ${project.basedir}/target/eo-foreign.csv + ${project.build.directory}/eo-foreign.csv csv false true + ${project.build.directory}/eo/unphi @@ -220,6 +221,7 @@ SOFTWARE. lint transpile xmir-to-phi + phi-to-xmir copy unplace unspile @@ -243,21 +245,21 @@ SOFTWARE. assemble lint xmir-to-phi + phi-to-xmir transpile binarize test ${project.basedir}/src/test/eo - ${project.basedir}/target/eo-test - ${project.basedir}/target/eo-test/2-optimize - ${project.basedir}/target/eo-test/phi + ${project.build.directory}/eo-test + ${project.build.directory}/eo-test/2-optimize + ${project.build.directory}/eo-test/phi + ${project.build.directory}/eo-test/unphi false true false - - ${project.basedir}/target/generated-test-sources - + ${project.build.directory}/generated-test-sources false true diff --git a/eo-runtime/src/test/groovy/check-target-files.groovy b/eo-runtime/src/test/groovy/check-target-files.groovy index 854afb1038..85c3574934 100644 --- a/eo-runtime/src/test/groovy/check-target-files.groovy +++ b/eo-runtime/src/test/groovy/check-target-files.groovy @@ -33,11 +33,13 @@ var expected = [ 'eo/6-lint/org/eolang/go.xmir', 'eo/8-transpile/org/eolang/malloc.xmir', 'eo/phi/org/eolang/number.phi', + 'eo/unphi/org/eolang/number.xmir', 'eo-test/1-parse/org/eolang/bool-tests.xmir', 'eo-test/2-optimize/org/eolang/go-tests.xmir', 'eo-test/6-lint/org/eolang/dataized-tests.xmir', 'eo-test/8-transpile/org/eolang/runtime-tests.xmir', 'eo-test/phi/org/eolang/number-tests.phi', + 'eo-test/unphi/org/eolang/number-tests.xmir', 'generated-sources/EOorg/EOeolang/EOdataized.java', 'generated-test-sources/EOorg/EOeolang/EOand_with_zeroTest.java', 'classes/EO-SOURCES/org/eolang/false.eo', From 09efc7c29b1d09bf35b71ef1b0cacc8df147d418 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 12 Dec 2024 03:14:28 +0300 Subject: [PATCH 10/16] #3644: extra --- eo-runtime/src/test/groovy/check-target-files.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/eo-runtime/src/test/groovy/check-target-files.groovy b/eo-runtime/src/test/groovy/check-target-files.groovy index 85c3574934..5bc1742a15 100644 --- a/eo-runtime/src/test/groovy/check-target-files.groovy +++ b/eo-runtime/src/test/groovy/check-target-files.groovy @@ -41,6 +41,7 @@ var expected = [ 'eo-test/phi/org/eolang/number-tests.phi', 'eo-test/unphi/org/eolang/number-tests.xmir', 'generated-sources/EOorg/EOeolang/EOdataized.java', + 'generated-sources/EOorg/EOeolang/EOnet/EOsocket.java', 'generated-test-sources/EOorg/EOeolang/EOand_with_zeroTest.java', 'classes/EO-SOURCES/org/eolang/false.eo', ] From 3cbe3ddc426223b97a932c862afe819656e9d99b Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 12 Dec 2024 03:14:54 +0300 Subject: [PATCH 11/16] #3644: fmt --- eo-runtime/src/test/groovy/check-target-files.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eo-runtime/src/test/groovy/check-target-files.groovy b/eo-runtime/src/test/groovy/check-target-files.groovy index 5bc1742a15..afc3d290d2 100644 --- a/eo-runtime/src/test/groovy/check-target-files.groovy +++ b/eo-runtime/src/test/groovy/check-target-files.groovy @@ -1,5 +1,3 @@ -import java.nio.file.Paths - /** * The MIT License (MIT) * @@ -24,6 +22,8 @@ import java.nio.file.Paths * SOFTWARE. */ +import java.nio.file.Paths + var expected = [ 'eo-foreign.csv', 'eo/1-parse/org/eolang/bytes.xmir', From 64b08d4ba7347c73c489c529cbe09bfb09ea7c66 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 12 Dec 2024 03:15:37 +0300 Subject: [PATCH 12/16] #3644: dir --- eo-runtime/src/test/groovy/check-folders-numbering.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eo-runtime/src/test/groovy/check-folders-numbering.groovy b/eo-runtime/src/test/groovy/check-folders-numbering.groovy index 21b3a07a85..e918d9da4d 100644 --- a/eo-runtime/src/test/groovy/check-folders-numbering.groovy +++ b/eo-runtime/src/test/groovy/check-folders-numbering.groovy @@ -40,7 +40,8 @@ var allowed = [ '6-lint', '7-pre', '8-transpile', - 'phi' + 'phi', + 'unphi', ] List allowedDirs = allowed.stream() .map { target.resolve(it).toFile() } From 16b3f1b18c0817c6d3a6db93aebf7bd3daddbca9 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 12 Dec 2024 03:16:13 +0300 Subject: [PATCH 13/16] #3644: dir --- eo-runtime/src/test/groovy/check-folders-numbering.groovy | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/eo-runtime/src/test/groovy/check-folders-numbering.groovy b/eo-runtime/src/test/groovy/check-folders-numbering.groovy index e918d9da4d..664940ac41 100644 --- a/eo-runtime/src/test/groovy/check-folders-numbering.groovy +++ b/eo-runtime/src/test/groovy/check-folders-numbering.groovy @@ -24,7 +24,7 @@ import java.util.stream.Collectors -target = basedir.toPath().resolve("target").resolve("eo") +target = basedir.toPath().resolve('target/eo') List directories = target.toFile().listFiles(new FileFilter() { @Override boolean accept(final File pathname) { @@ -40,8 +40,7 @@ var allowed = [ '6-lint', '7-pre', '8-transpile', - 'phi', - 'unphi', + 'phi' ] List allowedDirs = allowed.stream() .map { target.resolve(it).toFile() } From e10f0694378f2e4514dddc1996f56ec1b06f3111 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 12 Dec 2024 21:03:37 +0300 Subject: [PATCH 14/16] #3644: master --- eo-parser/src/main/antlr4/org/eolang/parser/Phi.g4 | 2 +- .../resources/org/eolang/parser/phi-syntax/all-the-basics.phi | 2 +- .../resources/org/eolang/parser/phi-typos/alpha-with-tail.phi | 1 + eo-runtime/pom.xml | 1 + eo-runtime/src/test/groovy/check-folders-numbering.groovy | 3 ++- 5 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 eo-parser/src/test/resources/org/eolang/parser/phi-typos/alpha-with-tail.phi diff --git a/eo-parser/src/main/antlr4/org/eolang/parser/Phi.g4 b/eo-parser/src/main/antlr4/org/eolang/parser/Phi.g4 index e44380e457..89fb0692f6 100644 --- a/eo-parser/src/main/antlr4/org/eolang/parser/Phi.g4 +++ b/eo-parser/src/main/antlr4/org/eolang/parser/Phi.g4 @@ -83,7 +83,7 @@ lambdaBinding ; FUNCTION - : [A-Z][A-Za-z_φ]* + : [A-Z][A-Z0-9a-z_φ]* ; application diff --git a/eo-parser/src/test/resources/org/eolang/parser/phi-syntax/all-the-basics.phi b/eo-parser/src/test/resources/org/eolang/parser/phi-syntax/all-the-basics.phi index 6afdaad4e1..e185692adb 100644 --- a/eo-parser/src/test/resources/org/eolang/parser/phi-syntax/all-the-basics.phi +++ b/eo-parser/src/test/resources/org/eolang/parser/phi-syntax/all-the-basics.phi @@ -12,7 +12,7 @@ hi-大家 ↦ ⟦ ⟧, α0 ↦ Φ () () (), α65536 ↦ Φ.r, - k ↦ ⟦ λ ⤍ FunctionName, α0 ↦ ⟦ λ ⤍ FunctionName, Δ ⤍ 42- ⟧ ⟧, + k ↦ ⟦ λ ⤍ Function_Name_i64, α0 ↦ ⟦ λ ⤍ FunctionName, Δ ⤍ 42- ⟧ ⟧, terminator-application ↦ ⊥ (t ↦ ξ.t), terminator-dispatch ↦ ⊥.t, string ↦ "Hello", diff --git a/eo-parser/src/test/resources/org/eolang/parser/phi-typos/alpha-with-tail.phi b/eo-parser/src/test/resources/org/eolang/parser/phi-typos/alpha-with-tail.phi new file mode 100644 index 0000000000..dd880665ad --- /dev/null +++ b/eo-parser/src/test/resources/org/eolang/parser/phi-typos/alpha-with-tail.phi @@ -0,0 +1 @@ +{⟦ k ↦ ξ.αx.t ⟧} diff --git a/eo-runtime/pom.xml b/eo-runtime/pom.xml index 61770d3c41..e9099fe5c6 100644 --- a/eo-runtime/pom.xml +++ b/eo-runtime/pom.xml @@ -255,6 +255,7 @@ SOFTWARE. ${project.build.directory}/eo-test ${project.build.directory}/eo-test/2-optimize ${project.build.directory}/eo-test/phi + ${project.build.directory}/eo-test/phi ${project.build.directory}/eo-test/unphi false true diff --git a/eo-runtime/src/test/groovy/check-folders-numbering.groovy b/eo-runtime/src/test/groovy/check-folders-numbering.groovy index 664940ac41..d6b94d5dd2 100644 --- a/eo-runtime/src/test/groovy/check-folders-numbering.groovy +++ b/eo-runtime/src/test/groovy/check-folders-numbering.groovy @@ -40,7 +40,8 @@ var allowed = [ '6-lint', '7-pre', '8-transpile', - 'phi' + 'phi', + 'unphi' ] List allowedDirs = allowed.stream() .map { target.resolve(it).toFile() } From 3dc317dece15e17593a15cca52548a4ef4c63220 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Thu, 12 Dec 2024 21:05:12 +0300 Subject: [PATCH 15/16] #3644: rm --- .../resources/org/eolang/parser/phi-typos/alpha-with-tail.phi | 1 - 1 file changed, 1 deletion(-) delete mode 100644 eo-parser/src/test/resources/org/eolang/parser/phi-typos/alpha-with-tail.phi diff --git a/eo-parser/src/test/resources/org/eolang/parser/phi-typos/alpha-with-tail.phi b/eo-parser/src/test/resources/org/eolang/parser/phi-typos/alpha-with-tail.phi deleted file mode 100644 index dd880665ad..0000000000 --- a/eo-parser/src/test/resources/org/eolang/parser/phi-typos/alpha-with-tail.phi +++ /dev/null @@ -1 +0,0 @@ -{⟦ k ↦ ξ.αx.t ⟧} From dcbf5c88dd16336f13cbfdfc38c6858a08fd0f6e Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Fri, 13 Dec 2024 07:36:23 +0300 Subject: [PATCH 16/16] #3644: master