Skip to content

Commit

Permalink
Correctness fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
0marperez committed Sep 29, 2023
1 parent 3d4240b commit b643d07
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public fun Any?.type(): String = when (this) {
is Boolean -> "boolean"
is List<*>, is Array<*> -> "array"
is Short, is Int, is Long, is Float, is Double -> "number"
is HashMap<*, *>, is Any -> "object"
is Any -> "object"
null -> "null"
else -> throw Exception("Undetected type for: $this")
}
66 changes: 33 additions & 33 deletions tests/codegen/waiter-tests/model/function-type.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use smithy.waiters#waitable
state: "success",
matcher: {
output: {
path: "type(primitives.string) == types.string",
expected: "true",
comparator: "booleanEquals"
path: "type(primitives.string)",
expected: "string",
comparator: "stringEquals"
}
}
}
Expand All @@ -25,9 +25,9 @@ use smithy.waiters#waitable
state: "success",
matcher: {
output: {
path: "type(primitives.boolean) == types.boolean",
expected: "true",
comparator: "booleanEquals"
path: "type(primitives.boolean)",
expected: "boolean",
comparator: "stringEquals"
}
}
}
Expand All @@ -39,9 +39,9 @@ use smithy.waiters#waitable
state: "success",
matcher: {
output: {
path: "type(lists.booleans) == types.array",
expected: "true",
comparator: "booleanEquals"
path: "type(lists.booleans)",
expected: "array",
comparator: "stringEquals"
}
}
}
Expand All @@ -53,9 +53,9 @@ use smithy.waiters#waitable
state: "success",
matcher: {
output: {
path: "type(primitives.short) == types.number",
expected: "true",
comparator: "booleanEquals"
path: "type(primitives.short)",
expected: "number",
comparator: "stringEquals"
}
}
}
Expand All @@ -67,9 +67,9 @@ use smithy.waiters#waitable
state: "success",
matcher: {
output: {
path: "type(primitives.integer) == types.number",
expected: "true",
comparator: "booleanEquals"
path: "type(primitives.integer)",
expected: "number",
comparator: "stringEquals"
}
}
}
Expand All @@ -81,9 +81,9 @@ use smithy.waiters#waitable
state: "success",
matcher: {
output: {
path: "type(primitives.long) == types.number",
expected: "true",
comparator: "booleanEquals"
path: "type(primitives.long)",
expected: "number",
comparator: "stringEquals"
}
}
}
Expand All @@ -95,9 +95,9 @@ use smithy.waiters#waitable
state: "success",
matcher: {
output: {
path: "type(primitives.float) == types.number",
expected: "true",
comparator: "booleanEquals"
path: "type(primitives.float)",
expected: "number",
comparator: "stringEquals"
}
}
}
Expand All @@ -109,9 +109,9 @@ use smithy.waiters#waitable
state: "success",
matcher: {
output: {
path: "type(primitives.double) == types.number",
expected: "true",
comparator: "booleanEquals"
path: "type(primitives.double)",
expected: "number",
comparator: "stringEquals"
}
}
}
Expand All @@ -123,9 +123,9 @@ use smithy.waiters#waitable
state: "success",
matcher: {
output: {
path: "type(primitives) == types.objectType",
expected: "true",
comparator: "booleanEquals"
path: "type(primitives)",
expected: "object",
comparator: "stringEquals"
}
}
}
Expand All @@ -137,9 +137,9 @@ use smithy.waiters#waitable
state: "success",
matcher: {
output: {
path: "type(merge(primitives, primitives)) == types.objectType",
expected: "true",
comparator: "booleanEquals"
path: "type(merge(primitives, primitives))",
expected: "object",
comparator: "stringEquals"
}
}
}
Expand All @@ -151,9 +151,9 @@ use smithy.waiters#waitable
state: "success",
matcher: {
output: {
path: "type(primitives.boolean) == types.nullType",
expected: "true",
comparator: "booleanEquals"
path: "type(primitives.boolean)",
expected: "null",
comparator: "stringEquals"
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions tests/codegen/waiter-tests/model/utils/structures.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ structure GetEntityResponse {
sampleValues: Values,
objectOne: Values,
objectTwo: Values,
types: Types,
}

structure EntityPrimitives {
Expand Down Expand Up @@ -173,12 +172,3 @@ structure Values {
valueTwo: String
valueThree: String
}

structure Types {
string: String
boolean: String
array: String
number: String
objectType: String
nullType: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

package com.test

import com.test.model.*
import com.test.model.EntityLists
import com.test.model.EntityPrimitives
import com.test.model.GetFunctionTypeEqualsRequest
import com.test.model.GetFunctionTypeEqualsResponse
import com.test.utils.successTest
import com.test.waiters.*
import kotlin.test.Test
Expand All @@ -16,11 +19,6 @@ class FunctionTypeTest {
WaitersTestClient::waitUntilTypeFunctionStringEquals,
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { string = "foo" }
types = Types { string = "foo" }
},
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { string = "foo" }
types = Types { string = "string" }
},
)

Expand All @@ -29,11 +27,6 @@ class FunctionTypeTest {
WaitersTestClient::waitUntilTypeFunctionBooleanEquals,
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { boolean = true }
types = Types { boolean = "foo" }
},
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { boolean = true }
types = Types { boolean = "boolean" }
},
)

Expand All @@ -42,11 +35,6 @@ class FunctionTypeTest {
WaitersTestClient::waitUntilTypeFunctionArrayEquals,
GetFunctionTypeEqualsResponse {
lists = EntityLists { booleans = listOf(true) }
types = Types { array = "foo" }
},
GetFunctionTypeEqualsResponse {
lists = EntityLists { booleans = listOf(true) }
types = Types { array = "array" }
},
)

Expand All @@ -55,11 +43,6 @@ class FunctionTypeTest {
WaitersTestClient::waitUntilTypeFunctionShortEquals,
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { short = 1 }
types = Types { number = "foo" }
},
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { short = 1 }
types = Types { number = "number" }
},
)

Expand All @@ -68,11 +51,6 @@ class FunctionTypeTest {
WaitersTestClient::waitUntilTypeFunctionIntegerEquals,
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { integer = 1 }
types = Types { number = "foo" }
},
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { integer = 1 }
types = Types { number = "number" }
},
)

Expand All @@ -81,11 +59,6 @@ class FunctionTypeTest {
WaitersTestClient::waitUntilTypeFunctionLongEquals,
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { long = 1L }
types = Types { number = "foo" }
},
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { long = 1L }
types = Types { number = "number" }
},
)

Expand All @@ -94,11 +67,6 @@ class FunctionTypeTest {
WaitersTestClient::waitUntilTypeFunctionFloatEquals,
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { float = 1f }
types = Types { number = "foo" }
},
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { float = 1f }
types = Types { number = "number" }
},
)

Expand All @@ -107,11 +75,6 @@ class FunctionTypeTest {
WaitersTestClient::waitUntilTypeFunctionDoubleEquals,
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { double = 1.0 }
types = Types { number = "foo" }
},
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { double = 1.0 }
types = Types { number = "number" }
},
)

Expand All @@ -120,11 +83,6 @@ class FunctionTypeTest {
WaitersTestClient::waitUntilTypeFunctionObjectEquals,
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { }
types = Types { objectType = "foo" }
},
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { }
types = Types { objectType = "object" }
},
)

Expand All @@ -133,11 +91,6 @@ class FunctionTypeTest {
WaitersTestClient::waitUntilTypeFunctionMergedObjectEquals,
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { }
types = Types { objectType = "foo" }
},
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { }
types = Types { objectType = "object" }
},
)

Expand All @@ -146,11 +99,6 @@ class FunctionTypeTest {
WaitersTestClient::waitUntilTypeFunctionNullEquals,
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { boolean = null }
types = Types { nullType = "foo" }
},
GetFunctionTypeEqualsResponse {
primitives = EntityPrimitives { boolean = null }
types = Types { nullType = "null" }
},
)
}

0 comments on commit b643d07

Please sign in to comment.