Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lang] Generate inline constant expressions with Java format.
close #631 Signed-off-by: Stéphane Galland <galland@arakhne.org>
- Loading branch information
1 parent
7ee7c79
commit 0ecafba
Showing
4 changed files
with
111 additions
and
8 deletions.
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
91 changes: 91 additions & 0 deletions
91
tests/io.sarl.lang.tests/src/io/sarl/lang/tests/bugs/Bug631.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,91 @@ | ||
/* | ||
* Copyright (C) 2014-2017 the original authors or authors. | ||
* | ||
* 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 io.sarl.lang.tests.bugs; | ||
|
||
import com.google.inject.Inject; | ||
import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
import org.eclipse.xtext.xbase.testing.CompilationTestHelper; | ||
import org.junit.Test; | ||
|
||
import io.sarl.lang.SARLVersion; | ||
import io.sarl.lang.sarl.SarlScript; | ||
import io.sarl.tests.api.AbstractSarlTest; | ||
|
||
/** Testing class for issue: Invalid floating point value in inline expression. | ||
* | ||
* <p>https://github.com/sarl/sarl/issues/631 | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $Name$ $Revision$ $Date$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
*/ | ||
@SuppressWarnings("all") | ||
public class Bug631 extends AbstractSarlTest { | ||
|
||
private static final String SNIPSET1 = multilineString( | ||
"package io.sarl.lang.tests.bug631", | ||
"class XXX {", | ||
" def fct : float {", | ||
" 0f", | ||
" }", | ||
" def fct2 : float[] {", | ||
" #[ 0f, fct ]", | ||
" }", | ||
"}"); | ||
|
||
@Inject | ||
private CompilationTestHelper compiler; | ||
|
||
@Test | ||
public void parsing_01() throws Exception { | ||
SarlScript mas = file(SNIPSET1); | ||
final Validator validator = validate(mas); | ||
validator.assertNoErrors(); | ||
} | ||
|
||
@Test | ||
public void compiling_01() throws Exception { | ||
this.compiler.assertCompilesTo(SNIPSET1, multilineString( | ||
"package io.sarl.lang.tests.bug631;", | ||
"", | ||
"import io.sarl.lang.annotation.SarlSpecification;", | ||
"import io.sarl.lang.annotation.SyntheticMember;", | ||
"import org.eclipse.xtext.xbase.lib.Inline;", | ||
"", | ||
"@SarlSpecification(\"" + SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING + "\")", | ||
"@SuppressWarnings(\"all\")", | ||
"public class XXX {", | ||
" @Inline(value = \"0.0f\", constantExpression = true)", | ||
" public float fct() {", | ||
" return 0f;", | ||
" }", | ||
" ", | ||
" public float[] fct2() {", | ||
" float _fct = 0.0f;", | ||
" return new float[] { 0f, _fct };", | ||
" }", | ||
" ", | ||
" @SyntheticMember", | ||
" public XXX() {", | ||
" super();", | ||
" }", | ||
"}", | ||
"")); | ||
} | ||
|
||
} |
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