#14: Fixed issue with cast methods when being invocation targets

This commit is contained in:
Renaud Pawlak 2015-12-17 17:20:35 +01:00
parent ed9b8c5cdc
commit 238e60bc3e
3 changed files with 685 additions and 630 deletions

View File

@ -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));
}
}

View 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);
}
}