blob: 65d3f07e6912d33d4368fbb0cfd79d135086f334 [file] [log] [blame]
briangoetzef42f9a2013-05-06 11:43:51 -04001/*
lanaf3d11f62013-12-26 12:04:16 -08002 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
briangoetzef42f9a2013-05-06 11:43:51 -04003 * 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
24import static org.testng.Assert.assertEquals;
25import org.testng.annotations.Test;
26
27/**
28 * @author Robert Field
29 */
30
31interface LTII {
32
33 interface ILsp1 {
34 String m();
35 }
36
37 interface ILsp2 {
38 String m(String x);
39 }
40
41 default ILsp1 t1() {
42 return () -> { return "yo"; };
43 }
44
45 default ILsp2 t2() {
46 return (x) -> { return "snur" + x; };
47 }
48
49}
50
51@Test
52public class LambdaTranslationInInterface implements LTII {
53
54 public void testLambdaInDefaultMethod() {
55 assertEquals(t1().m(), "yo");
56 assertEquals(t2().m("p"), "snurp");
57 }
58
59}