jdk/test/jdk/lambda/MethodReferenceTestSuper.java
changeset 29748 9ad0fcf27b36
parent 29659 f40752db7773
parent 29747 0ab8f74c7f13
child 29749 68def6418e33
child 29815 a50c9d80a80f
child 29899 a660cade22ce
equal deleted inserted replaced
29659:f40752db7773 29748:9ad0fcf27b36
     1 /*
       
     2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 import org.testng.annotations.Test;
       
    25 
       
    26 import static org.testng.Assert.assertEquals;
       
    27 
       
    28 
       
    29 
       
    30 /**
       
    31  * @author Robert Field
       
    32  */
       
    33 
       
    34 interface SPRI { String m(String a); }
       
    35 
       
    36 class SPRA {
       
    37     String xsA__(String s) {
       
    38         return "A__xsA:" + s;
       
    39     }
       
    40 
       
    41     String xsA_M(String s) {
       
    42         return "A_MxsA:" + s;
       
    43     }
       
    44 
       
    45     String xsAB_(String s) {
       
    46         return "AB_xsA:" + s;
       
    47     }
       
    48 
       
    49     String xsABM(String s) {
       
    50         return "ABMxsA:" + s;
       
    51     }
       
    52 
       
    53 }
       
    54 
       
    55 class SPRB extends SPRA {
       
    56 
       
    57     String xsAB_(String s) {
       
    58         return "AB_xsB:" + s;
       
    59     }
       
    60 
       
    61     String xsABM(String s) {
       
    62         return "ABMxsB:" + s;
       
    63     }
       
    64 
       
    65     String xs_B_(String s) {
       
    66         return "_B_xsB:" + s;
       
    67     }
       
    68 
       
    69     String xs_BM(String s) {
       
    70         return "_BMxsB:" + s;
       
    71     }
       
    72 
       
    73 }
       
    74 
       
    75 @Test
       
    76 public class MethodReferenceTestSuper extends SPRB {
       
    77 
       
    78     String xsA_M(String s) {
       
    79         return "A_MxsM:" + s;
       
    80     }
       
    81 
       
    82 
       
    83     String xsABM(String s) {
       
    84         return "ABMxsM:" + s;
       
    85     }
       
    86 
       
    87     String xs_BM(String s) {
       
    88         return "_BMxsM:" + s;
       
    89     }
       
    90 
       
    91     public void testMethodReferenceSuper() {
       
    92         SPRI q;
       
    93 
       
    94         q = super::xsA__;
       
    95         assertEquals(q.m("*"), "A__xsA:*");
       
    96 
       
    97         q = super::xsA_M;
       
    98         assertEquals(q.m("*"), "A_MxsA:*");
       
    99 
       
   100         q = super::xsAB_;
       
   101         assertEquals(q.m("*"), "AB_xsB:*");
       
   102 
       
   103         q = super::xsABM;
       
   104         assertEquals(q.m("*"), "ABMxsB:*");
       
   105 
       
   106         q = super::xs_B_;
       
   107         assertEquals(q.m("*"), "_B_xsB:*");
       
   108 
       
   109         q = super::xs_BM;
       
   110         assertEquals(q.m("*"), "_BMxsB:*");
       
   111     }
       
   112 
       
   113 }