mirror of
https://github.com/cincheo/jsweet.git
synced 2025-12-15 15:29:22 +00:00
#14: Fixed issue with cast methods when being invocation targets
This commit is contained in:
parent
ed9b8c5cdc
commit
238e60bc3e
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,7 @@ import org.junit.Test;
|
||||
import source.syntax.AnnotationQualifiedNames;
|
||||
import source.syntax.FinalVariables;
|
||||
import source.syntax.FinalVariablesRuntime;
|
||||
import source.syntax.GlobalsCastMethod;
|
||||
import source.syntax.GlobalsInvocation;
|
||||
import source.syntax.IndexedAccessInStaticScope;
|
||||
import source.syntax.Keywords;
|
||||
@ -143,5 +144,13 @@ public class SyntaxTests extends AbstractTest {
|
||||
assertEquals("value4", r.get("field4"));
|
||||
} , getSourceFile(ValidIndexedAccesses.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGlobalCastMethod() {
|
||||
transpile((logHandler) -> {
|
||||
logHandler.assertReportedProblems();
|
||||
} , getSourceFile(GlobalsCastMethod.class));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
35
src/test/java/source/syntax/GlobalsCastMethod.java
Normal file
35
src/test/java/source/syntax/GlobalsCastMethod.java
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* JSweet - http://www.jsweet.org
|
||||
* Copyright (C) 2015 CINCHEO SAS <renaud.pawlak@cincheo.fr>
|
||||
*
|
||||
* 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 source.syntax;
|
||||
|
||||
import static jsweet.util.Globals.number;
|
||||
|
||||
public class GlobalsCastMethod {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
double n = 5;
|
||||
|
||||
// this invocation must preserve parentheses on target
|
||||
number(n / 2).toFixed(0);
|
||||
|
||||
// this invocation does not
|
||||
number(n / 2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user