test/tools/javac/lambda/typeInference/InferenceTest5.java

changeset 2029
252f872b8a2f
parent 1991
1b7f5a27c4ba
parent 2028
4ce8148ffc4f
child 2030
8ecfe6a3ba4c
     1.1 --- a/test/tools/javac/lambda/typeInference/InferenceTest5.java	Thu Sep 12 11:09:20 2013 -0700
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,122 +0,0 @@
     1.4 -/*
     1.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 - *
     1.8 - * This code is free software; you can redistribute it and/or modify it
     1.9 - * under the terms of the GNU General Public License version 2 only, as
    1.10 - * published by the Free Software Foundation.
    1.11 - *
    1.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 - * version 2 for more details (a copy is included in the LICENSE file that
    1.16 - * accompanied this code).
    1.17 - *
    1.18 - * You should have received a copy of the GNU General Public License version
    1.19 - * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 - *
    1.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 - * or visit www.oracle.com if you need additional information or have any
    1.24 - * questions.
    1.25 - */
    1.26 -
    1.27 -/**
    1.28 - * @test
    1.29 - * @bug 8003280
    1.30 - * @summary Add lambda tests
    1.31 - *  This test is for overloaded methods, verify that the specific method is
    1.32 -             selected when type inference occurs
    1.33 - * @compile InferenceTest5.java
    1.34 - * @run main InferenceTest5
    1.35 - */
    1.36 -
    1.37 -import java.util.List;
    1.38 -import java.io.File;
    1.39 -
    1.40 -public class InferenceTest5 {
    1.41 -
    1.42 -    private static void assertTrue(boolean b) {
    1.43 -        if(!b)
    1.44 -            throw new AssertionError();
    1.45 -    }
    1.46 -
    1.47 -    public static void main(String[] args) {
    1.48 -        InferenceTest5 test = new InferenceTest5();
    1.49 -        int n = test.method1((a, b) -> {} );
    1.50 -        assertTrue(n == 1);
    1.51 -
    1.52 -        n = test.method1(() -> null);
    1.53 -        assertTrue(n == 2);
    1.54 -
    1.55 -        n = test.method1(a -> null);
    1.56 -        assertTrue(n == 3);
    1.57 -
    1.58 -        n = test.method1(a -> {});
    1.59 -        assertTrue(n == 4);
    1.60 -
    1.61 -        n = test.method1(() -> {});
    1.62 -        assertTrue(n == 5);
    1.63 -
    1.64 -        n = test.method1((a, b) -> 0);
    1.65 -        assertTrue(n == 6);
    1.66 -
    1.67 -        n = test.method1((a, b) -> null);
    1.68 -        assertTrue(n == 6);
    1.69 -
    1.70 -        n = test.method1((a, b) -> null, (a, b) -> null);
    1.71 -        assertTrue(n == 7);
    1.72 -    }
    1.73 -
    1.74 -    int method1(SAM1<String> s) {
    1.75 -        return 1;
    1.76 -    }
    1.77 -
    1.78 -    int method1(SAM2 s) {
    1.79 -        return 2;
    1.80 -    }
    1.81 -
    1.82 -    int method1(SAM3 s) {
    1.83 -        return 3;
    1.84 -    }
    1.85 -
    1.86 -    int method1(SAM4 s) {
    1.87 -        return 4;
    1.88 -    }
    1.89 -
    1.90 -    int method1(SAM5 s) {
    1.91 -        return 5;
    1.92 -    }
    1.93 -
    1.94 -    int method1(SAM6<?, ? super Integer> s) {
    1.95 -        return 6;
    1.96 -    }
    1.97 -
    1.98 -    int method1(SAM6<?, ?>... s) {
    1.99 -        return 7;
   1.100 -    }
   1.101 -
   1.102 -    static interface SAM1<T> {
   1.103 -        void foo(List<T> a, List<T> b);
   1.104 -    }
   1.105 -
   1.106 -    static interface SAM2 {
   1.107 -        List<String> foo();
   1.108 -    }
   1.109 -
   1.110 -    static interface SAM3 {
   1.111 -        String foo(int a);
   1.112 -    }
   1.113 -
   1.114 -    static interface SAM4 {
   1.115 -        void foo(List<File> a);
   1.116 -    }
   1.117 -
   1.118 -    static interface SAM5 {
   1.119 -        void foo();
   1.120 -    }
   1.121 -
   1.122 -    static interface SAM6<T, V> {
   1.123 -        V get(T t, T t2);
   1.124 -    }
   1.125 -}

mercurial