1 package test 2 3 /* 4 * The MIT License 5 * 6 * Copyright (c) 2016 Niek Haarman 7 * Copyright (c) 2007 Mockito contributors 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and associated documentation files (the "Software"), to deal 11 * in the Software without restriction, including without limitation the rights 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 * copies of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 * THE SOFTWARE. 26 */ 27 28 open class Open { gonull29 open fun go(vararg arg: Any?) { 30 } 31 modifiesContentsnull32 open fun modifiesContents(a: IntArray) { 33 for (i in 0..a.size - 1) { 34 a[i] = a[i] + 1 35 } 36 } 37 stringResultnull38 open fun stringResult() = "Default" 39 40 fun throwsNPE(): Any = throw NullPointerException("Test") 41 } 42 43 class Closed 44 45 interface Methods { 46 47 fun intArray(i: IntArray) 48 fun closed(c: Closed) 49 fun closedArray(a: Array<Closed>) 50 fun closedNullableArray(a: Array<Closed?>) 51 fun closedCollection(c: Collection<Closed>) 52 fun closedList(c: List<Closed>) 53 fun closedStringMap(m: Map<Closed, String>) 54 fun closedSet(s: Set<Closed>) 55 fun string(s: String) 56 fun boolean(b: Boolean) 57 fun byte(b: Byte) 58 fun char(c: Char) 59 fun short(s: Short) 60 fun int(i: Int) 61 fun long(l: Long) 62 fun float(f: Float) 63 fun double(d: Double) 64 fun closedVararg(vararg c: Closed) 65 fun throwableClass(t: ThrowableClass) 66 fun nullableString(s: String?) 67 68 fun stringResult(): String 69 fun stringResult(s: String): String 70 fun nullableStringResult(): String? 71 fun builderMethod(): Methods 72 fun varargBooleanResult(vararg values: String): Boolean 73 74 fun nonDefaultReturnType(): ExtraInterface 75 } 76 77 interface ExtraInterface 78 79 abstract class ThrowingConstructor { 80 81 constructor() { 82 error("Error in constructor") 83 } 84 } 85 86 abstract class ThrowingConstructorWithArgument { 87 88 constructor(s: String) { 89 error("Error in constructor: $s") 90 } 91 } 92 93 abstract class NonThrowingConstructorWithArgument { 94 95 constructor() { 96 error("Error in constructor") 97 } 98 99 @Suppress("UNUSED_PARAMETER") 100 constructor(s: String) 101 } 102 103 interface GenericMethods<T> { genericMethodnull104 fun genericMethod(): T 105 fun nullableReturnType(): T? 106 } 107 108 class ThrowableClass(cause: Throwable) : Throwable(cause) 109