test/langtools/jdk/jshell/MethodsTest.java
changeset 49416 f14852315495
parent 47499 b3ea71b70f7b
child 55142 e2dbcc6ed36d
equal deleted inserted replaced
49415:56a5f899e882 49416:f14852315495
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug 8080357 8167643 8187359
    26  * @bug 8080357 8167643 8187359 8199762
    27  * @summary Tests for EvaluationState.methods
    27  * @summary Tests for EvaluationState.methods
    28  * @build KullaTesting TestingInputStream ExpectedDiagnostic
    28  * @build KullaTesting TestingInputStream ExpectedDiagnostic
    29  * @run testng MethodsTest
    29  * @run testng MethodsTest
    30  */
    30  */
    31 
    31 
   197                 ste(MAIN_SNIPPET, VALID, VALID, false, null),
   197                 ste(MAIN_SNIPPET, VALID, VALID, false, null),
   198                 ste(a, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
   198                 ste(a, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
   199         assertActiveKeys();
   199         assertActiveKeys();
   200     }
   200     }
   201 
   201 
       
   202     // 8199762
       
   203     public void methodsRedeclaration5() {
       
   204         Snippet m1 = methodKey(assertEval("int m(Object o) { return 10; }"));
       
   205         assertMethods(method("(Object)int", "m"));
       
   206 
       
   207         Snippet m2 = methodKey(assertEval("int m(Object o) { return 30; }",
       
   208                 ste(MAIN_SNIPPET, VALID, VALID, false, null),
       
   209                 ste(m1, VALID, OVERWRITTEN, false, MAIN_SNIPPET)));
       
   210 
       
   211         assertEval("<T> int m(T o) { return 30; }",
       
   212                 ste(MAIN_SNIPPET, VALID, VALID, true, null),
       
   213                 ste(m2, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
       
   214         assertMethods(method("(T)int", "m"));
       
   215         assertEval("m(null)", "30");
       
   216         assertActiveKeys();
       
   217     }
       
   218 
   202     public void methodsErrors() {
   219     public void methodsErrors() {
   203         assertDeclareFail("String f();",
   220         assertDeclareFail("String f();",
   204                 new ExpectedDiagnostic("compiler.err.missing.meth.body.or.decl.abstract", 0, 11, 7, -1, -1, Diagnostic.Kind.ERROR));
   221                 new ExpectedDiagnostic("compiler.err.missing.meth.body.or.decl.abstract", 0, 11, 7, -1, -1, Diagnostic.Kind.ERROR));
   205         assertNumberOfActiveMethods(0);
   222         assertNumberOfActiveMethods(0);
   206         assertActiveKeys();
   223         assertActiveKeys();