-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f81597
commit 0d47108
Showing
10 changed files
with
380 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!-- markdownlint-disable-next-line line-length --> | ||
<img alt="logo" src="https://www.yegor256.com/images/books/elegant-objects/cactus.svg" height="100px" /> | ||
|
||
[![Maven Central](https://img.shields.io/maven-central/v/org.eolang/eo-maven-plugin.svg)](https://maven-badges.herokuapp.com/maven-central/org.eolang/eo-maven-plugin) | ||
|
||
This directory contains integration tests for eolang-maven-plugin, | ||
but you can use them as examples of EO-to-Java transformations. |
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,18 @@ | ||
<img alt="logo" src="https://www.objectionary.com/cactus.svg" height="100px" /> | ||
|
||
This is a simple example a program written entirely in EO. | ||
You can use the files from this directory as a template. | ||
The only change you will have to do is setting | ||
the right versions the `pom.xml`. Use the latest version | ||
visible in this badge: | ||
|
||
[![Maven Central](https://img.shields.io/maven-central/v/org.eolang/eo-maven-plugin.svg)](https://maven-badges.herokuapp.com/maven-central/org.eolang/eo-maven-plugin) | ||
|
||
Just copy these files to your local directory, change the | ||
version in `pom.xml` and run `mvn test` (it is assumed that | ||
you have [Maven 3.3+](https://maven.apache.org/) installed). | ||
|
||
If everything works fine, you will see the `SUCCESS` message | ||
in the console. The files generated during parsing, optimization, | ||
and compilation are available in `target/eo` directory. This directory | ||
will be created by Maven automatically. |
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,24 @@ | ||
# 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. | ||
|
||
invoker.mavenOpts = -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn | ||
invoker.goals = clean test |
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,103 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.jcabi</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>0.68.0</version> | ||
</parent> | ||
<groupId>org.eolang</groupId> | ||
<artifactId>examples</artifactId> | ||
<version>@project.version@</version> | ||
<packaging>jar</packaging> | ||
<name>Fibonacci Numbers Calculator</name> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<configuration combine.self="override"/> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<failIfNoTests>false</failIfNoTests> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.eolang</groupId> | ||
<artifactId>eo-maven-plugin</artifactId> | ||
<version>@project.version@</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>register</goal> | ||
<goal>assemble</goal> | ||
<goal>transpile</goal> | ||
<goal>sodg</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<unrollExitError>true</unrollExitError> | ||
<sodgIncludes> | ||
<o>org.eolang.error</o> | ||
</sodgIncludes> | ||
<foreign>${project.build.directory}/eo/foreign.csv</foreign> | ||
<foreignFormat>csv</foreignFormat> | ||
<placed>${project.build.directory}/eo/placed.json</placed> | ||
<placedFormat>json</placedFormat> | ||
<trackOptimizationSteps>true</trackOptimizationSteps> | ||
<generateSodgXmlFiles>true</generateSodgXmlFiles> | ||
<generateGraphFiles>true</generateGraphFiles> | ||
<generateXemblyFiles>true</generateXemblyFiles> | ||
<generateDotFiles>true</generateDotFiles> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>3.5.0</version> | ||
<executions> | ||
<execution> | ||
<phase>test</phase> | ||
<goals> | ||
<goal>java</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<mainClass>org.eolang.Main</mainClass> | ||
<arguments> | ||
<argument>org.eolang.examples.app</argument> | ||
<argument>6</argument> | ||
<argument>8</argument> | ||
</arguments> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
50 changes: 50 additions & 0 deletions
50
eo-maven-plugin/src/it/fibonacci/src/main/eo/org/eolang/examples/app.eo
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,50 @@ | ||
# 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. | ||
|
||
+package org.eolang.examples | ||
+alias org.eolang.examples.fibonacci | ||
+alias org.eolang.io.stdout | ||
+alias org.eolang.txt.sprintf | ||
+alias org.eolang.txt.sscanf | ||
+architect yegor256@gmail.com | ||
|
||
# Application. | ||
[args] > app | ||
number > n | ||
at. > nn! | ||
QQ.txt.sscanf | ||
"%d" | ||
args.at 0 | ||
0 | ||
at. > e! | ||
QQ.txt.sscanf | ||
"%d" | ||
args.at 1 | ||
0 | ||
fibonacci n > f! | ||
and. > @ | ||
stdout | ||
sprintf | ||
"%dth Fibonacci number is %d\n" | ||
* n f | ||
e.eq f | ||
|
38 changes: 38 additions & 0 deletions
38
eo-maven-plugin/src/it/fibonacci/src/main/eo/org/eolang/examples/fibonacci.eo
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,38 @@ | ||
# 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. | ||
|
||
+architect yegor256@gmail.com | ||
+package org.eolang.examples | ||
|
||
# This is the main abstract object that | ||
# represents n-th Fibonacci number | ||
[n] > fibonacci | ||
if. > @ | ||
lt. | ||
n | ||
2 | ||
n | ||
plus. | ||
^.fibonacci | ||
n.minus 1 | ||
^.fibonacci | ||
n.minus 2 |
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,72 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* Check the internet connection. | ||
* | ||
* @return Is the internet connection available | ||
*/ | ||
private static boolean online() { | ||
boolean online = true | ||
try { | ||
final URL url = new URL('http://www.google.com') | ||
final URLConnection conn = url.openConnection() | ||
conn.connect() | ||
conn.inputStream.close() | ||
} catch (final IOException ignored) { | ||
online = false | ||
} | ||
return online | ||
} | ||
|
||
[ | ||
'target/eo/foreign.csv', | ||
'target/generated-sources/EOorg/EOeolang/EOexamples/EOapp.java', | ||
'target/eo/1-parse/org/eolang/examples/app.xmir', | ||
'target/eo/2-optimization-steps/org/eolang/examples/app/00-not-empty-atoms.xml', | ||
'target/eo/2-optimize/org/eolang/examples/app.xmir', | ||
'target/eo/6-pre/org/eolang/examples/app/01-classes.xml', | ||
'target/eo/7-transpile/org/eolang/examples/app.xmir', | ||
'target/eo/sodg/org/eolang/error.sodg', | ||
'target/eo/sodg/org/eolang/error.sodg.xe', | ||
'target/eo/sodg/org/eolang/error.sodg.graph.xml', | ||
'target/eo/sodg/org/eolang/error.sodg.dot', | ||
].each { path -> assert new File(basedir, path).exists() } | ||
|
||
[ | ||
'target/classes/EOorg/EOeolang/EOexamples/EOapp.class', | ||
'target/eo/placed.json', | ||
'target/eo/4-pull/org/eolang/tuple.eo', | ||
].each { path -> assert new File(basedir, path).exists() || !online() } | ||
|
||
String log = new File(basedir, 'build.log').text | ||
|
||
[ | ||
'org.eolang:eo-runtime:', | ||
' unpacked to ', | ||
'6th Fibonacci number is 8', | ||
'BUILD SUCCESS', | ||
].each { expectedLog -> assert log.contains(expectedLog) || !online() } | ||
|
||
true |
Oops, something went wrong.