Adding support for testing BUILD.gn
BUG=tint:50 Change-Id: Ie19a1af6a97a49a67dcc7474991c960b986ddebe Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19782 Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
366b74c364
commit
0a196c13c8
466
BUILD.gn
466
BUILD.gn
|
@ -13,12 +13,14 @@
|
|||
# limitations under the License.
|
||||
|
||||
import("//build_overrides/build.gni")
|
||||
import("//testing/test.gni")
|
||||
import("tint_overrides_with_defaults.gni")
|
||||
|
||||
###############################################################################
|
||||
# Common - Configs, etc. shared across targets
|
||||
###############################################################################
|
||||
|
||||
config("tint_common_config") {
|
||||
cflags = []
|
||||
ldflags = []
|
||||
include_dirs = []
|
||||
defines = []
|
||||
|
||||
if (tint_build_spv_reader) {
|
||||
|
@ -46,15 +48,20 @@ config("tint_common_config") {
|
|||
}
|
||||
}
|
||||
|
||||
# libtint source sets are divided into a non-optional core in :libtint_core and
|
||||
# optional :libtint_* subsets, because ninja does not like having multiple source
|
||||
# files with the same name, like function.cc, in the same source set target.
|
||||
###############################################################################
|
||||
# Library - Tint core and optional modules of libtint
|
||||
###############################################################################
|
||||
# libtint source sets are divided into a non-optional core in :libtint_core_src
|
||||
# and optional :libtint_*_src subsets, because ninja does not like having
|
||||
# multiple source files with the same name, like function.cc, in the same
|
||||
# source set
|
||||
# target.
|
||||
#
|
||||
# Targets that want to use tint as a library should depend on ":libtint" and use
|
||||
# the build flags to control what is included, instead of trying to specify the
|
||||
# subsets that they want.
|
||||
# Targets that want to use tint as a library should depend on ":libtint" and
|
||||
# use the build flags to control what is included, instead of trying to specify
|
||||
# the subsets that they want.
|
||||
|
||||
source_set("libtint_core") {
|
||||
source_set("libtint_core_src") {
|
||||
sources = [
|
||||
"src/ast/array_accessor_expression.cc",
|
||||
"src/ast/array_accessor_expression.h",
|
||||
|
@ -224,7 +231,7 @@ source_set("libtint_core") {
|
|||
}
|
||||
}
|
||||
|
||||
config("tint_spv_reader_config") {
|
||||
config("libtint_spv_config") {
|
||||
include_dirs = [
|
||||
"${tint_spirv_tools_dir}/",
|
||||
"${tint_spirv_tools_dir}/include",
|
||||
|
@ -232,7 +239,7 @@ config("tint_spv_reader_config") {
|
|||
]
|
||||
}
|
||||
|
||||
source_set("libtint_spv_reader") {
|
||||
source_set("libtint_spv_reader_src") {
|
||||
sources = [
|
||||
"src/reader/spirv/enum_converter.cc",
|
||||
"src/reader/spirv/enum_converter.h",
|
||||
|
@ -253,8 +260,10 @@ source_set("libtint_spv_reader") {
|
|||
"${tint_spirv_tools_dir}/:spvtools_val",
|
||||
]
|
||||
|
||||
configs += [ ":tint_common_config" ]
|
||||
configs += [ ":tint_spv_reader_config" ]
|
||||
configs += [
|
||||
":tint_common_config",
|
||||
":libtint_spv_config",
|
||||
]
|
||||
|
||||
if (build_with_chromium) {
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
|
@ -262,7 +271,7 @@ source_set("libtint_spv_reader") {
|
|||
}
|
||||
}
|
||||
|
||||
source_set("libtint_spv_writer") {
|
||||
source_set("libtint_spv_writer_src") {
|
||||
sources = [
|
||||
"src/writer/spirv/binary_writer.cc",
|
||||
"src/writer/spirv/binary_writer.h",
|
||||
|
@ -280,7 +289,10 @@ source_set("libtint_spv_writer") {
|
|||
|
||||
deps = [ "${tint_spirv_headers_dir}/:spv_headers" ]
|
||||
|
||||
configs += [ ":tint_common_config" ]
|
||||
configs += [
|
||||
":tint_common_config",
|
||||
":libtint_spv_config",
|
||||
]
|
||||
|
||||
if (build_with_chromium) {
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
|
@ -288,7 +300,7 @@ source_set("libtint_spv_writer") {
|
|||
}
|
||||
}
|
||||
|
||||
source_set("libtint_wgsl_reader") {
|
||||
source_set("libtint_wgsl_reader_src") {
|
||||
sources = [
|
||||
"src/reader/wgsl/lexer.cc",
|
||||
"src/reader/wgsl/lexer.h",
|
||||
|
@ -308,7 +320,7 @@ source_set("libtint_wgsl_reader") {
|
|||
}
|
||||
}
|
||||
|
||||
source_set("libtint_wgsl_writer") {
|
||||
source_set("libtint_wgsl_writer_src") {
|
||||
sources = [
|
||||
"src/writer/wgsl/generator.cc",
|
||||
"src/writer/wgsl/generator.h",
|
||||
|
@ -325,22 +337,22 @@ source_set("libtint_wgsl_writer") {
|
|||
}
|
||||
|
||||
source_set("libtint") {
|
||||
deps = [ ":libtint_core" ]
|
||||
deps = [ ":libtint_core_src" ]
|
||||
|
||||
if (tint_build_spv_reader) {
|
||||
deps += [ ":libtint_spv_reader" ]
|
||||
deps += [ ":libtint_spv_reader_src" ]
|
||||
}
|
||||
|
||||
if (tint_build_spv_writer) {
|
||||
deps += [ ":libtint_spv_writer" ]
|
||||
deps += [ ":libtint_spv_writer_src" ]
|
||||
}
|
||||
|
||||
if (tint_build_wgsl_reader) {
|
||||
deps += [ ":libtint_wgsl_reader" ]
|
||||
deps += [ ":libtint_wgsl_reader_src" ]
|
||||
}
|
||||
|
||||
if (tint_build_wgsl_writer) {
|
||||
deps += [ ":libtint_wgsl_writer" ]
|
||||
deps += [ ":libtint_wgsl_writer_src" ]
|
||||
}
|
||||
|
||||
configs += [ ":tint_common_config" ]
|
||||
|
@ -351,6 +363,408 @@ source_set("libtint") {
|
|||
}
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Gtest Gmock - Handle building inside and outside of Chromium.
|
||||
###############################################################################
|
||||
# When building outside of Chromium we need to define our own targets for GTest
|
||||
# and GMock. However when compiling inside of Chromium we need to reuse the
|
||||
# existing targets, both because Chromium has a special harness for swarming
|
||||
# and because otherwise the "gn check" fails.
|
||||
|
||||
if (!build_with_chromium) {
|
||||
# When we aren't in Chromium we define out own targets based on the location
|
||||
# of the googletest repo.
|
||||
config("gtest_config") {
|
||||
include_dirs = [
|
||||
"${tint_googletest_dir}/googletest",
|
||||
"${tint_googletest_dir}/googletest/include",
|
||||
]
|
||||
}
|
||||
static_library("gtest") {
|
||||
testonly = true
|
||||
sources = [ "${tint_googletest_dir}/googletest/src/gtest-all.cc" ]
|
||||
public_configs = [ ":gtest_config" ]
|
||||
}
|
||||
|
||||
config("gmock_config") {
|
||||
include_dirs = [
|
||||
"${tint_googletest_dir}/googlemock",
|
||||
"${tint_googletest_dir}/googlemock/include",
|
||||
"${tint_googletest_dir}/googletest/include",
|
||||
]
|
||||
}
|
||||
|
||||
static_library("gmock") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"${tint_googletest_dir}/googlemock/src/gmock-all.cc",
|
||||
"${tint_googletest_dir}/googlemock/src/gmock_main.cc",
|
||||
]
|
||||
public_configs = [ ":gmock_config" ]
|
||||
}
|
||||
|
||||
group("gmock_and_gtest") {
|
||||
testonly = true
|
||||
public_deps = [
|
||||
":gmock",
|
||||
":gtest",
|
||||
]
|
||||
}
|
||||
} else {
|
||||
# When we are in Chromium we reuse its targets, and also add some deps that
|
||||
# are needed to launch the test in swarming mode.
|
||||
group("gmock_and_gtest") {
|
||||
testonly = true
|
||||
public_deps = [
|
||||
"//base",
|
||||
"//base/test:test_support",
|
||||
"//testing/gmock",
|
||||
"//testing/gtest",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Tests - For libtint core and optional modules
|
||||
###############################################################################
|
||||
config("tint_unittests_config") {
|
||||
include_dirs = [
|
||||
"${tint_googletest_dir}/googlemock/include",
|
||||
"${tint_googletest_dir}/googletest/include",
|
||||
]
|
||||
}
|
||||
|
||||
source_set("tint_unittests_core_src") {
|
||||
sources = [
|
||||
"src/ast/array_accessor_expression_test.cc",
|
||||
"src/ast/as_expression_test.cc",
|
||||
"src/ast/assignment_statement_test.cc",
|
||||
"src/ast/binary_expression_test.cc",
|
||||
"src/ast/binding_decoration_test.cc",
|
||||
"src/ast/bool_literal_test.cc",
|
||||
"src/ast/break_statement_test.cc",
|
||||
"src/ast/builtin_decoration_test.cc",
|
||||
"src/ast/call_expression_test.cc",
|
||||
"src/ast/case_statement_test.cc",
|
||||
"src/ast/cast_expression_test.cc",
|
||||
"src/ast/continue_statement_test.cc",
|
||||
"src/ast/decorated_variable_test.cc",
|
||||
"src/ast/else_statement_test.cc",
|
||||
"src/ast/entry_point_test.cc",
|
||||
"src/ast/fallthrough_statement_test.cc",
|
||||
"src/ast/float_literal_test.cc",
|
||||
"src/ast/function_test.cc",
|
||||
"src/ast/identifier_expression_test.cc",
|
||||
"src/ast/if_statement_test.cc",
|
||||
"src/ast/import_test.cc",
|
||||
"src/ast/int_literal_test.cc",
|
||||
"src/ast/kill_statement_test.cc",
|
||||
"src/ast/location_decoration_test.cc",
|
||||
"src/ast/loop_statement_test.cc",
|
||||
"src/ast/member_accessor_expression_test.cc",
|
||||
"src/ast/module_test.cc",
|
||||
"src/ast/nop_statement_test.cc",
|
||||
"src/ast/return_statement_test.cc",
|
||||
"src/ast/scalar_constructor_expression_test.cc",
|
||||
"src/ast/set_decoration_test.cc",
|
||||
"src/ast/struct_member_offset_decoration_test.cc",
|
||||
"src/ast/struct_member_test.cc",
|
||||
"src/ast/struct_test.cc",
|
||||
"src/ast/switch_statement_test.cc",
|
||||
"src/ast/type/alias_type_test.cc",
|
||||
"src/ast/type/array_type_test.cc",
|
||||
"src/ast/type/bool_type_test.cc",
|
||||
"src/ast/type/f32_type_test.cc",
|
||||
"src/ast/type/i32_type_test.cc",
|
||||
"src/ast/type/matrix_type_test.cc",
|
||||
"src/ast/type/pointer_type_test.cc",
|
||||
"src/ast/type/struct_type_test.cc",
|
||||
"src/ast/type/u32_type_test.cc",
|
||||
"src/ast/type/vector_type_test.cc",
|
||||
"src/ast/type_constructor_expression_test.cc",
|
||||
"src/ast/uint_literal_test.cc",
|
||||
"src/ast/unary_derivative_expression_test.cc",
|
||||
"src/ast/unary_method_expression_test.cc",
|
||||
"src/ast/unary_op_expression_test.cc",
|
||||
"src/ast/unless_statement_test.cc",
|
||||
"src/ast/variable_decl_statement_test.cc",
|
||||
"src/ast/variable_test.cc",
|
||||
"src/scope_stack_test.cc",
|
||||
"src/type_determiner_test.cc",
|
||||
"src/type_manager_test.cc",
|
||||
"src/validator_impl_import_test.cc",
|
||||
]
|
||||
|
||||
configs += [
|
||||
":tint_common_config",
|
||||
":tint_unittests_config",
|
||||
]
|
||||
|
||||
if (build_with_chromium) {
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
}
|
||||
}
|
||||
|
||||
source_set("tint_unittests_spv_reader_src") {
|
||||
sources = [
|
||||
"src/reader/spirv/enum_converter_test.cc",
|
||||
"src/reader/spirv/fail_stream_test.cc",
|
||||
"src/reader/spirv/function_arithmetic_test.cc",
|
||||
"src/reader/spirv/function_decl_test.cc",
|
||||
"src/reader/spirv/function_logical_test.cc",
|
||||
"src/reader/spirv/function_memory_test.cc",
|
||||
"src/reader/spirv/function_var_test.cc",
|
||||
"src/reader/spirv/namer_test.cc",
|
||||
"src/reader/spirv/parser_impl_convert_member_decoration_test.cc",
|
||||
"src/reader/spirv/parser_impl_convert_type_test.cc",
|
||||
"src/reader/spirv/parser_impl_entry_point_test.cc",
|
||||
"src/reader/spirv/parser_impl_function_decl_test.cc",
|
||||
"src/reader/spirv/parser_impl_get_decorations_test.cc",
|
||||
"src/reader/spirv/parser_impl_import_test.cc",
|
||||
"src/reader/spirv/parser_impl_module_var_test.cc",
|
||||
"src/reader/spirv/parser_impl_named_types_test.cc",
|
||||
"src/reader/spirv/parser_impl_test.cc",
|
||||
"src/reader/spirv/parser_impl_user_name_test.cc",
|
||||
"src/reader/spirv/parser_test.cc",
|
||||
"src/reader/spirv/spirv_tools_helpers_test.cc",
|
||||
"src/reader/spirv/spirv_tools_helpers_test.h",
|
||||
]
|
||||
|
||||
deps = [ "${tint_spirv_headers_dir}/:spv_headers" ]
|
||||
|
||||
configs += [
|
||||
":libtint_spv_config",
|
||||
":tint_common_config",
|
||||
":tint_unittests_config",
|
||||
]
|
||||
|
||||
if (build_with_chromium) {
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
}
|
||||
}
|
||||
|
||||
source_set("tint_unittests_spv_writer_src") {
|
||||
sources = [
|
||||
"src/writer/spirv/binary_writer_test.cc",
|
||||
"src/writer/spirv/builder_assign_test.cc",
|
||||
"src/writer/spirv/builder_binary_expression_test.cc",
|
||||
"src/writer/spirv/builder_constructor_expression_test.cc",
|
||||
"src/writer/spirv/builder_entry_point_test.cc",
|
||||
"src/writer/spirv/builder_function_test.cc",
|
||||
"src/writer/spirv/builder_function_variable_test.cc",
|
||||
"src/writer/spirv/builder_global_variable_test.cc",
|
||||
"src/writer/spirv/builder_ident_expression_test.cc",
|
||||
"src/writer/spirv/builder_if_test.cc",
|
||||
"src/writer/spirv/builder_literal_test.cc",
|
||||
"src/writer/spirv/builder_return_test.cc",
|
||||
"src/writer/spirv/builder_test.cc",
|
||||
"src/writer/spirv/builder_type_test.cc",
|
||||
"src/writer/spirv/instruction_test.cc",
|
||||
"src/writer/spirv/operand_test.cc",
|
||||
"src/writer/spirv/spv_dump.cc",
|
||||
"src/writer/spirv/spv_dump.h",
|
||||
]
|
||||
deps = [ "${tint_spirv_headers_dir}/:spv_headers" ]
|
||||
|
||||
configs += [
|
||||
":libtint_spv_config",
|
||||
":tint_common_config",
|
||||
":tint_unittests_config",
|
||||
]
|
||||
|
||||
if (build_with_chromium) {
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
}
|
||||
}
|
||||
|
||||
source_set("tint_unittests_wgsl_reader_src") {
|
||||
sources = [
|
||||
"src/reader/wgsl/lexer_test.cc",
|
||||
"src/reader/wgsl/parser_impl_additive_expression_test.cc",
|
||||
"src/reader/wgsl/parser_impl_and_expression_test.cc",
|
||||
"src/reader/wgsl/parser_impl_argument_expression_list_test.cc",
|
||||
"src/reader/wgsl/parser_impl_assignment_stmt_test.cc",
|
||||
"src/reader/wgsl/parser_impl_body_stmt_test.cc",
|
||||
"src/reader/wgsl/parser_impl_break_stmt_test.cc",
|
||||
"src/reader/wgsl/parser_impl_builtin_decoration_test.cc",
|
||||
"src/reader/wgsl/parser_impl_case_body_test.cc",
|
||||
"src/reader/wgsl/parser_impl_const_expr_test.cc",
|
||||
"src/reader/wgsl/parser_impl_const_literal_test.cc",
|
||||
"src/reader/wgsl/parser_impl_continue_stmt_test.cc",
|
||||
"src/reader/wgsl/parser_impl_continuing_stmt_test.cc",
|
||||
"src/reader/wgsl/parser_impl_derivative_modifier_test.cc",
|
||||
"src/reader/wgsl/parser_impl_else_stmt_test.cc",
|
||||
"src/reader/wgsl/parser_impl_elseif_stmt_test.cc",
|
||||
"src/reader/wgsl/parser_impl_entry_point_decl_test.cc",
|
||||
"src/reader/wgsl/parser_impl_equality_expression_test.cc",
|
||||
"src/reader/wgsl/parser_impl_exclusive_or_expression_test.cc",
|
||||
"src/reader/wgsl/parser_impl_function_decl_test.cc",
|
||||
"src/reader/wgsl/parser_impl_function_header_test.cc",
|
||||
"src/reader/wgsl/parser_impl_function_type_decl_test.cc",
|
||||
"src/reader/wgsl/parser_impl_global_constant_decl_test.cc",
|
||||
"src/reader/wgsl/parser_impl_global_decl_test.cc",
|
||||
"src/reader/wgsl/parser_impl_global_variable_decl_test.cc",
|
||||
"src/reader/wgsl/parser_impl_if_stmt_test.cc",
|
||||
"src/reader/wgsl/parser_impl_import_decl_test.cc",
|
||||
"src/reader/wgsl/parser_impl_inclusive_or_expression_test.cc",
|
||||
"src/reader/wgsl/parser_impl_logical_and_expression_test.cc",
|
||||
"src/reader/wgsl/parser_impl_logical_or_expression_test.cc",
|
||||
"src/reader/wgsl/parser_impl_loop_stmt_test.cc",
|
||||
"src/reader/wgsl/parser_impl_multiplicative_expression_test.cc",
|
||||
"src/reader/wgsl/parser_impl_param_list_test.cc",
|
||||
"src/reader/wgsl/parser_impl_paren_rhs_stmt_test.cc",
|
||||
"src/reader/wgsl/parser_impl_pipeline_stage_test.cc",
|
||||
"src/reader/wgsl/parser_impl_postfix_expression_test.cc",
|
||||
"src/reader/wgsl/parser_impl_primary_expression_test.cc",
|
||||
"src/reader/wgsl/parser_impl_relational_expression_test.cc",
|
||||
"src/reader/wgsl/parser_impl_shift_expression_test.cc",
|
||||
"src/reader/wgsl/parser_impl_statement_test.cc",
|
||||
"src/reader/wgsl/parser_impl_statements_test.cc",
|
||||
"src/reader/wgsl/parser_impl_storage_class_test.cc",
|
||||
"src/reader/wgsl/parser_impl_struct_body_decl_test.cc",
|
||||
"src/reader/wgsl/parser_impl_struct_decl_test.cc",
|
||||
"src/reader/wgsl/parser_impl_struct_decoration_decl_test.cc",
|
||||
"src/reader/wgsl/parser_impl_struct_decoration_test.cc",
|
||||
"src/reader/wgsl/parser_impl_struct_member_decoration_decl_test.cc",
|
||||
"src/reader/wgsl/parser_impl_struct_member_decoration_test.cc",
|
||||
"src/reader/wgsl/parser_impl_struct_member_test.cc",
|
||||
"src/reader/wgsl/parser_impl_switch_body_test.cc",
|
||||
"src/reader/wgsl/parser_impl_switch_stmt_test.cc",
|
||||
"src/reader/wgsl/parser_impl_test.cc",
|
||||
"src/reader/wgsl/parser_impl_test_helper.cc",
|
||||
"src/reader/wgsl/parser_impl_test_helper.h",
|
||||
"src/reader/wgsl/parser_impl_type_alias_test.cc",
|
||||
"src/reader/wgsl/parser_impl_type_decl_test.cc",
|
||||
"src/reader/wgsl/parser_impl_unary_expression_test.cc",
|
||||
"src/reader/wgsl/parser_impl_unless_stmt_test.cc",
|
||||
"src/reader/wgsl/parser_impl_variable_decl_test.cc",
|
||||
"src/reader/wgsl/parser_impl_variable_decoration_list_test.cc",
|
||||
"src/reader/wgsl/parser_impl_variable_decoration_test.cc",
|
||||
"src/reader/wgsl/parser_impl_variable_ident_decl_test.cc",
|
||||
"src/reader/wgsl/parser_impl_variable_stmt_test.cc",
|
||||
"src/reader/wgsl/parser_impl_variable_storage_decoration_test.cc",
|
||||
"src/reader/wgsl/parser_test.cc",
|
||||
"src/reader/wgsl/token_test.cc",
|
||||
]
|
||||
|
||||
configs += [
|
||||
":tint_common_config",
|
||||
":tint_unittests_config",
|
||||
]
|
||||
|
||||
if (build_with_chromium) {
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
}
|
||||
}
|
||||
|
||||
source_set("tint_unittests_wgsl_writer_src") {
|
||||
sources = [
|
||||
"src/writer/wgsl/generator_impl_alias_type_test.cc",
|
||||
"src/writer/wgsl/generator_impl_array_accessor_test.cc",
|
||||
"src/writer/wgsl/generator_impl_as_test.cc",
|
||||
"src/writer/wgsl/generator_impl_assign_test.cc",
|
||||
"src/writer/wgsl/generator_impl_break_test.cc",
|
||||
"src/writer/wgsl/generator_impl_call_test.cc",
|
||||
"src/writer/wgsl/generator_impl_case_test.cc",
|
||||
"src/writer/wgsl/generator_impl_cast_test.cc",
|
||||
"src/writer/wgsl/generator_impl_constructor_test.cc",
|
||||
"src/writer/wgsl/generator_impl_continue_test.cc",
|
||||
"src/writer/wgsl/generator_impl_else_test.cc",
|
||||
"src/writer/wgsl/generator_impl_entry_point_test.cc",
|
||||
"src/writer/wgsl/generator_impl_fallthrough_test.cc",
|
||||
"src/writer/wgsl/generator_impl_function_test.cc",
|
||||
"src/writer/wgsl/generator_impl_identifier_test.cc",
|
||||
"src/writer/wgsl/generator_impl_if_test.cc",
|
||||
"src/writer/wgsl/generator_impl_import_test.cc",
|
||||
"src/writer/wgsl/generator_impl_kill_test.cc",
|
||||
"src/writer/wgsl/generator_impl_loop_test.cc",
|
||||
"src/writer/wgsl/generator_impl_member_accessor_test.cc",
|
||||
"src/writer/wgsl/generator_impl_nop_test.cc",
|
||||
"src/writer/wgsl/generator_impl_relational_test.cc",
|
||||
"src/writer/wgsl/generator_impl_return_test.cc",
|
||||
"src/writer/wgsl/generator_impl_switch_test.cc",
|
||||
"src/writer/wgsl/generator_impl_test.cc",
|
||||
"src/writer/wgsl/generator_impl_type_test.cc",
|
||||
"src/writer/wgsl/generator_impl_unary_derivative_test.cc",
|
||||
"src/writer/wgsl/generator_impl_unary_method_test.cc",
|
||||
"src/writer/wgsl/generator_impl_unary_op_test.cc",
|
||||
"src/writer/wgsl/generator_impl_unless_test.cc",
|
||||
"src/writer/wgsl/generator_impl_variable_decl_statement_test.cc",
|
||||
"src/writer/wgsl/generator_impl_variable_test.cc",
|
||||
]
|
||||
|
||||
configs += [
|
||||
":tint_common_config",
|
||||
":tint_unittests_config",
|
||||
]
|
||||
|
||||
if (build_with_chromium) {
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
}
|
||||
}
|
||||
|
||||
source_set("tint_unittests_src") {
|
||||
deps = [ ":tint_unittests_core_src" ]
|
||||
|
||||
if (tint_build_spv_reader) {
|
||||
deps += [ ":tint_unittests_spv_reader_src" ]
|
||||
}
|
||||
|
||||
if (tint_build_spv_writer) {
|
||||
deps += [ ":tint_unittests_spv_writer_src" ]
|
||||
}
|
||||
|
||||
if (tint_build_wgsl_reader) {
|
||||
deps += [ ":tint_unittests_wgsl_reader_src" ]
|
||||
}
|
||||
|
||||
if (tint_build_wgsl_writer) {
|
||||
deps += [ ":tint_unittests_wgsl_writer_src" ]
|
||||
}
|
||||
|
||||
configs += [
|
||||
":tint_common_config",
|
||||
":tint_unittests_config",
|
||||
]
|
||||
|
||||
if (build_with_chromium) {
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
}
|
||||
}
|
||||
|
||||
test("tint_unittests") {
|
||||
deps = [
|
||||
":gmock_and_gtest",
|
||||
":libtint",
|
||||
":tint_unittests_src",
|
||||
]
|
||||
|
||||
# TODO(rharrison): Use main() from chromium for chromium tree builds. This
|
||||
# requires adding a file to //gpu like Dawn has done.
|
||||
|
||||
configs += [
|
||||
":tint_common_config",
|
||||
":tint_unittests_config",
|
||||
]
|
||||
|
||||
if (build_with_chromium) {
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
}
|
||||
|
||||
testonly = true
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Samples - Executables exposing command line functionality
|
||||
###############################################################################
|
||||
|
||||
config("tint_exe_config") {
|
||||
include_dirs = []
|
||||
if (tint_build_spv_reader || tint_build_spv_writer) {
|
||||
|
@ -363,7 +777,7 @@ executable("tint_exe") {
|
|||
deps = [ ":libtint" ]
|
||||
|
||||
if (tint_build_spv_reader || tint_build_spv_writer) {
|
||||
deps += ["${tint_spirv_headers_dir}/:spv_headers" ]
|
||||
deps += [ "${tint_spirv_headers_dir}/:spv_headers" ]
|
||||
}
|
||||
|
||||
configs += [ ":tint_common_config" ]
|
||||
|
@ -374,7 +788,3 @@ executable("tint_exe") {
|
|||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
}
|
||||
}
|
||||
|
||||
group("tint_all") {
|
||||
deps = [ ":tint_exe" ]
|
||||
}
|
||||
|
|
13
DEPS
13
DEPS
|
@ -9,18 +9,16 @@ vars = {
|
|||
'buildtools_revision': '74cfb57006f83cfe050817526db359d5c8a11628',
|
||||
'clang_revision': '3605577b67603ec5776afcfada9e0ff4ea05cf0e',
|
||||
'cpplint_revision': '305ac8725a166ed42e3f5dd3f80d6de2cf840ef1',
|
||||
'googletest_revision': '482ac6ee63429af2aa9c44f4e6427873fb68fb1f',
|
||||
'googletest_revision': 'dcc92d0ab6c4ce022162a23566d44f673251eee4',
|
||||
'spirv_headers_revision': 'f8bf11a0253a32375c32cad92c841237b96696c0',
|
||||
'spirv_tools_revision': '60104cd97446877dad8ed1010a635218937a2f18',
|
||||
'testing_revision': 'e5ced5141379ee8ae28b4f93d3c02df039d2b052',
|
||||
}
|
||||
|
||||
deps = {
|
||||
'third_party/cpplint': Var('chromium_git') + Var('github') +
|
||||
'/google/styleguide.git@' + Var('cpplint_revision'),
|
||||
|
||||
'third_party/googletest': Var('chromium_git') + Var('github') +
|
||||
'/google/googletest.git@' + Var('googletest_revision'),
|
||||
|
||||
'third_party/spirv-headers': Var('chromium_git') + Var('github') +
|
||||
'/KhronosGroup/SPIRV-Headers.git@' + Var('spirv_headers_revision'),
|
||||
|
||||
|
@ -39,6 +37,13 @@ deps = {
|
|||
|
||||
'third_party/binutils': Var('chromium_git') +
|
||||
'/chromium/src/third_party/binutils@' + Var('binutils_revision'),
|
||||
|
||||
# Dependencies required for testing
|
||||
'testing': Var('chromium_git') + '/chromium/src/testing@' +
|
||||
Var('testing_revision'),
|
||||
|
||||
'third_party/googletest': Var('chromium_git') + Var('github') +
|
||||
'/google/googletest.git@' + Var('googletest_revision'),
|
||||
}
|
||||
|
||||
hooks = [
|
||||
|
|
|
@ -402,6 +402,7 @@ if(${TINT_BUILD_WGSL_READER})
|
|||
reader/wgsl/parser_impl_switch_body_test.cc
|
||||
reader/wgsl/parser_impl_switch_stmt_test.cc
|
||||
reader/wgsl/parser_impl_test.cc
|
||||
reader/wgsl/parser_impl_test_helper.cc
|
||||
reader/wgsl/parser_impl_test_helper.h
|
||||
reader/wgsl/parser_impl_type_alias_test.cc
|
||||
reader/wgsl/parser_impl_type_decl_test.cc
|
||||
|
|
|
@ -27,8 +27,8 @@ TEST_F(ArrayAccessorExpressionTest, Create) {
|
|||
auto ary = std::make_unique<IdentifierExpression>("ary");
|
||||
auto idx = std::make_unique<IdentifierExpression>("idx");
|
||||
|
||||
auto ary_ptr = ary.get();
|
||||
auto idx_ptr = idx.get();
|
||||
auto* ary_ptr = ary.get();
|
||||
auto* idx_ptr = idx.get();
|
||||
|
||||
ArrayAccessorExpression exp(std::move(ary), std::move(idx));
|
||||
ASSERT_EQ(exp.array(), ary_ptr);
|
||||
|
@ -40,8 +40,8 @@ TEST_F(ArrayAccessorExpressionTest, CreateWithSource) {
|
|||
|
||||
ArrayAccessorExpression exp(Source{20, 2}, std::move(ary), std::move(idx));
|
||||
auto src = exp.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(ArrayAccessorExpressionTest, IsArrayAccessor) {
|
||||
|
|
|
@ -28,7 +28,7 @@ TEST_F(AsExpressionTest, Create) {
|
|||
type::F32Type f32;
|
||||
auto expr = std::make_unique<IdentifierExpression>("expr");
|
||||
|
||||
auto expr_ptr = expr.get();
|
||||
auto* expr_ptr = expr.get();
|
||||
|
||||
AsExpression exp(&f32, std::move(expr));
|
||||
ASSERT_EQ(exp.type(), &f32);
|
||||
|
@ -41,8 +41,8 @@ TEST_F(AsExpressionTest, CreateWithSource) {
|
|||
|
||||
AsExpression exp(Source{20, 2}, &f32, std::move(expr));
|
||||
auto src = exp.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(AsExpressionTest, IsAs) {
|
||||
|
|
|
@ -27,8 +27,8 @@ TEST_F(AssignmentStatementTest, Creation) {
|
|||
auto lhs = std::make_unique<ast::IdentifierExpression>("lhs");
|
||||
auto rhs = std::make_unique<ast::IdentifierExpression>("rhs");
|
||||
|
||||
auto lhs_ptr = lhs.get();
|
||||
auto rhs_ptr = rhs.get();
|
||||
auto* lhs_ptr = lhs.get();
|
||||
auto* rhs_ptr = rhs.get();
|
||||
|
||||
AssignmentStatement stmt(std::move(lhs), std::move(rhs));
|
||||
EXPECT_EQ(stmt.lhs(), lhs_ptr);
|
||||
|
@ -41,8 +41,8 @@ TEST_F(AssignmentStatementTest, CreationWithSource) {
|
|||
|
||||
AssignmentStatement stmt(Source{20, 2}, std::move(lhs), std::move(rhs));
|
||||
auto src = stmt.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(AssignmentStatementTest, IsAssign) {
|
||||
|
|
|
@ -29,8 +29,8 @@ TEST_F(BinaryExpressionTest, Creation) {
|
|||
auto lhs = std::make_unique<IdentifierExpression>("lhs");
|
||||
auto rhs = std::make_unique<IdentifierExpression>("rhs");
|
||||
|
||||
auto lhs_ptr = lhs.get();
|
||||
auto rhs_ptr = rhs.get();
|
||||
auto* lhs_ptr = lhs.get();
|
||||
auto* rhs_ptr = rhs.get();
|
||||
|
||||
BinaryExpression r(BinaryOp::kEqual, std::move(lhs), std::move(rhs));
|
||||
EXPECT_EQ(r.lhs(), lhs_ptr);
|
||||
|
@ -45,8 +45,8 @@ TEST_F(BinaryExpressionTest, Creation_WithSource) {
|
|||
BinaryExpression r(Source{20, 2}, BinaryOp::kEqual, std::move(lhs),
|
||||
std::move(rhs));
|
||||
auto src = r.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(BinaryExpressionTest, IsBinaryal) {
|
||||
|
|
|
@ -24,7 +24,7 @@ using BindingDecorationTest = testing::Test;
|
|||
|
||||
TEST_F(BindingDecorationTest, Creation) {
|
||||
BindingDecoration d{2};
|
||||
EXPECT_EQ(2, d.value());
|
||||
EXPECT_EQ(2u, d.value());
|
||||
}
|
||||
|
||||
TEST_F(BindingDecorationTest, Is) {
|
||||
|
|
|
@ -32,7 +32,7 @@ TEST_F(BreakStatementTest, Creation) {
|
|||
|
||||
TEST_F(BreakStatementTest, CreationWithConditional) {
|
||||
auto expr = std::make_unique<IdentifierExpression>("expr");
|
||||
auto expr_ptr = expr.get();
|
||||
auto* expr_ptr = expr.get();
|
||||
|
||||
BreakStatement stmt(StatementCondition::kIf, std::move(expr));
|
||||
EXPECT_EQ(stmt.condition(), StatementCondition::kIf);
|
||||
|
@ -42,8 +42,8 @@ TEST_F(BreakStatementTest, CreationWithConditional) {
|
|||
TEST_F(BreakStatementTest, Creation_WithSource) {
|
||||
BreakStatement stmt(Source{20, 2});
|
||||
auto src = stmt.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(BreakStatementTest, Creation_WithSourceAndCondition) {
|
||||
|
@ -52,8 +52,8 @@ TEST_F(BreakStatementTest, Creation_WithSourceAndCondition) {
|
|||
BreakStatement stmt(Source{20, 2}, StatementCondition::kUnless,
|
||||
std::move(expr));
|
||||
auto src = stmt.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(BreakStatementTest, IsBreak) {
|
||||
|
|
|
@ -29,15 +29,15 @@ TEST_F(CallExpressionTest, Creation) {
|
|||
params.push_back(std::make_unique<IdentifierExpression>("param1"));
|
||||
params.push_back(std::make_unique<IdentifierExpression>("param2"));
|
||||
|
||||
auto func_ptr = func.get();
|
||||
auto param1_ptr = params[0].get();
|
||||
auto param2_ptr = params[1].get();
|
||||
auto* func_ptr = func.get();
|
||||
auto* param1_ptr = params[0].get();
|
||||
auto* param2_ptr = params[1].get();
|
||||
|
||||
CallExpression stmt(std::move(func), std::move(params));
|
||||
EXPECT_EQ(stmt.func(), func_ptr);
|
||||
|
||||
const auto& vec = stmt.params();
|
||||
ASSERT_EQ(vec.size(), 2);
|
||||
ASSERT_EQ(vec.size(), 2u);
|
||||
EXPECT_EQ(vec[0].get(), param1_ptr);
|
||||
EXPECT_EQ(vec[1].get(), param2_ptr);
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ TEST_F(CallExpressionTest, Creation_WithSource) {
|
|||
auto func = std::make_unique<IdentifierExpression>("func");
|
||||
CallExpression stmt(Source{20, 2}, std::move(func), {});
|
||||
auto src = stmt.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(CallExpressionTest, IsCall) {
|
||||
|
|
|
@ -32,12 +32,12 @@ TEST_F(CaseStatementTest, Creation) {
|
|||
StatementList stmts;
|
||||
stmts.push_back(std::make_unique<NopStatement>());
|
||||
|
||||
auto bool_ptr = b.get();
|
||||
auto nop_ptr = stmts[0].get();
|
||||
auto* bool_ptr = b.get();
|
||||
auto* nop_ptr = stmts[0].get();
|
||||
|
||||
CaseStatement c(std::move(b), std::move(stmts));
|
||||
EXPECT_EQ(c.condition(), bool_ptr);
|
||||
ASSERT_EQ(c.body().size(), 1);
|
||||
ASSERT_EQ(c.body().size(), 1u);
|
||||
EXPECT_EQ(c.body()[0].get(), nop_ptr);
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ TEST_F(CaseStatementTest, Creation_WithSource) {
|
|||
|
||||
CaseStatement c(Source{20, 2}, std::move(b), std::move(stmts));
|
||||
auto src = c.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(CaseStatementTest, IsDefault_WithoutCondition) {
|
||||
|
|
|
@ -27,7 +27,7 @@ using CastExpressionTest = testing::Test;
|
|||
TEST_F(CastExpressionTest, Creation) {
|
||||
type::F32Type f32;
|
||||
auto expr = std::make_unique<IdentifierExpression>("expr");
|
||||
auto expr_ptr = expr.get();
|
||||
auto* expr_ptr = expr.get();
|
||||
|
||||
CastExpression c(&f32, std::move(expr));
|
||||
EXPECT_EQ(c.type(), &f32);
|
||||
|
@ -40,8 +40,8 @@ TEST_F(CastExpressionTest, Creation_withSource) {
|
|||
|
||||
CastExpression c(Source{20, 2}, &f32, std::move(expr));
|
||||
auto src = c.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(CastExpressionTest, IsCast) {
|
||||
|
|
|
@ -32,7 +32,7 @@ TEST_F(ContinueStatementTest, Creation) {
|
|||
|
||||
TEST_F(ContinueStatementTest, CreationWithConditional) {
|
||||
auto expr = std::make_unique<IdentifierExpression>("expr");
|
||||
auto expr_ptr = expr.get();
|
||||
auto* expr_ptr = expr.get();
|
||||
|
||||
ContinueStatement stmt(StatementCondition::kIf, std::move(expr));
|
||||
EXPECT_EQ(stmt.condition(), StatementCondition::kIf);
|
||||
|
@ -42,8 +42,8 @@ TEST_F(ContinueStatementTest, CreationWithConditional) {
|
|||
TEST_F(ContinueStatementTest, Creation_WithSource) {
|
||||
ContinueStatement stmt(Source{20, 2});
|
||||
auto src = stmt.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(ContinueStatementTest, Creation_WithSourceAndCondition) {
|
||||
|
@ -52,8 +52,8 @@ TEST_F(ContinueStatementTest, Creation_WithSourceAndCondition) {
|
|||
ContinueStatement stmt(Source{20, 2}, StatementCondition::kUnless,
|
||||
std::move(expr));
|
||||
auto src = stmt.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(ContinueStatementTest, IsContinue) {
|
||||
|
|
|
@ -37,8 +37,8 @@ TEST_F(DecoratedVariableTest, Creation) {
|
|||
EXPECT_EQ(dv.name(), "my_var");
|
||||
EXPECT_EQ(dv.storage_class(), StorageClass::kFunction);
|
||||
EXPECT_EQ(dv.type(), &t);
|
||||
EXPECT_EQ(dv.line(), 0);
|
||||
EXPECT_EQ(dv.column(), 0);
|
||||
EXPECT_EQ(dv.line(), 0u);
|
||||
EXPECT_EQ(dv.column(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(DecoratedVariableTest, CreationWithSource) {
|
||||
|
@ -50,8 +50,8 @@ TEST_F(DecoratedVariableTest, CreationWithSource) {
|
|||
EXPECT_EQ(dv.name(), "i");
|
||||
EXPECT_EQ(dv.storage_class(), StorageClass::kPrivate);
|
||||
EXPECT_EQ(dv.type(), &t);
|
||||
EXPECT_EQ(dv.line(), 27);
|
||||
EXPECT_EQ(dv.column(), 4);
|
||||
EXPECT_EQ(dv.line(), 27u);
|
||||
EXPECT_EQ(dv.column(), 4u);
|
||||
}
|
||||
|
||||
TEST_F(DecoratedVariableTest, IsValid) {
|
||||
|
|
|
@ -34,20 +34,20 @@ TEST_F(ElseStatementTest, Creation) {
|
|||
StatementList body;
|
||||
body.push_back(std::make_unique<NopStatement>());
|
||||
|
||||
auto cond_ptr = cond.get();
|
||||
auto nop_ptr = body[0].get();
|
||||
auto* cond_ptr = cond.get();
|
||||
auto* nop_ptr = body[0].get();
|
||||
|
||||
ElseStatement e(std::move(cond), std::move(body));
|
||||
EXPECT_EQ(e.condition(), cond_ptr);
|
||||
ASSERT_EQ(e.body().size(), 1);
|
||||
ASSERT_EQ(e.body().size(), 1u);
|
||||
EXPECT_EQ(e.body()[0].get(), nop_ptr);
|
||||
}
|
||||
|
||||
TEST_F(ElseStatementTest, Creation_WithSource) {
|
||||
ElseStatement e(Source{20, 2}, {});
|
||||
auto src = e.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(ElseStatementTest, IsElse) {
|
||||
|
|
|
@ -30,8 +30,8 @@ TEST_F(EntryPointTest, Creation) {
|
|||
EXPECT_EQ(e.name(), "main");
|
||||
EXPECT_EQ(e.function_name(), "vtx_main");
|
||||
EXPECT_EQ(e.stage(), PipelineStage::kVertex);
|
||||
EXPECT_EQ(e.line(), 0);
|
||||
EXPECT_EQ(e.column(), 0);
|
||||
EXPECT_EQ(e.line(), 0u);
|
||||
EXPECT_EQ(e.column(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(EntryPointTest, CreationWithSource) {
|
||||
|
@ -41,8 +41,8 @@ TEST_F(EntryPointTest, CreationWithSource) {
|
|||
EXPECT_EQ(e.name(), "main");
|
||||
EXPECT_EQ(e.function_name(), "vtx_main");
|
||||
EXPECT_EQ(e.stage(), PipelineStage::kVertex);
|
||||
EXPECT_EQ(e.line(), 27);
|
||||
EXPECT_EQ(e.column(), 4);
|
||||
EXPECT_EQ(e.line(), 27u);
|
||||
EXPECT_EQ(e.column(), 4u);
|
||||
}
|
||||
|
||||
TEST_F(EntryPointTest, CreationEmpty) {
|
||||
|
@ -56,8 +56,8 @@ TEST_F(EntryPointTest, CreationEmpty) {
|
|||
EXPECT_EQ(e.function_name(), "my_func");
|
||||
EXPECT_EQ(e.name(), "a_name");
|
||||
EXPECT_EQ(e.stage(), PipelineStage::kFragment);
|
||||
EXPECT_EQ(e.line(), 27);
|
||||
EXPECT_EQ(e.column(), 4);
|
||||
EXPECT_EQ(e.line(), 27u);
|
||||
EXPECT_EQ(e.column(), 4u);
|
||||
}
|
||||
|
||||
TEST_F(EntryPointTest, IsValid) {
|
||||
|
|
|
@ -24,15 +24,15 @@ using FallthroughStatementTest = testing::Test;
|
|||
|
||||
TEST_F(FallthroughStatementTest, Creation) {
|
||||
FallthroughStatement stmt;
|
||||
EXPECT_EQ(stmt.line(), 0);
|
||||
EXPECT_EQ(stmt.column(), 0);
|
||||
EXPECT_EQ(stmt.line(), 0u);
|
||||
EXPECT_EQ(stmt.column(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(FallthroughStatementTest, Creation_WithSource) {
|
||||
FallthroughStatement stmt(Source{20, 2});
|
||||
auto src = stmt.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(FallthroughStatementTest, IsFallthrough) {
|
||||
|
|
|
@ -34,11 +34,11 @@ TEST_F(FunctionTest, Creation) {
|
|||
VariableList params;
|
||||
params.push_back(
|
||||
std::make_unique<Variable>("var", StorageClass::kNone, &i32));
|
||||
auto var_ptr = params[0].get();
|
||||
auto* var_ptr = params[0].get();
|
||||
|
||||
Function f("func", std::move(params), &void_type);
|
||||
EXPECT_EQ(f.name(), "func");
|
||||
ASSERT_EQ(f.params().size(), 1);
|
||||
ASSERT_EQ(f.params().size(), 1u);
|
||||
EXPECT_EQ(f.return_type(), &void_type);
|
||||
EXPECT_EQ(f.params()[0].get(), var_ptr);
|
||||
}
|
||||
|
@ -53,8 +53,8 @@ TEST_F(FunctionTest, Creation_WithSource) {
|
|||
|
||||
Function f(Source{20, 2}, "func", std::move(params), &void_type);
|
||||
auto src = f.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, IsValid) {
|
||||
|
|
|
@ -24,20 +24,20 @@ using IdentifierExpressionTest = testing::Test;
|
|||
|
||||
TEST_F(IdentifierExpressionTest, Creation) {
|
||||
IdentifierExpression i("ident");
|
||||
ASSERT_EQ(i.name().size(), 1);
|
||||
ASSERT_EQ(i.name().size(), 1u);
|
||||
EXPECT_EQ(i.name()[0], "ident");
|
||||
}
|
||||
|
||||
TEST_F(IdentifierExpressionTest, Creation_WithSource) {
|
||||
IdentifierExpression i(Source{20, 2}, {"ns1", "ns2", "ident"});
|
||||
ASSERT_EQ(i.name().size(), 3);
|
||||
ASSERT_EQ(i.name().size(), 3u);
|
||||
EXPECT_EQ(i.name()[0], "ns1");
|
||||
EXPECT_EQ(i.name()[1], "ns2");
|
||||
EXPECT_EQ(i.name()[2], "ident");
|
||||
|
||||
auto src = i.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(IdentifierExpressionTest, IsIdentifier) {
|
||||
|
|
|
@ -30,12 +30,12 @@ TEST_F(IfStatementTest, Creation) {
|
|||
StatementList body;
|
||||
body.push_back(std::make_unique<NopStatement>());
|
||||
|
||||
auto cond_ptr = cond.get();
|
||||
auto stmt_ptr = body[0].get();
|
||||
auto* cond_ptr = cond.get();
|
||||
auto* stmt_ptr = body[0].get();
|
||||
|
||||
IfStatement stmt(std::move(cond), std::move(body));
|
||||
EXPECT_EQ(stmt.condition(), cond_ptr);
|
||||
ASSERT_EQ(stmt.body().size(), 1);
|
||||
ASSERT_EQ(stmt.body().size(), 1u);
|
||||
EXPECT_EQ(stmt.body()[0].get(), stmt_ptr);
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,8 @@ TEST_F(IfStatementTest, Creation_WithSource) {
|
|||
|
||||
IfStatement stmt(Source{20, 2}, std::move(cond), std::move(body));
|
||||
auto src = stmt.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(IfStatementTest, IsIf) {
|
||||
|
|
|
@ -29,8 +29,8 @@ TEST_F(ImportTest, Creation) {
|
|||
|
||||
EXPECT_EQ(i.path(), "GLSL.std.430");
|
||||
EXPECT_EQ(i.name(), "std::glsl");
|
||||
EXPECT_EQ(i.line(), 0);
|
||||
EXPECT_EQ(i.column(), 0);
|
||||
EXPECT_EQ(i.line(), 0u);
|
||||
EXPECT_EQ(i.column(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(ImportTest, CreationWithSource) {
|
||||
|
@ -39,8 +39,8 @@ TEST_F(ImportTest, CreationWithSource) {
|
|||
|
||||
EXPECT_EQ(i.path(), "GLSL.std.430");
|
||||
EXPECT_EQ(i.name(), "std::glsl");
|
||||
EXPECT_EQ(i.line(), 27);
|
||||
EXPECT_EQ(i.column(), 4);
|
||||
EXPECT_EQ(i.line(), 27u);
|
||||
EXPECT_EQ(i.column(), 4u);
|
||||
}
|
||||
|
||||
TEST_F(ImportTest, CreationEmpty) {
|
||||
|
@ -52,8 +52,8 @@ TEST_F(ImportTest, CreationEmpty) {
|
|||
|
||||
EXPECT_EQ(i.path(), "GLSL.std.430");
|
||||
EXPECT_EQ(i.name(), "std::glsl");
|
||||
EXPECT_EQ(i.line(), 27);
|
||||
EXPECT_EQ(i.column(), 4);
|
||||
EXPECT_EQ(i.line(), 27u);
|
||||
EXPECT_EQ(i.column(), 4u);
|
||||
}
|
||||
|
||||
TEST_F(ImportTest, to_str) {
|
||||
|
|
|
@ -26,14 +26,14 @@ using KillStatementTest = testing::Test;
|
|||
|
||||
TEST_F(KillStatementTest, Creation) {
|
||||
KillStatement k;
|
||||
EXPECT_EQ(k.line(), 0);
|
||||
EXPECT_EQ(k.column(), 0);
|
||||
EXPECT_EQ(k.line(), 0u);
|
||||
EXPECT_EQ(k.column(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(KillStatementTest, Creation_WithSource) {
|
||||
KillStatement k(Source{20, 2});
|
||||
EXPECT_EQ(k.line(), 20);
|
||||
EXPECT_EQ(k.column(), 2);
|
||||
EXPECT_EQ(k.line(), 20u);
|
||||
EXPECT_EQ(k.column(), 2u);
|
||||
}
|
||||
|
||||
TEST_F(KillStatementTest, IsKill) {
|
||||
|
|
|
@ -26,7 +26,7 @@ using LocationDecorationTest = testing::Test;
|
|||
|
||||
TEST_F(LocationDecorationTest, Creation) {
|
||||
LocationDecoration d{2};
|
||||
EXPECT_EQ(2, d.value());
|
||||
EXPECT_EQ(2u, d.value());
|
||||
}
|
||||
|
||||
TEST_F(LocationDecorationTest, Is) {
|
||||
|
|
|
@ -31,16 +31,16 @@ using LoopStatementTest = testing::Test;
|
|||
TEST_F(LoopStatementTest, Creation) {
|
||||
StatementList body;
|
||||
body.push_back(std::make_unique<KillStatement>());
|
||||
auto b_ptr = body[0].get();
|
||||
auto* b_ptr = body[0].get();
|
||||
|
||||
StatementList continuing;
|
||||
continuing.push_back(std::make_unique<NopStatement>());
|
||||
auto c_ptr = continuing[0].get();
|
||||
auto* c_ptr = continuing[0].get();
|
||||
|
||||
LoopStatement l(std::move(body), std::move(continuing));
|
||||
ASSERT_EQ(l.body().size(), 1);
|
||||
ASSERT_EQ(l.body().size(), 1u);
|
||||
EXPECT_EQ(l.body()[0].get(), b_ptr);
|
||||
ASSERT_EQ(l.continuing().size(), 1);
|
||||
ASSERT_EQ(l.continuing().size(), 1u);
|
||||
EXPECT_EQ(l.continuing()[0].get(), c_ptr);
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,8 @@ TEST_F(LoopStatementTest, Creation_WithSource) {
|
|||
|
||||
LoopStatement l(Source{20, 2}, std::move(body), std::move(continuing));
|
||||
auto src = l.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(LoopStatementTest, IsLoop) {
|
||||
|
|
|
@ -29,8 +29,8 @@ TEST_F(MemberAccessorExpressionTest, Creation) {
|
|||
auto str = std::make_unique<IdentifierExpression>("structure");
|
||||
auto mem = std::make_unique<IdentifierExpression>("member");
|
||||
|
||||
auto str_ptr = str.get();
|
||||
auto mem_ptr = mem.get();
|
||||
auto* str_ptr = str.get();
|
||||
auto* mem_ptr = mem.get();
|
||||
|
||||
MemberAccessorExpression stmt(std::move(str), std::move(mem));
|
||||
EXPECT_EQ(stmt.structure(), str_ptr);
|
||||
|
@ -43,8 +43,8 @@ TEST_F(MemberAccessorExpressionTest, Creation_WithSource) {
|
|||
|
||||
MemberAccessorExpression stmt(Source{20, 2}, std::move(str), std::move(mem));
|
||||
auto src = stmt.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(MemberAccessorExpressionTest, IsMemberAccessor) {
|
||||
|
|
|
@ -33,13 +33,13 @@ using ModuleTest = testing::Test;
|
|||
TEST_F(ModuleTest, Creation) {
|
||||
Module m;
|
||||
|
||||
EXPECT_EQ(m.imports().size(), 0);
|
||||
EXPECT_EQ(m.imports().size(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(ModuleTest, ToStrEmitsPreambleAndPostamble) {
|
||||
Module m;
|
||||
const auto str = m.to_str();
|
||||
const auto expected = "Module{\n}\n";
|
||||
auto* const expected = "Module{\n}\n";
|
||||
EXPECT_EQ(str, expected);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ModuleTest, Imports) {
|
|||
m.AddImport(std::make_unique<Import>("GLSL.std.430", "std::glsl"));
|
||||
m.AddImport(std::make_unique<Import>("OpenCL.debug.100", "std::debug"));
|
||||
|
||||
EXPECT_EQ(2, m.imports().size());
|
||||
EXPECT_EQ(2u, m.imports().size());
|
||||
EXPECT_EQ("std::glsl", m.imports()[0]->name());
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ TEST_F(ModuleTest, LookupImport) {
|
|||
m.AddImport(std::move(i));
|
||||
m.AddImport(std::make_unique<Import>("OpenCL.debug.100", "std::debug"));
|
||||
|
||||
auto import = m.FindImportByName("std::glsl");
|
||||
auto* import = m.FindImportByName("std::glsl");
|
||||
ASSERT_NE(nullptr, import);
|
||||
EXPECT_EQ(import->path(), "GLSL.std.430");
|
||||
EXPECT_EQ(import->name(), "std::glsl");
|
||||
|
|
|
@ -26,14 +26,14 @@ using NopStatementTest = testing::Test;
|
|||
|
||||
TEST_F(NopStatementTest, Creation) {
|
||||
NopStatement n;
|
||||
EXPECT_EQ(n.line(), 0);
|
||||
EXPECT_EQ(n.column(), 0);
|
||||
EXPECT_EQ(n.line(), 0u);
|
||||
EXPECT_EQ(n.column(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(NopStatementTest, Creation_WithSource) {
|
||||
NopStatement n(Source{20, 2});
|
||||
EXPECT_EQ(n.line(), 20);
|
||||
EXPECT_EQ(n.column(), 2);
|
||||
EXPECT_EQ(n.line(), 20u);
|
||||
EXPECT_EQ(n.column(), 2u);
|
||||
}
|
||||
|
||||
TEST_F(NopStatementTest, IsNop) {
|
||||
|
|
|
@ -27,7 +27,7 @@ using ReturnStatementTest = testing::Test;
|
|||
|
||||
TEST_F(ReturnStatementTest, Creation) {
|
||||
auto expr = std::make_unique<IdentifierExpression>("expr");
|
||||
auto expr_ptr = expr.get();
|
||||
auto* expr_ptr = expr.get();
|
||||
|
||||
ReturnStatement r(std::move(expr));
|
||||
EXPECT_EQ(r.value(), expr_ptr);
|
||||
|
@ -36,8 +36,8 @@ TEST_F(ReturnStatementTest, Creation) {
|
|||
TEST_F(ReturnStatementTest, Creation_WithSource) {
|
||||
ReturnStatement r(Source{20, 2});
|
||||
auto src = r.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(ReturnStatementTest, IsReturn) {
|
||||
|
|
|
@ -27,7 +27,7 @@ using ScalarConstructorExpressionTest = testing::Test;
|
|||
TEST_F(ScalarConstructorExpressionTest, Creation) {
|
||||
ast::type::BoolType bool_type;
|
||||
auto b = std::make_unique<BoolLiteral>(&bool_type, true);
|
||||
auto b_ptr = b.get();
|
||||
auto* b_ptr = b.get();
|
||||
ScalarConstructorExpression c(std::move(b));
|
||||
EXPECT_EQ(c.literal(), b_ptr);
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ TEST_F(ScalarConstructorExpressionTest, Creation_WithSource) {
|
|||
auto b = std::make_unique<BoolLiteral>(&bool_type, true);
|
||||
ScalarConstructorExpression c(Source{20, 2}, std::move(b));
|
||||
auto src = c.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(ScalarConstructorExpressionTest, IsValid) {
|
||||
|
|
|
@ -24,7 +24,7 @@ using SetDecorationTest = testing::Test;
|
|||
|
||||
TEST_F(SetDecorationTest, Creation) {
|
||||
SetDecoration d{2};
|
||||
EXPECT_EQ(2, d.value());
|
||||
EXPECT_EQ(2u, d.value());
|
||||
}
|
||||
|
||||
TEST_F(SetDecorationTest, Is) {
|
||||
|
|
|
@ -24,7 +24,7 @@ using StructMemberOffsetDecorationTest = testing::Test;
|
|||
|
||||
TEST_F(StructMemberOffsetDecorationTest, Creation) {
|
||||
StructMemberOffsetDecoration d{2};
|
||||
EXPECT_EQ(2, d.offset());
|
||||
EXPECT_EQ(2u, d.offset());
|
||||
}
|
||||
|
||||
TEST_F(StructMemberOffsetDecorationTest, Is) {
|
||||
|
|
|
@ -35,10 +35,10 @@ TEST_F(StructMemberTest, Creation) {
|
|||
StructMember st{"a", &i32, std::move(decorations)};
|
||||
EXPECT_EQ(st.name(), "a");
|
||||
EXPECT_EQ(st.type(), &i32);
|
||||
EXPECT_EQ(st.decorations().size(), 1);
|
||||
EXPECT_EQ(st.decorations().size(), 1u);
|
||||
EXPECT_TRUE(st.decorations()[0]->IsOffset());
|
||||
EXPECT_EQ(st.line(), 0);
|
||||
EXPECT_EQ(st.column(), 0);
|
||||
EXPECT_EQ(st.line(), 0u);
|
||||
EXPECT_EQ(st.column(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(StructMemberTest, CreationWithSource) {
|
||||
|
@ -48,9 +48,9 @@ TEST_F(StructMemberTest, CreationWithSource) {
|
|||
StructMember st{s, "a", &i32, {}};
|
||||
EXPECT_EQ(st.name(), "a");
|
||||
EXPECT_EQ(st.type(), &i32);
|
||||
EXPECT_EQ(st.decorations().size(), 0);
|
||||
EXPECT_EQ(st.line(), 27);
|
||||
EXPECT_EQ(st.column(), 4);
|
||||
EXPECT_EQ(st.decorations().size(), 0u);
|
||||
EXPECT_EQ(st.line(), 27u);
|
||||
EXPECT_EQ(st.column(), 4u);
|
||||
}
|
||||
|
||||
TEST_F(StructMemberTest, IsValid) {
|
||||
|
|
|
@ -36,10 +36,10 @@ TEST_F(StructTest, Creation) {
|
|||
std::make_unique<StructMember>("a", &i32, StructMemberDecorationList()));
|
||||
|
||||
Struct s{StructDecoration::kNone, std::move(members)};
|
||||
EXPECT_EQ(s.members().size(), 1);
|
||||
EXPECT_EQ(s.members().size(), 1u);
|
||||
EXPECT_EQ(s.decoration(), StructDecoration::kNone);
|
||||
EXPECT_EQ(s.line(), 0);
|
||||
EXPECT_EQ(s.column(), 0);
|
||||
EXPECT_EQ(s.line(), 0u);
|
||||
EXPECT_EQ(s.column(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(StructTest, CreationWithSource) {
|
||||
|
@ -50,10 +50,10 @@ TEST_F(StructTest, CreationWithSource) {
|
|||
std::make_unique<StructMember>("a", &i32, StructMemberDecorationList()));
|
||||
|
||||
Struct s{source, StructDecoration::kNone, std::move(members)};
|
||||
EXPECT_EQ(s.members().size(), 1);
|
||||
EXPECT_EQ(s.members().size(), 1u);
|
||||
EXPECT_EQ(s.decoration(), StructDecoration::kNone);
|
||||
EXPECT_EQ(s.line(), 27);
|
||||
EXPECT_EQ(s.column(), 4);
|
||||
EXPECT_EQ(s.line(), 27u);
|
||||
EXPECT_EQ(s.column(), 4u);
|
||||
}
|
||||
|
||||
TEST_F(StructTest, IsValid) {
|
||||
|
|
|
@ -36,12 +36,12 @@ TEST_F(SwitchStatementTest, Creation) {
|
|||
body.push_back(
|
||||
std::make_unique<CaseStatement>(std::move(lit), StatementList()));
|
||||
|
||||
auto ident_ptr = ident.get();
|
||||
auto case_ptr = body[0].get();
|
||||
auto* ident_ptr = ident.get();
|
||||
auto* case_ptr = body[0].get();
|
||||
|
||||
SwitchStatement stmt(std::move(ident), std::move(body));
|
||||
EXPECT_EQ(stmt.condition(), ident_ptr);
|
||||
ASSERT_EQ(stmt.body().size(), 1);
|
||||
ASSERT_EQ(stmt.body().size(), 1u);
|
||||
EXPECT_EQ(stmt.body()[0].get(), case_ptr);
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,8 @@ TEST_F(SwitchStatementTest, Creation_WithSource) {
|
|||
|
||||
SwitchStatement stmt(Source{20, 2}, std::move(ident), CaseStatementList());
|
||||
auto src = stmt.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(SwitchStatementTest, IsSwitch) {
|
||||
|
|
|
@ -29,7 +29,7 @@ TEST_F(ArrayTypeTest, CreateSizedArray) {
|
|||
U32Type u32;
|
||||
ArrayType arr{&u32, 3};
|
||||
EXPECT_EQ(arr.type(), &u32);
|
||||
EXPECT_EQ(arr.size(), 3);
|
||||
EXPECT_EQ(arr.size(), 3u);
|
||||
EXPECT_TRUE(arr.IsArray());
|
||||
EXPECT_FALSE(arr.IsRuntimeArray());
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ TEST_F(ArrayTypeTest, CreateRuntimeArray) {
|
|||
U32Type u32;
|
||||
ArrayType arr{&u32};
|
||||
EXPECT_EQ(arr.type(), &u32);
|
||||
EXPECT_EQ(arr.size(), 0);
|
||||
EXPECT_EQ(arr.size(), 0u);
|
||||
EXPECT_TRUE(arr.IsArray());
|
||||
EXPECT_TRUE(arr.IsRuntimeArray());
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@ TEST_F(MatrixTypeTest, Creation) {
|
|||
I32Type i32;
|
||||
MatrixType m{&i32, 2, 4};
|
||||
EXPECT_EQ(m.type(), &i32);
|
||||
EXPECT_EQ(m.rows(), 2);
|
||||
EXPECT_EQ(m.columns(), 4);
|
||||
EXPECT_EQ(m.rows(), 2u);
|
||||
EXPECT_EQ(m.columns(), 4u);
|
||||
}
|
||||
|
||||
TEST_F(MatrixTypeTest, Is) {
|
||||
|
|
|
@ -28,7 +28,7 @@ using StructTypeTest = testing::Test;
|
|||
|
||||
TEST_F(StructTypeTest, Creation) {
|
||||
auto impl = std::make_unique<Struct>();
|
||||
auto ptr = impl.get();
|
||||
auto* ptr = impl.get();
|
||||
StructType s{std::move(impl)};
|
||||
EXPECT_EQ(s.impl(), ptr);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ TEST_F(VectorTypeTest, Creation) {
|
|||
I32Type i32;
|
||||
VectorType v{&i32, 2};
|
||||
EXPECT_EQ(v.type(), &i32);
|
||||
EXPECT_EQ(v.size(), 2);
|
||||
EXPECT_EQ(v.size(), 2u);
|
||||
}
|
||||
|
||||
TEST_F(VectorTypeTest, Is) {
|
||||
|
|
|
@ -33,11 +33,11 @@ TEST_F(TypeConstructorExpressionTest, Creation) {
|
|||
type::F32Type f32;
|
||||
ExpressionList expr;
|
||||
expr.push_back(std::make_unique<IdentifierExpression>("expr"));
|
||||
auto expr_ptr = expr[0].get();
|
||||
auto* expr_ptr = expr[0].get();
|
||||
|
||||
TypeConstructorExpression t(&f32, std::move(expr));
|
||||
EXPECT_EQ(t.type(), &f32);
|
||||
ASSERT_EQ(t.values().size(), 1);
|
||||
ASSERT_EQ(t.values().size(), 1u);
|
||||
EXPECT_EQ(t.values()[0].get(), expr_ptr);
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,8 @@ TEST_F(TypeConstructorExpressionTest, Creation_WithSource) {
|
|||
|
||||
TypeConstructorExpression t(Source{20, 2}, &f32, std::move(expr));
|
||||
auto src = t.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(TypeConstructorExpressionTest, IsTypeConstructor) {
|
||||
|
|
|
@ -27,7 +27,7 @@ TEST_F(UintLiteralTest, Value) {
|
|||
ast::type::U32Type u32;
|
||||
UintLiteral u{&u32, 47};
|
||||
ASSERT_TRUE(u.IsUint());
|
||||
EXPECT_EQ(u.value(), 47);
|
||||
EXPECT_EQ(u.value(), 47u);
|
||||
}
|
||||
|
||||
TEST_F(UintLiteralTest, Is) {
|
||||
|
|
|
@ -27,7 +27,7 @@ using UnaryDerivativeExpressionTest = testing::Test;
|
|||
|
||||
TEST_F(UnaryDerivativeExpressionTest, Creation) {
|
||||
auto ident = std::make_unique<IdentifierExpression>("ident");
|
||||
auto ident_ptr = ident.get();
|
||||
auto* ident_ptr = ident.get();
|
||||
|
||||
UnaryDerivativeExpression d(UnaryDerivative::kDpdy,
|
||||
DerivativeModifier::kCoarse, std::move(ident));
|
||||
|
@ -42,8 +42,8 @@ TEST_F(UnaryDerivativeExpressionTest, Creation_WithSource) {
|
|||
UnaryDerivativeExpression d(Source{20, 2}, UnaryDerivative::kDpdy,
|
||||
DerivativeModifier::kCoarse, std::move(ident));
|
||||
auto src = d.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(UnaryDerivativeExpressionTest, IsUnaryDerivative) {
|
||||
|
|
|
@ -30,11 +30,11 @@ TEST_F(UnaryMethodExpressionTest, Creation) {
|
|||
ExpressionList params;
|
||||
params.push_back(std::make_unique<IdentifierExpression>("ident"));
|
||||
|
||||
auto ident_ptr = params[0].get();
|
||||
auto* ident_ptr = params[0].get();
|
||||
|
||||
UnaryMethodExpression u(UnaryMethod::kAll, std::move(params));
|
||||
EXPECT_EQ(u.op(), UnaryMethod::kAll);
|
||||
ASSERT_EQ(u.params().size(), 1);
|
||||
ASSERT_EQ(u.params().size(), 1u);
|
||||
EXPECT_EQ(u.params()[0].get(), ident_ptr);
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,8 @@ TEST_F(UnaryMethodExpressionTest, Creation_WithSource) {
|
|||
|
||||
UnaryMethodExpression u(Source{20, 2}, UnaryMethod::kAll, std::move(params));
|
||||
auto src = u.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(UnaryMethodExpressionTest, IsUnaryMethod) {
|
||||
|
|
|
@ -27,7 +27,7 @@ using UnaryOpExpressionTest = testing::Test;
|
|||
|
||||
TEST_F(UnaryOpExpressionTest, Creation) {
|
||||
auto ident = std::make_unique<IdentifierExpression>("ident");
|
||||
auto ident_ptr = ident.get();
|
||||
auto* ident_ptr = ident.get();
|
||||
|
||||
UnaryOpExpression u(UnaryOp::kNot, std::move(ident));
|
||||
EXPECT_EQ(u.op(), UnaryOp::kNot);
|
||||
|
@ -38,8 +38,8 @@ TEST_F(UnaryOpExpressionTest, Creation_WithSource) {
|
|||
auto ident = std::make_unique<IdentifierExpression>("ident");
|
||||
UnaryOpExpression u(Source{20, 2}, UnaryOp::kNot, std::move(ident));
|
||||
auto src = u.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(UnaryOpExpressionTest, IsUnaryOp) {
|
||||
|
|
|
@ -30,12 +30,12 @@ TEST_F(UnlessStatementTest, Creation) {
|
|||
StatementList body;
|
||||
body.push_back(std::make_unique<NopStatement>());
|
||||
|
||||
auto ident_ptr = ident.get();
|
||||
auto nop_ptr = body[0].get();
|
||||
auto* ident_ptr = ident.get();
|
||||
auto* nop_ptr = body[0].get();
|
||||
|
||||
UnlessStatement u(std::move(ident), std::move(body));
|
||||
EXPECT_EQ(u.condition(), ident_ptr);
|
||||
ASSERT_EQ(u.body().size(), 1);
|
||||
ASSERT_EQ(u.body().size(), 1u);
|
||||
EXPECT_EQ(u.body()[0].get(), nop_ptr);
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,8 @@ TEST_F(UnlessStatementTest, Creation_WithSource) {
|
|||
|
||||
UnlessStatement u(Source{20, 2}, std::move(ident), std::move(body));
|
||||
auto src = u.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(UnlessStatementTest, IsUnless) {
|
||||
|
|
|
@ -27,7 +27,7 @@ using VariableDeclStatementTest = testing::Test;
|
|||
TEST_F(VariableDeclStatementTest, Creation) {
|
||||
type::F32Type f32;
|
||||
auto var = std::make_unique<Variable>("a", StorageClass::kNone, &f32);
|
||||
auto var_ptr = var.get();
|
||||
auto* var_ptr = var.get();
|
||||
|
||||
VariableDeclStatement stmt(std::move(var));
|
||||
EXPECT_EQ(stmt.variable(), var_ptr);
|
||||
|
@ -39,8 +39,8 @@ TEST_F(VariableDeclStatementTest, Creation_WithSource) {
|
|||
|
||||
VariableDeclStatement stmt(Source{20, 2}, std::move(var));
|
||||
auto src = stmt.source();
|
||||
EXPECT_EQ(src.line, 20);
|
||||
EXPECT_EQ(src.column, 2);
|
||||
EXPECT_EQ(src.line, 20u);
|
||||
EXPECT_EQ(src.column, 2u);
|
||||
}
|
||||
|
||||
TEST_F(VariableDeclStatementTest, IsVariableDecl) {
|
||||
|
|
|
@ -32,8 +32,8 @@ TEST_F(VariableTest, Creation) {
|
|||
EXPECT_EQ(v.name(), "my_var");
|
||||
EXPECT_EQ(v.storage_class(), StorageClass::kFunction);
|
||||
EXPECT_EQ(v.type(), &t);
|
||||
EXPECT_EQ(v.line(), 0);
|
||||
EXPECT_EQ(v.column(), 0);
|
||||
EXPECT_EQ(v.line(), 0u);
|
||||
EXPECT_EQ(v.column(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, CreationWithSource) {
|
||||
|
@ -44,8 +44,8 @@ TEST_F(VariableTest, CreationWithSource) {
|
|||
EXPECT_EQ(v.name(), "i");
|
||||
EXPECT_EQ(v.storage_class(), StorageClass::kPrivate);
|
||||
EXPECT_EQ(v.type(), &t);
|
||||
EXPECT_EQ(v.line(), 27);
|
||||
EXPECT_EQ(v.column(), 4);
|
||||
EXPECT_EQ(v.line(), 27u);
|
||||
EXPECT_EQ(v.column(), 4u);
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, CreationEmpty) {
|
||||
|
@ -61,8 +61,8 @@ TEST_F(VariableTest, CreationEmpty) {
|
|||
EXPECT_EQ(v.name(), "a_var");
|
||||
EXPECT_EQ(v.storage_class(), StorageClass::kWorkgroup);
|
||||
EXPECT_EQ(v.type(), &t);
|
||||
EXPECT_EQ(v.line(), 27);
|
||||
EXPECT_EQ(v.column(), 4);
|
||||
EXPECT_EQ(v.line(), 27u);
|
||||
EXPECT_EQ(v.column(), 4u);
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid) {
|
||||
|
|
|
@ -137,7 +137,7 @@ TEST_P(SpvBinaryTest, EmitExpression) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< p->error() << "\n"
|
||||
<< assembly;
|
||||
|
|
|
@ -50,7 +50,7 @@ std::string CommonTypes() {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionDeclaration_VoidFunctionWithoutParams) {
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%100 = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
OpReturn
|
||||
|
@ -67,7 +67,7 @@ TEST_F(SpvParserTest, EmitFunctionDeclaration_VoidFunctionWithoutParams) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionDeclaration_NonVoidResultType) {
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%fn_ret_float = OpTypeFunction %float
|
||||
%100 = OpFunction %float None %fn_ret_float
|
||||
%entry = OpLabel
|
||||
|
@ -86,7 +86,7 @@ TEST_F(SpvParserTest, EmitFunctionDeclaration_NonVoidResultType) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionDeclaration_MixedParamTypes) {
|
||||
auto p = parser(test::Assemble(Names({"a", "b", "c"}) + CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(Names({"a", "b", "c"}) + CommonTypes() + R"(
|
||||
%fn_mixed_params = OpTypeFunction %float %uint %float %int
|
||||
|
||||
%100 = OpFunction %void None %fn_mixed_params
|
||||
|
@ -125,7 +125,7 @@ TEST_F(SpvParserTest, EmitFunctionDeclaration_MixedParamTypes) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionDeclaration_GenerateParamNames) {
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%fn_mixed_params = OpTypeFunction %float %uint %float %int
|
||||
|
||||
%100 = OpFunction %void None %fn_mixed_params
|
||||
|
|
|
@ -159,7 +159,7 @@ TEST_P(SpvBinaryLogicalTest, EmitExpression) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto p = parser(test::Assemble(assembly));
|
||||
auto* p = parser(test::Assemble(assembly));
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions())
|
||||
<< p->error() << "\n"
|
||||
<< assembly;
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace {
|
|||
using ::testing::HasSubstr;
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_StoreBoolConst) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeBool
|
||||
|
@ -64,7 +64,7 @@ Assignment{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_StoreUintConst) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeInt 32 0
|
||||
|
@ -92,7 +92,7 @@ Assignment{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_StoreIntConst) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeInt 32 1
|
||||
|
@ -120,7 +120,7 @@ Assignment{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_StoreFloatConst) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeFloat 32
|
||||
|
@ -148,7 +148,7 @@ Assignment{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_LoadBool) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeBool
|
||||
|
@ -178,7 +178,7 @@ TEST_F(SpvParserTest, EmitStatement_LoadBool) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_LoadScalar) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeInt 32 0
|
||||
|
@ -218,7 +218,7 @@ VariableDeclStatement{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_UseLoadedScalarTwice) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeInt 32 0
|
||||
|
@ -258,7 +258,7 @@ Assignment{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitStatement_StoreToModuleScopeVar) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeInt 32 0
|
||||
|
|
|
@ -70,7 +70,7 @@ std::string CommonTypes() {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_AnonymousVars) {
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%100 = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
%1 = OpVariable %ptr_uint Function
|
||||
|
@ -108,7 +108,7 @@ VariableDeclStatement{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_NamedVars) {
|
||||
auto p = parser(test::Assemble(Names({"a", "b", "c"}) + CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(Names({"a", "b", "c"}) + CommonTypes() + R"(
|
||||
%100 = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
%a = OpVariable %ptr_uint Function
|
||||
|
@ -146,7 +146,7 @@ VariableDeclStatement{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_MixedTypes) {
|
||||
auto p = parser(test::Assemble(Names({"a", "b", "c"}) + CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(Names({"a", "b", "c"}) + CommonTypes() + R"(
|
||||
%100 = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
%a = OpVariable %ptr_uint Function
|
||||
|
@ -184,7 +184,7 @@ VariableDeclStatement{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_ScalarInitializers) {
|
||||
auto p = parser(
|
||||
auto* p = parser(
|
||||
test::Assemble(Names({"a", "b", "c", "d", "e"}) + CommonTypes() + R"(
|
||||
%100 = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
|
@ -254,7 +254,7 @@ VariableDeclStatement{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_ScalarNullInitializers) {
|
||||
auto p =
|
||||
auto* p =
|
||||
parser(test::Assemble(Names({"a", "b", "c", "d"}) + CommonTypes() + R"(
|
||||
%null_bool = OpConstantNull %bool
|
||||
%null_int = OpConstantNull %int
|
||||
|
@ -318,7 +318,7 @@ VariableDeclStatement{
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_VectorInitializer) {
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Function %v2float
|
||||
%two = OpConstant %float 2.0
|
||||
%const = OpConstantComposite %v2float %float_1p5 %two
|
||||
|
@ -351,7 +351,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_VectorInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_MatrixInitializer) {
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Function %m3v2float
|
||||
%two = OpConstant %float 2.0
|
||||
%three = OpConstant %float 3.0
|
||||
|
@ -402,7 +402,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_MatrixInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer) {
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Function %arr2uint
|
||||
%two = OpConstant %uint 2
|
||||
%const = OpConstantComposite %arr2uint %uint_1 %two
|
||||
|
@ -435,7 +435,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) {
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Function %strct
|
||||
%two = OpConstant %uint 2
|
||||
%arrconst = OpConstantComposite %arr2uint %uint_1 %two
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace {
|
|||
using ::testing::Eq;
|
||||
|
||||
TEST_F(SpvParserTest, ConvertMemberDecoration_Empty) {
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
auto* p = parser(std::vector<uint32_t>{});
|
||||
|
||||
auto result = p->ConvertMemberDecoration({});
|
||||
EXPECT_EQ(result.get(), nullptr);
|
||||
|
@ -40,7 +40,7 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_Empty) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertMemberDecoration_OffsetWithoutOperand) {
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
auto* p = parser(std::vector<uint32_t>{});
|
||||
|
||||
auto result = p->ConvertMemberDecoration({SpvDecorationOffset});
|
||||
EXPECT_EQ(result.get(), nullptr);
|
||||
|
@ -50,7 +50,7 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_OffsetWithoutOperand) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertMemberDecoration_OffsetWithTooManyOperands) {
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
auto* p = parser(std::vector<uint32_t>{});
|
||||
|
||||
auto result = p->ConvertMemberDecoration({SpvDecorationOffset, 3, 4});
|
||||
EXPECT_EQ(result.get(), nullptr);
|
||||
|
@ -60,19 +60,19 @@ TEST_F(SpvParserTest, ConvertMemberDecoration_OffsetWithTooManyOperands) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertMemberDecoration_Offset) {
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
auto* p = parser(std::vector<uint32_t>{});
|
||||
|
||||
auto result = p->ConvertMemberDecoration({SpvDecorationOffset, 8});
|
||||
ASSERT_NE(result.get(), nullptr);
|
||||
EXPECT_TRUE(result->IsOffset());
|
||||
auto* offset_deco = result->AsOffset();
|
||||
ASSERT_NE(offset_deco, nullptr);
|
||||
EXPECT_EQ(offset_deco->offset(), 8);
|
||||
EXPECT_EQ(offset_deco->offset(), 8u);
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertMemberDecoration_UnhandledDecoration) {
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
auto* p = parser(std::vector<uint32_t>{});
|
||||
|
||||
auto result = p->ConvertMemberDecoration({12345678});
|
||||
EXPECT_EQ(result.get(), nullptr);
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace {
|
|||
using ::testing::Eq;
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PreservesExistingFailure) {
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
auto* p = parser(std::vector<uint32_t>{});
|
||||
p->Fail() << "boing";
|
||||
auto* type = p->ConvertType(10);
|
||||
EXPECT_EQ(type, nullptr);
|
||||
|
@ -45,7 +45,7 @@ TEST_F(SpvParserTest, ConvertType_PreservesExistingFailure) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_RequiresInternalRepresntation) {
|
||||
auto p = parser(std::vector<uint32_t>{});
|
||||
auto* p = parser(std::vector<uint32_t>{});
|
||||
auto* type = p->ConvertType(10);
|
||||
EXPECT_EQ(type, nullptr);
|
||||
EXPECT_THAT(
|
||||
|
@ -54,7 +54,7 @@ TEST_F(SpvParserTest, ConvertType_RequiresInternalRepresntation) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_NotAnId) {
|
||||
auto p = parser(test::Assemble("%1 = OpExtInstImport \"GLSL.std.450\""));
|
||||
auto* p = parser(test::Assemble("%1 = OpExtInstImport \"GLSL.std.450\""));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(10);
|
||||
|
@ -64,7 +64,7 @@ TEST_F(SpvParserTest, ConvertType_NotAnId) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_IdExistsButIsNotAType) {
|
||||
auto p = parser(test::Assemble("%1 = OpExtInstImport \"GLSL.std.450\""));
|
||||
auto* p = parser(test::Assemble("%1 = OpExtInstImport \"GLSL.std.450\""));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(1);
|
||||
|
@ -74,7 +74,7 @@ TEST_F(SpvParserTest, ConvertType_IdExistsButIsNotAType) {
|
|||
|
||||
TEST_F(SpvParserTest, ConvertType_UnhandledType) {
|
||||
// Pipes are an OpenCL type. Tint doesn't support them.
|
||||
auto p = parser(test::Assemble("%70 = OpTypePipe WriteOnly"));
|
||||
auto* p = parser(test::Assemble("%70 = OpTypePipe WriteOnly"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(70);
|
||||
|
@ -83,7 +83,7 @@ TEST_F(SpvParserTest, ConvertType_UnhandledType) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_Void) {
|
||||
auto p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
auto* p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(1);
|
||||
|
@ -92,7 +92,7 @@ TEST_F(SpvParserTest, ConvertType_Void) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_Bool) {
|
||||
auto p = parser(test::Assemble("%100 = OpTypeBool"));
|
||||
auto* p = parser(test::Assemble("%100 = OpTypeBool"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(100);
|
||||
|
@ -101,7 +101,7 @@ TEST_F(SpvParserTest, ConvertType_Bool) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_I32) {
|
||||
auto p = parser(test::Assemble("%2 = OpTypeInt 32 1"));
|
||||
auto* p = parser(test::Assemble("%2 = OpTypeInt 32 1"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(2);
|
||||
|
@ -110,7 +110,7 @@ TEST_F(SpvParserTest, ConvertType_I32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_U32) {
|
||||
auto p = parser(test::Assemble("%3 = OpTypeInt 32 0"));
|
||||
auto* p = parser(test::Assemble("%3 = OpTypeInt 32 0"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(3);
|
||||
|
@ -119,7 +119,7 @@ TEST_F(SpvParserTest, ConvertType_U32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_F32) {
|
||||
auto p = parser(test::Assemble("%4 = OpTypeFloat 32"));
|
||||
auto* p = parser(test::Assemble("%4 = OpTypeFloat 32"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(4);
|
||||
|
@ -128,7 +128,7 @@ TEST_F(SpvParserTest, ConvertType_F32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_BadIntWidth) {
|
||||
auto p = parser(test::Assemble("%5 = OpTypeInt 17 1"));
|
||||
auto* p = parser(test::Assemble("%5 = OpTypeInt 17 1"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(5);
|
||||
|
@ -137,7 +137,7 @@ TEST_F(SpvParserTest, ConvertType_BadIntWidth) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_BadFloatWidth) {
|
||||
auto p = parser(test::Assemble("%6 = OpTypeFloat 19"));
|
||||
auto* p = parser(test::Assemble("%6 = OpTypeFloat 19"));
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(6);
|
||||
|
@ -146,7 +146,7 @@ TEST_F(SpvParserTest, ConvertType_BadFloatWidth) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidVectorElement) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%5 = OpTypePipe ReadOnly
|
||||
%20 = OpTypeVector %5 2
|
||||
)"));
|
||||
|
@ -158,7 +158,7 @@ TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidVectorElement) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_VecOverF32) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%20 = OpTypeVector %float 2
|
||||
%30 = OpTypeVector %float 3
|
||||
|
@ -185,7 +185,7 @@ TEST_F(SpvParserTest, ConvertType_VecOverF32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_VecOverI32) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%int = OpTypeInt 32 1
|
||||
%20 = OpTypeVector %int 2
|
||||
%30 = OpTypeVector %int 3
|
||||
|
@ -212,7 +212,7 @@ TEST_F(SpvParserTest, ConvertType_VecOverI32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_VecOverU32) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%20 = OpTypeVector %uint 2
|
||||
%30 = OpTypeVector %uint 3
|
||||
|
@ -239,7 +239,7 @@ TEST_F(SpvParserTest, ConvertType_VecOverU32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidMatrixElement) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%5 = OpTypePipe ReadOnly
|
||||
%10 = OpTypeVector %5 2
|
||||
%20 = OpTypeMatrix %10 2
|
||||
|
@ -253,7 +253,7 @@ TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidMatrixElement) {
|
|||
|
||||
TEST_F(SpvParserTest, ConvertType_MatrixOverF32) {
|
||||
// Matrices are only defined over floats.
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%v2 = OpTypeVector %float 2
|
||||
%v3 = OpTypeVector %float 3
|
||||
|
@ -275,62 +275,62 @@ TEST_F(SpvParserTest, ConvertType_MatrixOverF32) {
|
|||
auto* m22 = p->ConvertType(22);
|
||||
EXPECT_TRUE(m22->IsMatrix());
|
||||
EXPECT_TRUE(m22->AsMatrix()->type()->IsF32());
|
||||
EXPECT_EQ(m22->AsMatrix()->rows(), 2);
|
||||
EXPECT_EQ(m22->AsMatrix()->columns(), 2);
|
||||
EXPECT_EQ(m22->AsMatrix()->rows(), 2u);
|
||||
EXPECT_EQ(m22->AsMatrix()->columns(), 2u);
|
||||
|
||||
auto* m23 = p->ConvertType(23);
|
||||
EXPECT_TRUE(m23->IsMatrix());
|
||||
EXPECT_TRUE(m23->AsMatrix()->type()->IsF32());
|
||||
EXPECT_EQ(m23->AsMatrix()->rows(), 2);
|
||||
EXPECT_EQ(m23->AsMatrix()->columns(), 3);
|
||||
EXPECT_EQ(m23->AsMatrix()->rows(), 2u);
|
||||
EXPECT_EQ(m23->AsMatrix()->columns(), 3u);
|
||||
|
||||
auto* m24 = p->ConvertType(24);
|
||||
EXPECT_TRUE(m24->IsMatrix());
|
||||
EXPECT_TRUE(m24->AsMatrix()->type()->IsF32());
|
||||
EXPECT_EQ(m24->AsMatrix()->rows(), 2);
|
||||
EXPECT_EQ(m24->AsMatrix()->columns(), 4);
|
||||
EXPECT_EQ(m24->AsMatrix()->rows(), 2u);
|
||||
EXPECT_EQ(m24->AsMatrix()->columns(), 4u);
|
||||
|
||||
auto* m32 = p->ConvertType(32);
|
||||
EXPECT_TRUE(m32->IsMatrix());
|
||||
EXPECT_TRUE(m32->AsMatrix()->type()->IsF32());
|
||||
EXPECT_EQ(m32->AsMatrix()->rows(), 3);
|
||||
EXPECT_EQ(m32->AsMatrix()->columns(), 2);
|
||||
EXPECT_EQ(m32->AsMatrix()->rows(), 3u);
|
||||
EXPECT_EQ(m32->AsMatrix()->columns(), 2u);
|
||||
|
||||
auto* m33 = p->ConvertType(33);
|
||||
EXPECT_TRUE(m33->IsMatrix());
|
||||
EXPECT_TRUE(m33->AsMatrix()->type()->IsF32());
|
||||
EXPECT_EQ(m33->AsMatrix()->rows(), 3);
|
||||
EXPECT_EQ(m33->AsMatrix()->columns(), 3);
|
||||
EXPECT_EQ(m33->AsMatrix()->rows(), 3u);
|
||||
EXPECT_EQ(m33->AsMatrix()->columns(), 3u);
|
||||
|
||||
auto* m34 = p->ConvertType(34);
|
||||
EXPECT_TRUE(m34->IsMatrix());
|
||||
EXPECT_TRUE(m34->AsMatrix()->type()->IsF32());
|
||||
EXPECT_EQ(m34->AsMatrix()->rows(), 3);
|
||||
EXPECT_EQ(m34->AsMatrix()->columns(), 4);
|
||||
EXPECT_EQ(m34->AsMatrix()->rows(), 3u);
|
||||
EXPECT_EQ(m34->AsMatrix()->columns(), 4u);
|
||||
|
||||
auto* m42 = p->ConvertType(42);
|
||||
EXPECT_TRUE(m42->IsMatrix());
|
||||
EXPECT_TRUE(m42->AsMatrix()->type()->IsF32());
|
||||
EXPECT_EQ(m42->AsMatrix()->rows(), 4);
|
||||
EXPECT_EQ(m42->AsMatrix()->columns(), 2);
|
||||
EXPECT_EQ(m42->AsMatrix()->rows(), 4u);
|
||||
EXPECT_EQ(m42->AsMatrix()->columns(), 2u);
|
||||
|
||||
auto* m43 = p->ConvertType(43);
|
||||
EXPECT_TRUE(m43->IsMatrix());
|
||||
EXPECT_TRUE(m43->AsMatrix()->type()->IsF32());
|
||||
EXPECT_EQ(m43->AsMatrix()->rows(), 4);
|
||||
EXPECT_EQ(m43->AsMatrix()->columns(), 3);
|
||||
EXPECT_EQ(m43->AsMatrix()->rows(), 4u);
|
||||
EXPECT_EQ(m43->AsMatrix()->columns(), 3u);
|
||||
|
||||
auto* m44 = p->ConvertType(44);
|
||||
EXPECT_TRUE(m44->IsMatrix());
|
||||
EXPECT_TRUE(m44->AsMatrix()->type()->IsF32());
|
||||
EXPECT_EQ(m44->AsMatrix()->rows(), 4);
|
||||
EXPECT_EQ(m44->AsMatrix()->columns(), 4);
|
||||
EXPECT_EQ(m44->AsMatrix()->rows(), 4u);
|
||||
EXPECT_EQ(m44->AsMatrix()->columns(), 4u);
|
||||
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_RuntimeArray) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%10 = OpTypeRuntimeArray %uint
|
||||
)"));
|
||||
|
@ -350,7 +350,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_Array) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_42 = OpConstant %uint 42
|
||||
%10 = OpTypeArray %uint %uint_42
|
||||
|
@ -371,7 +371,7 @@ TEST_F(SpvParserTest, ConvertType_Array) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_ArrayBadLengthIsSpecConstantValue) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpDecorate %uint_42 SpecId 12
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_42 = OpSpecConstant %uint 42
|
||||
|
@ -386,7 +386,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayBadLengthIsSpecConstantValue) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_ArrayBadLengthIsSpecConstantExpr) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_42 = OpConstant %uint 42
|
||||
%sum = OpSpecConstantOp %uint IAdd %uint_42 %uint_42
|
||||
|
@ -405,7 +405,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayBadLengthIsSpecConstantExpr) {
|
|||
// optimizer representation doesn't handle it and asserts out instead.
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_ArrayBadTooBig) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%uint64 = OpTypeInt 64 0
|
||||
%uint64_big = OpConstant %uint64 5000000000
|
||||
%10 = OpTypeArray %uint64 %uint64_big
|
||||
|
@ -420,7 +420,7 @@ TEST_F(SpvParserTest, ConvertType_ArrayBadTooBig) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_StructTwoMembers) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%float = OpTypeFloat 32
|
||||
%10 = OpTypeStruct %uint %float
|
||||
|
@ -441,7 +441,7 @@ TEST_F(SpvParserTest, ConvertType_StructTwoMembers) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_StructWithBlockDecoration) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpDecorate %10 Block
|
||||
%uint = OpTypeInt 32 0
|
||||
%10 = OpTypeStruct %uint
|
||||
|
@ -461,7 +461,7 @@ TEST_F(SpvParserTest, ConvertType_StructWithBlockDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_StructWithMemberDecorations) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpMemberDecorate %10 0 Offset 0
|
||||
OpMemberDecorate %10 1 Offset 8
|
||||
OpMemberDecorate %10 2 Offset 16
|
||||
|
@ -493,7 +493,7 @@ TEST_F(SpvParserTest, ConvertType_StructWithMemberDecorations) {
|
|||
|
||||
TEST_F(SpvParserTest, ConvertType_InvalidPointeetype) {
|
||||
// Disallow pointer-to-function
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%void = OpTypeVoid
|
||||
%42 = OpTypeFunction %void
|
||||
%3 = OpTypePointer Input %42
|
||||
|
@ -508,7 +508,7 @@ TEST_F(SpvParserTest, ConvertType_InvalidPointeetype) {
|
|||
|
||||
TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidStorageClass) {
|
||||
// Disallow invalid storage class
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%1 = OpTypeFloat 32
|
||||
%3 = OpTypePointer !999 %1 ; Special syntax to inject 999 as the storage class
|
||||
)"));
|
||||
|
@ -517,7 +517,7 @@ TEST_F(SpvParserTest, DISABLED_ConvertType_InvalidStorageClass) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerInput) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer Input %float
|
||||
)"));
|
||||
|
@ -533,7 +533,7 @@ TEST_F(SpvParserTest, ConvertType_PointerInput) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerOutput) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer Output %float
|
||||
)"));
|
||||
|
@ -549,7 +549,7 @@ TEST_F(SpvParserTest, ConvertType_PointerOutput) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerUniform) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer Uniform %float
|
||||
)"));
|
||||
|
@ -565,7 +565,7 @@ TEST_F(SpvParserTest, ConvertType_PointerUniform) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerWorkgroup) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer Workgroup %float
|
||||
)"));
|
||||
|
@ -581,7 +581,7 @@ TEST_F(SpvParserTest, ConvertType_PointerWorkgroup) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerUniformConstant) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer UniformConstant %float
|
||||
)"));
|
||||
|
@ -597,7 +597,7 @@ TEST_F(SpvParserTest, ConvertType_PointerUniformConstant) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerStorageBuffer) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer StorageBuffer %float
|
||||
)"));
|
||||
|
@ -613,7 +613,7 @@ TEST_F(SpvParserTest, ConvertType_PointerStorageBuffer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerImage) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer Image %float
|
||||
)"));
|
||||
|
@ -629,7 +629,7 @@ TEST_F(SpvParserTest, ConvertType_PointerImage) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerPushConstant) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer PushConstant %float
|
||||
)"));
|
||||
|
@ -645,7 +645,7 @@ TEST_F(SpvParserTest, ConvertType_PointerPushConstant) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerPrivate) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer Private %float
|
||||
)"));
|
||||
|
@ -661,7 +661,7 @@ TEST_F(SpvParserTest, ConvertType_PointerPrivate) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerFunction) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%3 = OpTypePointer Function %float
|
||||
)"));
|
||||
|
@ -678,7 +678,7 @@ TEST_F(SpvParserTest, ConvertType_PointerFunction) {
|
|||
|
||||
TEST_F(SpvParserTest, ConvertType_PointerToPointer) {
|
||||
// FYI: The reader suports pointer-to-pointer even while WebGPU does not.
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%42 = OpTypePointer Output %float
|
||||
%3 = OpTypePointer Input %42
|
||||
|
|
|
@ -35,7 +35,7 @@ std::string MakeEntryPoint(const std::string& stage,
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EntryPoint_NoEntryPoint) {
|
||||
auto p = parser(test::Assemble(""));
|
||||
auto* p = parser(test::Assemble(""));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_ast = p->module().to_str();
|
||||
|
@ -43,7 +43,7 @@ TEST_F(SpvParserTest, EntryPoint_NoEntryPoint) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EntryPoint_Vertex) {
|
||||
auto p = parser(test::Assemble(MakeEntryPoint("Vertex", "foobar")));
|
||||
auto* p = parser(test::Assemble(MakeEntryPoint("Vertex", "foobar")));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
|
@ -51,7 +51,7 @@ TEST_F(SpvParserTest, EntryPoint_Vertex) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EntryPoint_Fragment) {
|
||||
auto p = parser(test::Assemble(MakeEntryPoint("Fragment", "blitz")));
|
||||
auto* p = parser(test::Assemble(MakeEntryPoint("Fragment", "blitz")));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
|
@ -59,7 +59,7 @@ TEST_F(SpvParserTest, EntryPoint_Fragment) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EntryPoint_Compute) {
|
||||
auto p = parser(test::Assemble(MakeEntryPoint("GLCompute", "sort")));
|
||||
auto* p = parser(test::Assemble(MakeEntryPoint("GLCompute", "sort")));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
|
@ -67,9 +67,9 @@ TEST_F(SpvParserTest, EntryPoint_Compute) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EntryPoint_MultiNameConflict) {
|
||||
auto p = parser(test::Assemble(MakeEntryPoint("GLCompute", "work", "40") +
|
||||
MakeEntryPoint("Vertex", "work", "50") +
|
||||
MakeEntryPoint("Fragment", "work", "60")));
|
||||
auto* p = parser(test::Assemble(MakeEntryPoint("GLCompute", "work", "40") +
|
||||
MakeEntryPoint("Vertex", "work", "50") +
|
||||
MakeEntryPoint("Fragment", "work", "60")));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
|
@ -79,7 +79,7 @@ TEST_F(SpvParserTest, EntryPoint_MultiNameConflict) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EntryPoint_NameIsSanitized) {
|
||||
auto p = parser(test::Assemble(MakeEntryPoint("GLCompute", ".1234")));
|
||||
auto* p = parser(test::Assemble(MakeEntryPoint("GLCompute", ".1234")));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_str = p->module().to_str();
|
||||
|
|
|
@ -50,7 +50,7 @@ std::string CommonTypes() {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctions_NoFunctions) {
|
||||
auto p = parser(test::Assemble(CommonTypes()));
|
||||
auto* p = parser(test::Assemble(CommonTypes()));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_ast = p->module().to_str();
|
||||
|
@ -58,7 +58,7 @@ TEST_F(SpvParserTest, EmitFunctions_NoFunctions) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctions_FunctionWithoutBody) {
|
||||
auto p = parser(test::Assemble(Names({"main"}) + CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(Names({"main"}) + CommonTypes() + R"(
|
||||
%main = OpFunction %void None %voidfn
|
||||
OpFunctionEnd
|
||||
)"));
|
||||
|
@ -69,7 +69,7 @@ TEST_F(SpvParserTest, EmitFunctions_FunctionWithoutBody) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctions_VoidFunctionWithoutParams) {
|
||||
auto p = parser(test::Assemble(Names({"main"}) + CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(Names({"main"}) + CommonTypes() + R"(
|
||||
%main = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
OpReturn
|
||||
|
@ -85,7 +85,7 @@ TEST_F(SpvParserTest, EmitFunctions_VoidFunctionWithoutParams) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctions_CalleePrecedesCaller) {
|
||||
auto p = parser(
|
||||
auto* p = parser(
|
||||
test::Assemble(Names({"root", "branch", "leaf"}) + CommonTypes() + R"(
|
||||
%root = OpFunction %void None %voidfn
|
||||
%root_entry = OpLabel
|
||||
|
@ -123,7 +123,7 @@ TEST_F(SpvParserTest, EmitFunctions_CalleePrecedesCaller) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctions_NonVoidResultType) {
|
||||
auto p = parser(test::Assemble(Names({"ret_float"}) + CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(Names({"ret_float"}) + CommonTypes() + R"(
|
||||
%fn_ret_float = OpTypeFunction %float
|
||||
|
||||
%ret_float = OpFunction %float None %fn_ret_float
|
||||
|
@ -142,8 +142,8 @@ TEST_F(SpvParserTest, EmitFunctions_NonVoidResultType) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctions_MixedParamTypes) {
|
||||
auto p = parser(test::Assemble(Names({"mixed_params", "a", "b", "c"}) +
|
||||
CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(Names({"mixed_params", "a", "b", "c"}) +
|
||||
CommonTypes() + R"(
|
||||
%fn_mixed_params = OpTypeFunction %float %uint %float %int
|
||||
|
||||
%mixed_params = OpFunction %void None %fn_mixed_params
|
||||
|
@ -181,7 +181,7 @@ TEST_F(SpvParserTest, EmitFunctions_MixedParamTypes) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, EmitFunctions_GenerateParamNames) {
|
||||
auto p = parser(test::Assemble(Names({"mixed_params"}) + CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(Names({"mixed_params"}) + CommonTypes() + R"(
|
||||
%fn_mixed_params = OpTypeFunction %float %uint %float %int
|
||||
|
||||
%mixed_params = OpFunction %void None %fn_mixed_params
|
||||
|
|
|
@ -27,7 +27,7 @@ using ::testing::Eq;
|
|||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
TEST_F(SpvParserTest, GetDecorationsFor_NotAnId) {
|
||||
auto p = parser(test::Assemble(""));
|
||||
auto* p = parser(test::Assemble(""));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(42);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
|
@ -35,7 +35,7 @@ TEST_F(SpvParserTest, GetDecorationsFor_NotAnId) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, GetDecorationsFor_NoDecorations) {
|
||||
auto p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
auto* p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(1);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
|
@ -43,7 +43,7 @@ TEST_F(SpvParserTest, GetDecorationsFor_NoDecorations) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, GetDecorationsFor_OneDecoration) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpDecorate %10 Block
|
||||
%float = OpTypeFloat 32
|
||||
%10 = OpTypeStruct %float
|
||||
|
@ -56,7 +56,7 @@ TEST_F(SpvParserTest, GetDecorationsFor_OneDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, GetDecorationsFor_MultiDecoration) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpDecorate %5 RelaxedPrecision
|
||||
OpDecorate %5 Location 7 ; Invalid case made up for test
|
||||
%float = OpTypeFloat 32
|
||||
|
@ -71,7 +71,7 @@ TEST_F(SpvParserTest, GetDecorationsFor_MultiDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, GetDecorationsForMember_NotAnId) {
|
||||
auto p = parser(test::Assemble(""));
|
||||
auto* p = parser(test::Assemble(""));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsForMember(42, 9);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
|
@ -79,7 +79,7 @@ TEST_F(SpvParserTest, GetDecorationsForMember_NotAnId) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, GetDecorationsForMember_NotAStruct) {
|
||||
auto p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
auto* p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(1);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
|
@ -87,7 +87,7 @@ TEST_F(SpvParserTest, GetDecorationsForMember_NotAStruct) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, GetDecorationsForMember_MemberWithoutDecoration) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%10 = OpTypeStruct %uint
|
||||
)"));
|
||||
|
@ -99,7 +99,7 @@ TEST_F(SpvParserTest, GetDecorationsForMember_MemberWithoutDecoration) {
|
|||
|
||||
// TODO(dneto): Enable when ArrayStride is handled
|
||||
TEST_F(SpvParserTest, DISABLED_GetDecorationsForMember_OneDecoration) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpMemberDecorate %10 1 ArrayStride 12
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_2 = OpConstant %uint 2
|
||||
|
@ -117,7 +117,7 @@ TEST_F(SpvParserTest, DISABLED_GetDecorationsForMember_OneDecoration) {
|
|||
// crbug.com/tint/30 for ArrayStride
|
||||
// crbug.com/tint/31 for matrix layout
|
||||
TEST_F(SpvParserTest, DISABLED_GetDecorationsForMember_MultiDecoration) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpMemberDecorate %50 1 RelaxedPrecision
|
||||
OpMemberDecorate %50 2 ArrayStride 16
|
||||
OpMemberDecorate %50 2 MatrixStride 8
|
||||
|
|
|
@ -32,7 +32,7 @@ using ::testing::Not;
|
|||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
TEST_F(SpvParserTest, Import_NoImport) {
|
||||
auto p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
auto* p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_ast = p->module().to_str();
|
||||
|
@ -40,7 +40,7 @@ TEST_F(SpvParserTest, Import_NoImport) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, Import_ImportGlslStd450) {
|
||||
auto p = parser(test::Assemble(R"(%1 = OpExtInstImport "GLSL.std.450")"));
|
||||
auto* p = parser(test::Assemble(R"(%1 = OpExtInstImport "GLSL.std.450")"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
EXPECT_THAT(p->glsl_std_450_imports(), ElementsAre(1));
|
||||
|
@ -49,7 +49,7 @@ TEST_F(SpvParserTest, Import_ImportGlslStd450) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, Import_ImportGlslStd450Twice) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
%42 = OpExtInstImport "GLSL.std.450"
|
||||
)"));
|
||||
|
@ -57,7 +57,7 @@ TEST_F(SpvParserTest, Import_ImportGlslStd450Twice) {
|
|||
EXPECT_TRUE(p->error().empty());
|
||||
EXPECT_THAT(p->glsl_std_450_imports(), UnorderedElementsAre(1, 42));
|
||||
const auto module = p->module();
|
||||
EXPECT_EQ(module.imports().size(), 1);
|
||||
EXPECT_EQ(module.imports().size(), 1u);
|
||||
const auto module_ast = module.to_str();
|
||||
// TODO(dneto): Use a matcher to show there is only one import.
|
||||
EXPECT_THAT(module_ast, HasSubstr(R"(Import{"GLSL.std.450" as std::glsl})"));
|
||||
|
|
|
@ -59,7 +59,7 @@ std::string CommonTypes() {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_NoVar) {
|
||||
auto p = parser(test::Assemble(""));
|
||||
auto* p = parser(test::Assemble(""));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
const auto module_ast = p->module().to_str();
|
||||
|
@ -67,7 +67,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_NoVar) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_BadStorageClass) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%ptr = OpTypePointer CrossWorkgroup %float
|
||||
%52 = OpVariable %ptr CrossWorkgroup
|
||||
|
@ -81,7 +81,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_BadStorageClass) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_BadPointerType) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%fn_ty = OpTypeFunction %float
|
||||
%3 = OpTypePointer Private %fn_ty
|
||||
|
@ -97,7 +97,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_BadPointerType) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_AnonWorkgroupVar) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%float = OpTypeFloat 32
|
||||
%ptr = OpTypePointer Workgroup %float
|
||||
%52 = OpVariable %ptr Workgroup
|
||||
|
@ -115,7 +115,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_AnonWorkgroupVar) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_NamedWorkgroupVar) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpName %52 "the_counter"
|
||||
%float = OpTypeFloat 32
|
||||
%ptr = OpTypePointer Workgroup %float
|
||||
|
@ -134,7 +134,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_NamedWorkgroupVar) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_PrivateVar) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpName %52 "my_own_private_idaho"
|
||||
%float = OpTypeFloat 32
|
||||
%ptr = OpTypePointer Private %float
|
||||
|
@ -153,7 +153,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_PrivateVar) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_BuiltinVerteIndex) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpDecorate %52 BuiltIn VertexIndex
|
||||
%uint = OpTypeInt 32 0
|
||||
%ptr = OpTypePointer Input %uint
|
||||
|
@ -175,7 +175,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_BuiltinVerteIndex) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ScalarInitializers) {
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%1 = OpVariable %ptr_bool Private %true
|
||||
%2 = OpVariable %ptr_bool Private %false
|
||||
%3 = OpVariable %ptr_int Private %int_m1
|
||||
|
@ -228,7 +228,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ScalarInitializers) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ScalarNullInitializers) {
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%null_bool = OpConstantNull %bool
|
||||
%null_int = OpConstantNull %int
|
||||
%null_uint = OpConstantNull %uint
|
||||
|
@ -277,7 +277,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ScalarNullInitializers) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_VectorInitializer) {
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %v2float
|
||||
%two = OpConstant %float 2.0
|
||||
%const = OpConstantComposite %v2float %float_1p5 %two
|
||||
|
@ -301,7 +301,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_VectorInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_MatrixInitializer) {
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %m3v2float
|
||||
%two = OpConstant %float 2.0
|
||||
%three = OpConstant %float 3.0
|
||||
|
@ -343,7 +343,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_MatrixInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_ArrayInitializer) {
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %arr2uint
|
||||
%two = OpConstant %uint 2
|
||||
%const = OpConstantComposite %arr2uint %uint_1 %two
|
||||
|
@ -367,7 +367,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ArrayInitializer) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, ModuleScopeVar_StructInitializer) {
|
||||
auto p = parser(test::Assemble(CommonTypes() + R"(
|
||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Private %strct
|
||||
%two = OpConstant %uint 2
|
||||
%arrconst = OpConstantComposite %arr2uint %uint_1 %two
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace {
|
|||
using ::testing::HasSubstr;
|
||||
|
||||
TEST_F(SpvParserTest, NamedTypes_AnonStruct) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%s = OpTypeStruct %uint %uint
|
||||
)"));
|
||||
|
@ -44,7 +44,7 @@ TEST_F(SpvParserTest, NamedTypes_AnonStruct) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, NamedTypes_NamedStruct) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpName %s "mystruct"
|
||||
%uint = OpTypeInt 32 0
|
||||
%s = OpTypeStruct %uint %uint
|
||||
|
@ -55,7 +55,7 @@ TEST_F(SpvParserTest, NamedTypes_NamedStruct) {
|
|||
|
||||
// TODO(dneto): Enable this when array types can have ArrayStride
|
||||
TEST_F(SpvParserTest, DISABLED_NamedTypes_AnonArrayWithDecoration) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpDecorate %arr ArrayStride 16
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_3 = OpConstant %uint 3
|
||||
|
@ -69,7 +69,7 @@ TEST_F(SpvParserTest, DISABLED_NamedTypes_AnonArrayWithDecoration) {
|
|||
// an OpName?
|
||||
|
||||
TEST_F(SpvParserTest, NamedTypes_AnonRTArray) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%arr = OpTypeRuntimeArray %uint
|
||||
)"));
|
||||
|
@ -78,7 +78,7 @@ TEST_F(SpvParserTest, NamedTypes_AnonRTArray) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, NamedTypes_NamedRTArray) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpName %arr "myrtarr"
|
||||
%uint = OpTypeInt 32 0
|
||||
%arr = OpTypeRuntimeArray %uint
|
||||
|
|
|
@ -30,14 +30,14 @@ using ::testing::HasSubstr;
|
|||
|
||||
TEST_F(SpvParserTest, Impl_Uint32VecEmpty) {
|
||||
std::vector<uint32_t> data;
|
||||
auto p = parser(data);
|
||||
auto* p = parser(data);
|
||||
EXPECT_FALSE(p->Parse());
|
||||
// TODO(dneto): What message?
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest, Impl_InvalidModuleFails) {
|
||||
auto invalid_spv = test::Assemble("%ty = OpTypeInt 3 0");
|
||||
auto p = parser(invalid_spv);
|
||||
auto* p = parser(invalid_spv);
|
||||
EXPECT_FALSE(p->Parse());
|
||||
EXPECT_THAT(
|
||||
p->error(),
|
||||
|
|
|
@ -37,10 +37,10 @@ class SpvParserTestBase : public T {
|
|||
~SpvParserTestBase() = default;
|
||||
|
||||
/// Sets up the test helper
|
||||
void SetUp() { ctx_.Reset(); }
|
||||
void SetUp() override { ctx_.Reset(); }
|
||||
|
||||
/// Tears down the test helper
|
||||
void TearDown() { impl_ = nullptr; }
|
||||
void TearDown() override { impl_ = nullptr; }
|
||||
|
||||
/// Retrieves the parser from the helper
|
||||
/// @param input the SPIR-V binary to parse
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace {
|
|||
using ::testing::Eq;
|
||||
|
||||
TEST_F(SpvParserTest, UserName_RespectOpName) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpName %1 "the_void_type"
|
||||
%1 = OpTypeVoid
|
||||
)"));
|
||||
|
@ -37,7 +37,7 @@ TEST_F(SpvParserTest, UserName_RespectOpName) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, UserName_DistinguishDuplicateSuggestion) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpName %1 "vanilla"
|
||||
OpName %2 "vanilla"
|
||||
%1 = OpTypeVoid
|
||||
|
@ -49,7 +49,7 @@ TEST_F(SpvParserTest, UserName_DistinguishDuplicateSuggestion) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, UserName_RespectOpMemberName) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpMemberName %3 0 "strawberry"
|
||||
OpMemberName %3 1 "vanilla"
|
||||
OpMemberName %3 2 "chocolate"
|
||||
|
@ -63,7 +63,7 @@ TEST_F(SpvParserTest, UserName_RespectOpMemberName) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, UserName_SynthesizeMemberNames) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypeStruct %2 %2 %2
|
||||
)"));
|
||||
|
@ -74,7 +74,7 @@ TEST_F(SpvParserTest, UserName_SynthesizeMemberNames) {
|
|||
}
|
||||
|
||||
TEST_F(SpvParserTest, UserName_MemberNamesMixUserAndSynthesized) {
|
||||
auto p = parser(test::Assemble(R"(
|
||||
auto* p = parser(test::Assemble(R"(
|
||||
OpMemberName %3 1 "vanilla"
|
||||
%2 = OpTypeInt 32 0
|
||||
%3 = OpTypeStruct %2 %2 %2
|
||||
|
|
|
@ -36,8 +36,8 @@ TEST_F(LexerTest, Skips_Whitespace) {
|
|||
|
||||
auto t = l.next();
|
||||
EXPECT_TRUE(t.IsIdentifier());
|
||||
EXPECT_EQ(t.line(), 2);
|
||||
EXPECT_EQ(t.column(), 6);
|
||||
EXPECT_EQ(t.line(), 2u);
|
||||
EXPECT_EQ(t.column(), 6u);
|
||||
EXPECT_EQ(t.to_str(), "ident");
|
||||
|
||||
t = l.next();
|
||||
|
@ -52,14 +52,14 @@ ident1 #ends with comment
|
|||
|
||||
auto t = l.next();
|
||||
EXPECT_TRUE(t.IsIdentifier());
|
||||
EXPECT_EQ(t.line(), 2);
|
||||
EXPECT_EQ(t.column(), 1);
|
||||
EXPECT_EQ(t.line(), 2u);
|
||||
EXPECT_EQ(t.column(), 1u);
|
||||
EXPECT_EQ(t.to_str(), "ident1");
|
||||
|
||||
t = l.next();
|
||||
EXPECT_TRUE(t.IsIdentifier());
|
||||
EXPECT_EQ(t.line(), 4);
|
||||
EXPECT_EQ(t.column(), 2);
|
||||
EXPECT_EQ(t.line(), 4u);
|
||||
EXPECT_EQ(t.column(), 2u);
|
||||
EXPECT_EQ(t.to_str(), "ident2");
|
||||
|
||||
t = l.next();
|
||||
|
@ -72,20 +72,20 @@ TEST_F(LexerTest, StringTest_Parse) {
|
|||
auto t = l.next();
|
||||
EXPECT_TRUE(t.IsIdentifier());
|
||||
EXPECT_EQ(t.to_str(), "id");
|
||||
EXPECT_EQ(1, t.line());
|
||||
EXPECT_EQ(1, t.column());
|
||||
EXPECT_EQ(1u, t.line());
|
||||
EXPECT_EQ(1u, t.column());
|
||||
|
||||
t = l.next();
|
||||
EXPECT_TRUE(t.IsStringLiteral());
|
||||
EXPECT_EQ(t.to_str(), "this is string content");
|
||||
EXPECT_EQ(1, t.line());
|
||||
EXPECT_EQ(4, t.column());
|
||||
EXPECT_EQ(1u, t.line());
|
||||
EXPECT_EQ(4u, t.column());
|
||||
|
||||
t = l.next();
|
||||
EXPECT_TRUE(t.IsIdentifier());
|
||||
EXPECT_EQ(t.to_str(), "id2");
|
||||
EXPECT_EQ(1, t.line());
|
||||
EXPECT_EQ(29, t.column());
|
||||
EXPECT_EQ(1u, t.line());
|
||||
EXPECT_EQ(29u, t.column());
|
||||
}
|
||||
|
||||
TEST_F(LexerTest, StringTest_Unterminated) {
|
||||
|
@ -94,8 +94,8 @@ TEST_F(LexerTest, StringTest_Unterminated) {
|
|||
auto t = l.next();
|
||||
EXPECT_TRUE(t.IsIdentifier());
|
||||
EXPECT_EQ(t.to_str(), "id");
|
||||
EXPECT_EQ(1, t.line());
|
||||
EXPECT_EQ(1, t.column());
|
||||
EXPECT_EQ(1u, t.line());
|
||||
EXPECT_EQ(1u, t.column());
|
||||
|
||||
t = l.next();
|
||||
EXPECT_TRUE(t.IsStringLiteral());
|
||||
|
@ -121,8 +121,8 @@ TEST_P(FloatTest, Parse) {
|
|||
auto t = l.next();
|
||||
EXPECT_TRUE(t.IsFloatLiteral());
|
||||
EXPECT_EQ(t.to_f32(), params.result);
|
||||
EXPECT_EQ(1, t.line());
|
||||
EXPECT_EQ(1, t.column());
|
||||
EXPECT_EQ(1u, t.line());
|
||||
EXPECT_EQ(1u, t.column());
|
||||
|
||||
t = l.next();
|
||||
EXPECT_TRUE(t.IsEof());
|
||||
|
@ -170,8 +170,8 @@ TEST_P(IdentifierTest, Parse) {
|
|||
|
||||
auto t = l.next();
|
||||
EXPECT_TRUE(t.IsIdentifier());
|
||||
EXPECT_EQ(t.line(), 1);
|
||||
EXPECT_EQ(t.column(), 1);
|
||||
EXPECT_EQ(t.line(), 1u);
|
||||
EXPECT_EQ(t.column(), 1u);
|
||||
EXPECT_EQ(t.to_str(), GetParam());
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
|
@ -202,8 +202,8 @@ TEST_P(IntegerTest_HexSigned, Matches) {
|
|||
|
||||
auto t = l.next();
|
||||
EXPECT_TRUE(t.IsIntLiteral());
|
||||
EXPECT_EQ(t.line(), 1);
|
||||
EXPECT_EQ(t.column(), 1);
|
||||
EXPECT_EQ(t.line(), 1u);
|
||||
EXPECT_EQ(t.column(), 1u);
|
||||
EXPECT_EQ(t.to_i32(), params.result);
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
|
@ -246,8 +246,8 @@ TEST_P(IntegerTest_HexUnsigned, Matches) {
|
|||
|
||||
auto t = l.next();
|
||||
EXPECT_TRUE(t.IsUintLiteral());
|
||||
EXPECT_EQ(t.line(), 1);
|
||||
EXPECT_EQ(t.column(), 1);
|
||||
EXPECT_EQ(t.line(), 1u);
|
||||
EXPECT_EQ(t.column(), 1u);
|
||||
EXPECT_EQ(t.to_u32(), params.result);
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
|
@ -284,8 +284,8 @@ TEST_P(IntegerTest_Unsigned, Matches) {
|
|||
auto t = l.next();
|
||||
EXPECT_TRUE(t.IsUintLiteral());
|
||||
EXPECT_EQ(t.to_u32(), params.result);
|
||||
EXPECT_EQ(1, t.line());
|
||||
EXPECT_EQ(1, t.column());
|
||||
EXPECT_EQ(1u, t.line());
|
||||
EXPECT_EQ(1u, t.column());
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(LexerTest,
|
||||
IntegerTest_Unsigned,
|
||||
|
@ -310,8 +310,8 @@ TEST_P(IntegerTest_Signed, Matches) {
|
|||
auto t = l.next();
|
||||
EXPECT_TRUE(t.IsIntLiteral());
|
||||
EXPECT_EQ(t.to_i32(), params.result);
|
||||
EXPECT_EQ(1, t.line());
|
||||
EXPECT_EQ(1, t.column());
|
||||
EXPECT_EQ(1u, t.line());
|
||||
EXPECT_EQ(1u, t.column());
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
LexerTest,
|
||||
|
@ -350,8 +350,8 @@ TEST_P(PunctuationTest, Parses) {
|
|||
|
||||
auto t = l.next();
|
||||
EXPECT_TRUE(t.Is(params.type));
|
||||
EXPECT_EQ(1, t.line());
|
||||
EXPECT_EQ(1, t.column());
|
||||
EXPECT_EQ(1u, t.line());
|
||||
EXPECT_EQ(1u, t.column());
|
||||
|
||||
t = l.next();
|
||||
EXPECT_EQ(1 + std::string(params.input).size(), t.column());
|
||||
|
@ -399,8 +399,8 @@ TEST_P(KeywordTest, Parses) {
|
|||
|
||||
auto t = l.next();
|
||||
EXPECT_TRUE(t.Is(params.type));
|
||||
EXPECT_EQ(1, t.line());
|
||||
EXPECT_EQ(1, t.column());
|
||||
EXPECT_EQ(1u, t.line());
|
||||
EXPECT_EQ(1u, t.column());
|
||||
|
||||
t = l.next();
|
||||
EXPECT_EQ(1 + std::string(params.input).size(), t.column());
|
||||
|
@ -500,7 +500,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
|
||||
using KeywordTest_Reserved = testing::TestWithParam<const char*>;
|
||||
TEST_P(KeywordTest_Reserved, Parses) {
|
||||
auto keyword = GetParam();
|
||||
auto* keyword = GetParam();
|
||||
Lexer l(keyword);
|
||||
|
||||
auto t = l.next();
|
||||
|
|
|
@ -26,58 +26,58 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, AdditiveExpression_Parses_Plus) {
|
||||
auto p = parser("a + true");
|
||||
auto* p = parser("a + true");
|
||||
auto e = p->additive_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kAdd, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, AdditiveExpression_Parses_Minus) {
|
||||
auto p = parser("a - true");
|
||||
auto* p = parser("a - true");
|
||||
auto e = p->additive_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kSubtract, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, AdditiveExpression_InvalidLHS) {
|
||||
auto p = parser("if (a) {} + true");
|
||||
auto* p = parser("if (a) {} + true");
|
||||
auto e = p->additive_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, AdditiveExpression_InvalidRHS) {
|
||||
auto p = parser("true + if (a) {}");
|
||||
auto* p = parser("true + if (a) {}");
|
||||
auto e = p->additive_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -85,7 +85,7 @@ TEST_F(ParserImplTest, AdditiveExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, AdditiveExpression_NoOr_ReturnsLHS) {
|
||||
auto p = parser("a true");
|
||||
auto* p = parser("a true");
|
||||
auto e = p->additive_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
|
|
@ -26,36 +26,36 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, AndExpression_Parses) {
|
||||
auto p = parser("a & true");
|
||||
auto* p = parser("a & true");
|
||||
auto e = p->and_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kAnd, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, AndExpression_InvalidLHS) {
|
||||
auto p = parser("if (a) {} & true");
|
||||
auto* p = parser("if (a) {} & true");
|
||||
auto e = p->and_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, AndExpression_InvalidRHS) {
|
||||
auto p = parser("true & if (a) {}");
|
||||
auto* p = parser("true & if (a) {}");
|
||||
auto e = p->and_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -63,7 +63,7 @@ TEST_F(ParserImplTest, AndExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, AndExpression_NoOr_ReturnsLHS) {
|
||||
auto p = parser("a true");
|
||||
auto* p = parser("a true");
|
||||
auto e = p->and_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
|
|
@ -29,34 +29,34 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ArgumentExpressionList_Parses) {
|
||||
auto p = parser("a");
|
||||
auto* p = parser("a");
|
||||
auto e = p->argument_expression_list();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
ASSERT_EQ(e.size(), 1);
|
||||
ASSERT_EQ(e.size(), 1u);
|
||||
ASSERT_TRUE(e[0]->IsIdentifier());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ArgumentExpressionList_ParsesMultiple) {
|
||||
auto p = parser("a, -33, 1+2");
|
||||
auto* p = parser("a, -33, 1+2");
|
||||
auto e = p->argument_expression_list();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
ASSERT_EQ(e.size(), 3);
|
||||
ASSERT_EQ(e.size(), 3u);
|
||||
ASSERT_TRUE(e[0]->IsIdentifier());
|
||||
ASSERT_TRUE(e[1]->IsConstructor());
|
||||
ASSERT_TRUE(e[2]->IsBinary());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ArgumentExpressionList_HandlesMissingExpression) {
|
||||
auto p = parser("a, ");
|
||||
auto* p = parser("a, ");
|
||||
auto e = p->argument_expression_list();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:4: unable to parse argument expression after comma");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ArgumentExpressionList_HandlesInvalidExpression) {
|
||||
auto p = parser("if(a) {}");
|
||||
auto* p = parser("if(a) {}");
|
||||
auto e = p->argument_expression_list();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:1: unable to parse argument expression");
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, AssignmentStmt_Parses_ToVariable) {
|
||||
auto p = parser("a = 123");
|
||||
auto* p = parser("a = 123");
|
||||
auto e = p->assignment_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -39,21 +39,21 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToVariable) {
|
|||
ASSERT_NE(e->rhs(), nullptr);
|
||||
|
||||
ASSERT_TRUE(e->lhs()->IsIdentifier());
|
||||
auto ident = e->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = e->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(e->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(e->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
|
||||
auto init = e->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = e->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_NE(init->literal(), nullptr);
|
||||
ASSERT_TRUE(init->literal()->IsInt());
|
||||
EXPECT_EQ(init->literal()->AsInt()->value(), 123);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) {
|
||||
auto p = parser("a.b.c[2].d = 123");
|
||||
auto* p = parser("a.b.c[2].d = 123");
|
||||
auto e = p->assignment_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -64,21 +64,21 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) {
|
|||
|
||||
ASSERT_TRUE(e->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(e->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = e->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = e->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_NE(init->literal(), nullptr);
|
||||
ASSERT_TRUE(init->literal()->IsInt());
|
||||
EXPECT_EQ(init->literal()->AsInt()->value(), 123);
|
||||
|
||||
ASSERT_TRUE(e->lhs()->IsMemberAccessor());
|
||||
auto mem = e->lhs()->AsMemberAccessor();
|
||||
auto* mem = e->lhs()->AsMemberAccessor();
|
||||
|
||||
ASSERT_TRUE(mem->member()->IsIdentifier());
|
||||
auto ident = mem->member()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = mem->member()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "d");
|
||||
|
||||
ASSERT_TRUE(mem->structure()->IsArrayAccessor());
|
||||
auto ary = mem->structure()->AsArrayAccessor();
|
||||
auto* ary = mem->structure()->AsArrayAccessor();
|
||||
|
||||
ASSERT_TRUE(ary->idx_expr()->IsConstructor());
|
||||
ASSERT_TRUE(ary->idx_expr()->AsConstructor()->IsScalarConstructor());
|
||||
|
@ -91,7 +91,7 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) {
|
|||
mem = ary->array()->AsMemberAccessor();
|
||||
ASSERT_TRUE(mem->member()->IsIdentifier());
|
||||
ident = mem->member()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "c");
|
||||
|
||||
ASSERT_TRUE(mem->structure()->IsMemberAccessor());
|
||||
|
@ -99,17 +99,17 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) {
|
|||
|
||||
ASSERT_TRUE(mem->structure()->IsIdentifier());
|
||||
ident = mem->structure()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(mem->member()->IsIdentifier());
|
||||
ident = mem->member()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "b");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, AssignmentStmt_MissingEqual) {
|
||||
auto p = parser("a.b.c[2].d 123");
|
||||
auto* p = parser("a.b.c[2].d 123");
|
||||
auto e = p->assignment_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -117,14 +117,14 @@ TEST_F(ParserImplTest, AssignmentStmt_MissingEqual) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, AssignmentStmt_InvalidLHS) {
|
||||
auto p = parser("if (true) {} = 123");
|
||||
auto* p = parser("if (true) {} = 123");
|
||||
auto e = p->assignment_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, AssignmentStmt_InvalidRHS) {
|
||||
auto p = parser("a.b.c[2].d = if (true) {}");
|
||||
auto* p = parser("a.b.c[2].d = if (true) {}");
|
||||
auto e = p->assignment_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
|
|
@ -22,35 +22,35 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, BodyStmt) {
|
||||
auto p = parser(R"({
|
||||
auto* p = parser(R"({
|
||||
kill;
|
||||
nop;
|
||||
return 1 + b / 2;
|
||||
})");
|
||||
auto e = p->body_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e.size(), 3);
|
||||
ASSERT_EQ(e.size(), 3u);
|
||||
EXPECT_TRUE(e[0]->IsKill());
|
||||
EXPECT_TRUE(e[1]->IsNop());
|
||||
EXPECT_TRUE(e[2]->IsReturn());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, BodyStmt_Empty) {
|
||||
auto p = parser("{}");
|
||||
auto* p = parser("{}");
|
||||
auto e = p->body_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_EQ(e.size(), 0);
|
||||
EXPECT_EQ(e.size(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, BodyStmt_InvalidStmt) {
|
||||
auto p = parser("{fn main() -> void {}}");
|
||||
auto* p = parser("{fn main() -> void {}}");
|
||||
auto e = p->body_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:2: missing }");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, BodyStmt_MissingRightParen) {
|
||||
auto p = parser("{return;");
|
||||
auto* p = parser("{return;");
|
||||
auto e = p->body_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:9: missing }");
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, BreakStmt) {
|
||||
auto p = parser("break");
|
||||
auto* p = parser("break");
|
||||
auto e = p->break_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -35,7 +35,7 @@ TEST_F(ParserImplTest, BreakStmt) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, BreakStmt_WithIf) {
|
||||
auto p = parser("break if (a == b)");
|
||||
auto* p = parser("break if (a == b)");
|
||||
auto e = p->break_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -46,7 +46,7 @@ TEST_F(ParserImplTest, BreakStmt_WithIf) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, BreakStmt_WithUnless) {
|
||||
auto p = parser("break unless (a == b)");
|
||||
auto* p = parser("break unless (a == b)");
|
||||
auto e = p->break_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -57,7 +57,7 @@ TEST_F(ParserImplTest, BreakStmt_WithUnless) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, BreakStmt_InvalidRHS) {
|
||||
auto p = parser("break if (a = b)");
|
||||
auto* p = parser("break if (a = b)");
|
||||
auto e = p->break_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -65,7 +65,7 @@ TEST_F(ParserImplTest, BreakStmt_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, BreakStmt_MissingRHS) {
|
||||
auto p = parser("break if");
|
||||
auto* p = parser("break if");
|
||||
auto e = p->break_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
|
|
@ -36,9 +36,9 @@ class BuiltinTest : public testing::TestWithParam<BuiltinData> {
|
|||
BuiltinTest() = default;
|
||||
~BuiltinTest() = default;
|
||||
|
||||
void SetUp() { ctx_.Reset(); }
|
||||
void SetUp() override { ctx_.Reset(); }
|
||||
|
||||
void TearDown() { impl_ = nullptr; }
|
||||
void TearDown() override { impl_ = nullptr; }
|
||||
|
||||
ParserImpl* parser(const std::string& str) {
|
||||
impl_ = std::make_unique<ParserImpl>(&ctx_, str);
|
||||
|
@ -52,7 +52,7 @@ class BuiltinTest : public testing::TestWithParam<BuiltinData> {
|
|||
|
||||
TEST_P(BuiltinTest, Parses) {
|
||||
auto params = GetParam();
|
||||
auto p = parser(params.input);
|
||||
auto* p = parser(params.input);
|
||||
|
||||
auto builtin = p->builtin_decoration();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
|
@ -79,7 +79,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
ast::Builtin::kGlobalInvocationId}));
|
||||
|
||||
TEST_F(ParserImplTest, BuiltinDecoration_NoMatch) {
|
||||
auto p = parser("not-a-builtin");
|
||||
auto* p = parser("not-a-builtin");
|
||||
auto builtin = p->builtin_decoration();
|
||||
ASSERT_EQ(builtin, ast::Builtin::kNone);
|
||||
|
||||
|
|
|
@ -22,45 +22,45 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, CaseBody_Empty) {
|
||||
auto p = parser("");
|
||||
auto* p = parser("");
|
||||
auto e = p->case_body();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_EQ(e.size(), 0);
|
||||
EXPECT_EQ(e.size(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, CaseBody_Statements) {
|
||||
auto p = parser(R"(
|
||||
auto* p = parser(R"(
|
||||
var a: i32;
|
||||
a = 2;)");
|
||||
|
||||
auto e = p->case_body();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e.size(), 2);
|
||||
ASSERT_EQ(e.size(), 2u);
|
||||
EXPECT_TRUE(e[0]->IsVariableDecl());
|
||||
EXPECT_TRUE(e[1]->IsAssign());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, CaseBody_InvalidStatement) {
|
||||
auto p = parser("a =");
|
||||
auto* p = parser("a =");
|
||||
auto e = p->case_body();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(e.size(), 0);
|
||||
EXPECT_EQ(e.size(), 0u);
|
||||
EXPECT_EQ(p->error(), "1:4: unable to parse right side of assignment");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, CaseBody_Fallthrough) {
|
||||
auto p = parser("fallthrough;");
|
||||
auto* p = parser("fallthrough;");
|
||||
auto e = p->case_body();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e.size(), 1);
|
||||
ASSERT_EQ(e.size(), 1u);
|
||||
EXPECT_TRUE(e[0]->IsFallthrough());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, CaseBody_Fallthrough_MissingSemicolon) {
|
||||
auto p = parser("fallthrough");
|
||||
auto* p = parser("fallthrough");
|
||||
auto e = p->case_body();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(e.size(), 0);
|
||||
EXPECT_EQ(e.size(), 0u);
|
||||
EXPECT_EQ(p->error(), "1:12: missing ;");
|
||||
}
|
||||
|
||||
|
|
|
@ -27,23 +27,23 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_TypeDecl) {
|
||||
auto p = parser("vec2<f32>(1., 2.)");
|
||||
auto* p = parser("vec2<f32>(1., 2.)");
|
||||
auto e = p->const_expr();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
ASSERT_TRUE(e->IsConstructor());
|
||||
ASSERT_TRUE(e->AsConstructor()->IsTypeConstructor());
|
||||
|
||||
auto t = e->AsConstructor()->AsTypeConstructor();
|
||||
auto* t = e->AsConstructor()->AsTypeConstructor();
|
||||
ASSERT_TRUE(t->type()->IsVector());
|
||||
EXPECT_EQ(t->type()->AsVector()->size(), 2);
|
||||
EXPECT_EQ(t->type()->AsVector()->size(), 2u);
|
||||
|
||||
ASSERT_EQ(t->values().size(), 2);
|
||||
ASSERT_EQ(t->values().size(), 2u);
|
||||
auto& v = t->values();
|
||||
|
||||
ASSERT_TRUE(v[0]->IsConstructor());
|
||||
ASSERT_TRUE(v[0]->AsConstructor()->IsScalarConstructor());
|
||||
auto c = v[0]->AsConstructor()->AsScalarConstructor();
|
||||
auto* c = v[0]->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(c->literal()->IsFloat());
|
||||
EXPECT_FLOAT_EQ(c->literal()->AsFloat()->value(), 1.);
|
||||
|
||||
|
@ -55,7 +55,7 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_TypeDecl_MissingRightParen) {
|
||||
auto p = parser("vec2<f32>(1., 2.");
|
||||
auto* p = parser("vec2<f32>(1., 2.");
|
||||
auto e = p->const_expr();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -63,7 +63,7 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_TypeDecl_MissingLeftParen) {
|
||||
auto p = parser("vec2<f32> 1., 2.)");
|
||||
auto* p = parser("vec2<f32> 1., 2.)");
|
||||
auto e = p->const_expr();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -71,7 +71,7 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_TypeDecl_HangingComma) {
|
||||
auto p = parser("vec2<f32>(1.,)");
|
||||
auto* p = parser("vec2<f32>(1.,)");
|
||||
auto e = p->const_expr();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -79,7 +79,7 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl_HangingComma) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_TypeDecl_MissingComma) {
|
||||
auto p = parser("vec2<f32>(1. 2.");
|
||||
auto* p = parser("vec2<f32>(1. 2.");
|
||||
auto e = p->const_expr();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -87,7 +87,7 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl_MissingComma) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_MissingExpr) {
|
||||
auto p = parser("vec2<f32>()");
|
||||
auto* p = parser("vec2<f32>()");
|
||||
auto e = p->const_expr();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -95,7 +95,7 @@ TEST_F(ParserImplTest, ConstExpr_MissingExpr) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_InvalidExpr) {
|
||||
auto p = parser("vec2<f32>(1., if(a) {})");
|
||||
auto* p = parser("vec2<f32>(1., if(a) {})");
|
||||
auto e = p->const_expr();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -103,19 +103,19 @@ TEST_F(ParserImplTest, ConstExpr_InvalidExpr) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_ConstLiteral) {
|
||||
auto p = parser("true");
|
||||
auto* p = parser("true");
|
||||
auto e = p->const_expr();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
ASSERT_TRUE(e->IsConstructor());
|
||||
ASSERT_TRUE(e->AsConstructor()->IsScalarConstructor());
|
||||
auto c = e->AsConstructor()->AsScalarConstructor();
|
||||
auto* c = e->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(c->literal()->IsBool());
|
||||
EXPECT_TRUE(c->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstExpr_ConstLiteral_Invalid) {
|
||||
auto p = parser("invalid");
|
||||
auto* p = parser("invalid");
|
||||
auto e = p->const_expr();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ConstLiteral_Int) {
|
||||
auto p = parser("-234");
|
||||
auto* p = parser("-234");
|
||||
auto c = p->const_literal();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_NE(c, nullptr);
|
||||
|
@ -35,7 +35,7 @@ TEST_F(ParserImplTest, ConstLiteral_Int) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstLiteral_Uint) {
|
||||
auto p = parser("234u");
|
||||
auto* p = parser("234u");
|
||||
auto c = p->const_literal();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_NE(c, nullptr);
|
||||
|
@ -44,7 +44,7 @@ TEST_F(ParserImplTest, ConstLiteral_Uint) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstLiteral_Float) {
|
||||
auto p = parser("234.e12");
|
||||
auto* p = parser("234.e12");
|
||||
auto c = p->const_literal();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_NE(c, nullptr);
|
||||
|
@ -53,13 +53,13 @@ TEST_F(ParserImplTest, ConstLiteral_Float) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstLiteral_InvalidFloat) {
|
||||
auto p = parser("1.2e+256");
|
||||
auto* p = parser("1.2e+256");
|
||||
auto c = p->const_literal();
|
||||
ASSERT_EQ(c, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstLiteral_True) {
|
||||
auto p = parser("true");
|
||||
auto* p = parser("true");
|
||||
auto c = p->const_literal();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_NE(c, nullptr);
|
||||
|
@ -68,7 +68,7 @@ TEST_F(ParserImplTest, ConstLiteral_True) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstLiteral_False) {
|
||||
auto p = parser("false");
|
||||
auto* p = parser("false");
|
||||
auto c = p->const_literal();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_NE(c, nullptr);
|
||||
|
@ -77,7 +77,7 @@ TEST_F(ParserImplTest, ConstLiteral_False) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ConstLiteral_NoMatch) {
|
||||
auto p = parser("another-token");
|
||||
auto* p = parser("another-token");
|
||||
auto c = p->const_literal();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_EQ(c, nullptr);
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ContinueStmt) {
|
||||
auto p = parser("continue");
|
||||
auto* p = parser("continue");
|
||||
auto e = p->continue_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -35,7 +35,7 @@ TEST_F(ParserImplTest, ContinueStmt) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ContinueStmt_WithIf) {
|
||||
auto p = parser("continue if (a == b)");
|
||||
auto* p = parser("continue if (a == b)");
|
||||
auto e = p->continue_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -46,7 +46,7 @@ TEST_F(ParserImplTest, ContinueStmt_WithIf) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ContinueStmt_WithUnless) {
|
||||
auto p = parser("continue unless (a == b)");
|
||||
auto* p = parser("continue unless (a == b)");
|
||||
auto e = p->continue_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -57,7 +57,7 @@ TEST_F(ParserImplTest, ContinueStmt_WithUnless) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ContinueStmt_InvalidRHS) {
|
||||
auto p = parser("continue if (a = b)");
|
||||
auto* p = parser("continue if (a = b)");
|
||||
auto e = p->continue_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -65,7 +65,7 @@ TEST_F(ParserImplTest, ContinueStmt_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ContinueStmt_MissingRHS) {
|
||||
auto p = parser("continue if");
|
||||
auto* p = parser("continue if");
|
||||
auto e = p->continue_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
|
|
@ -22,18 +22,18 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ContinuingStmt) {
|
||||
auto p = parser("continuing { nop; }");
|
||||
auto* p = parser("continuing { nop; }");
|
||||
auto e = p->continuing_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e.size(), 1);
|
||||
ASSERT_EQ(e.size(), 1u);
|
||||
ASSERT_TRUE(e[0]->IsNop());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ContinuingStmt_InvalidBody) {
|
||||
auto p = parser("continuing { nop }");
|
||||
auto* p = parser("continuing { nop }");
|
||||
auto e = p->continuing_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e.size(), 0);
|
||||
ASSERT_EQ(e.size(), 0u);
|
||||
EXPECT_EQ(p->error(), "1:18: missing ;");
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ class DerivativeModifierTest
|
|||
DerivativeModifierTest() = default;
|
||||
~DerivativeModifierTest() = default;
|
||||
|
||||
void SetUp() { ctx_.Reset(); }
|
||||
void SetUp() override { ctx_.Reset(); }
|
||||
|
||||
void TearDown() { impl_ = nullptr; }
|
||||
void TearDown() override { impl_ = nullptr; }
|
||||
|
||||
ParserImpl* parser(const std::string& str) {
|
||||
impl_ = std::make_unique<ParserImpl>(&ctx_, str);
|
||||
|
@ -54,7 +54,7 @@ class DerivativeModifierTest
|
|||
|
||||
TEST_P(DerivativeModifierTest, Parses) {
|
||||
auto params = GetParam();
|
||||
auto p = parser(params.input);
|
||||
auto* p = parser(params.input);
|
||||
|
||||
auto mod = p->derivative_modifier();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
|
@ -71,7 +71,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
DerivativeModifierData{"coarse", ast::DerivativeModifier::kCoarse}));
|
||||
|
||||
TEST_F(ParserImplTest, DerivativeModifier_NoMatch) {
|
||||
auto p = parser("not-a-modifier");
|
||||
auto* p = parser("not-a-modifier");
|
||||
auto stage = p->derivative_modifier();
|
||||
ASSERT_EQ(stage, ast::DerivativeModifier::kNone);
|
||||
|
||||
|
|
|
@ -23,17 +23,17 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ElseStmt) {
|
||||
auto p = parser("else { a = b; c = d; }");
|
||||
auto* p = parser("else { a = b; c = d; }");
|
||||
auto e = p->else_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
ASSERT_TRUE(e->IsElse());
|
||||
ASSERT_EQ(e->condition(), nullptr);
|
||||
EXPECT_EQ(e->body().size(), 2);
|
||||
EXPECT_EQ(e->body().size(), 2u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ElseStmt_InvalidBody) {
|
||||
auto p = parser("else { fn main() -> void {}}");
|
||||
auto* p = parser("else { fn main() -> void {}}");
|
||||
auto e = p->else_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -41,7 +41,7 @@ TEST_F(ParserImplTest, ElseStmt_InvalidBody) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ElseStmt_MissingBody) {
|
||||
auto p = parser("else");
|
||||
auto* p = parser("else");
|
||||
auto e = p->else_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
|
|
@ -23,43 +23,43 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ElseIfStmt) {
|
||||
auto p = parser("elseif (a == 4) { a = b; c = d; }");
|
||||
auto* p = parser("elseif (a == 4) { a = b; c = d; }");
|
||||
auto e = p->elseif_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e.size(), 1);
|
||||
ASSERT_EQ(e.size(), 1u);
|
||||
|
||||
ASSERT_TRUE(e[0]->IsElse());
|
||||
ASSERT_NE(e[0]->condition(), nullptr);
|
||||
ASSERT_TRUE(e[0]->condition()->IsBinary());
|
||||
EXPECT_EQ(e[0]->body().size(), 2);
|
||||
EXPECT_EQ(e[0]->body().size(), 2u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ElseIfStmt_Multiple) {
|
||||
auto p = parser("elseif (a == 4) { a = b; c = d; } elseif(c) { d = 2; }");
|
||||
auto* p = parser("elseif (a == 4) { a = b; c = d; } elseif(c) { d = 2; }");
|
||||
auto e = p->elseif_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e.size(), 2);
|
||||
ASSERT_EQ(e.size(), 2u);
|
||||
|
||||
ASSERT_TRUE(e[0]->IsElse());
|
||||
ASSERT_NE(e[0]->condition(), nullptr);
|
||||
ASSERT_TRUE(e[0]->condition()->IsBinary());
|
||||
EXPECT_EQ(e[0]->body().size(), 2);
|
||||
EXPECT_EQ(e[0]->body().size(), 2u);
|
||||
|
||||
ASSERT_TRUE(e[1]->IsElse());
|
||||
ASSERT_NE(e[1]->condition(), nullptr);
|
||||
ASSERT_TRUE(e[1]->condition()->IsIdentifier());
|
||||
EXPECT_EQ(e[1]->body().size(), 1);
|
||||
EXPECT_EQ(e[1]->body().size(), 1u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ElseIfStmt_InvalidBody) {
|
||||
auto p = parser("elseif (true) { fn main() -> void {}}");
|
||||
auto* p = parser("elseif (true) { fn main() -> void {}}");
|
||||
auto e = p->elseif_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:17: missing }");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ElseIfStmt_MissingBody) {
|
||||
auto p = parser("elseif (true)");
|
||||
auto* p = parser("elseif (true)");
|
||||
auto e = p->elseif_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:14: missing {");
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, EntryPoint_Parses) {
|
||||
auto p = parser("entry_point fragment = main");
|
||||
auto* p = parser("entry_point fragment = main");
|
||||
auto e = p->entry_point_decl();
|
||||
ASSERT_NE(e, nullptr);
|
||||
ASSERT_FALSE(p->has_error());
|
||||
|
@ -33,7 +33,7 @@ TEST_F(ParserImplTest, EntryPoint_Parses) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, EntryPoint_ParsesWithStringName) {
|
||||
auto p = parser(R"(entry_point vertex as "main" = vtx_main)");
|
||||
auto* p = parser(R"(entry_point vertex as "main" = vtx_main)");
|
||||
auto e = p->entry_point_decl();
|
||||
ASSERT_NE(e, nullptr);
|
||||
ASSERT_FALSE(p->has_error());
|
||||
|
@ -43,7 +43,7 @@ TEST_F(ParserImplTest, EntryPoint_ParsesWithStringName) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, EntryPoint_ParsesWithIdentName) {
|
||||
auto p = parser(R"(entry_point vertex as main = vtx_main)");
|
||||
auto* p = parser(R"(entry_point vertex as main = vtx_main)");
|
||||
auto e = p->entry_point_decl();
|
||||
ASSERT_NE(e, nullptr);
|
||||
ASSERT_FALSE(p->has_error());
|
||||
|
@ -53,7 +53,7 @@ TEST_F(ParserImplTest, EntryPoint_ParsesWithIdentName) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, EntryPoint_MissingFnName) {
|
||||
auto p = parser(R"(entry_point vertex as main =)");
|
||||
auto* p = parser(R"(entry_point vertex as main =)");
|
||||
auto e = p->entry_point_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -61,7 +61,7 @@ TEST_F(ParserImplTest, EntryPoint_MissingFnName) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, EntryPoint_InvalidFnName) {
|
||||
auto p = parser(R"(entry_point vertex as main = 123)");
|
||||
auto* p = parser(R"(entry_point vertex as main = 123)");
|
||||
auto e = p->entry_point_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -69,7 +69,7 @@ TEST_F(ParserImplTest, EntryPoint_InvalidFnName) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, EntryPoint_MissingEqual) {
|
||||
auto p = parser(R"(entry_point vertex as main vtx_main)");
|
||||
auto* p = parser(R"(entry_point vertex as main vtx_main)");
|
||||
auto e = p->entry_point_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -77,7 +77,7 @@ TEST_F(ParserImplTest, EntryPoint_MissingEqual) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, EntryPoint_MissingName) {
|
||||
auto p = parser(R"(entry_point vertex as = vtx_main)");
|
||||
auto* p = parser(R"(entry_point vertex as = vtx_main)");
|
||||
auto e = p->entry_point_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -85,7 +85,7 @@ TEST_F(ParserImplTest, EntryPoint_MissingName) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, EntryPoint_InvalidName) {
|
||||
auto p = parser(R"(entry_point vertex as 123 = vtx_main)");
|
||||
auto* p = parser(R"(entry_point vertex as 123 = vtx_main)");
|
||||
auto e = p->entry_point_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -93,7 +93,7 @@ TEST_F(ParserImplTest, EntryPoint_InvalidName) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, EntryPoint_MissingStageWithIdent) {
|
||||
auto p = parser(R"(entry_point as 123 = vtx_main)");
|
||||
auto* p = parser(R"(entry_point as 123 = vtx_main)");
|
||||
auto e = p->entry_point_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -101,7 +101,7 @@ TEST_F(ParserImplTest, EntryPoint_MissingStageWithIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, EntryPoint_MissingStage) {
|
||||
auto p = parser(R"(entry_point = vtx_main)");
|
||||
auto* p = parser(R"(entry_point = vtx_main)");
|
||||
auto e = p->entry_point_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -109,7 +109,7 @@ TEST_F(ParserImplTest, EntryPoint_MissingStage) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, EntryPoint_InvalidStage) {
|
||||
auto p = parser(R"(entry_point invalid = vtx_main)");
|
||||
auto* p = parser(R"(entry_point invalid = vtx_main)");
|
||||
auto e = p->entry_point_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
|
|
@ -26,58 +26,58 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, EqualityExpression_Parses_Equal) {
|
||||
auto p = parser("a == true");
|
||||
auto* p = parser("a == true");
|
||||
auto e = p->equality_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kEqual, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, EqualityExpression_Parses_NotEqual) {
|
||||
auto p = parser("a != true");
|
||||
auto* p = parser("a != true");
|
||||
auto e = p->equality_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kNotEqual, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, EqualityExpression_InvalidLHS) {
|
||||
auto p = parser("if (a) {} == true");
|
||||
auto* p = parser("if (a) {} == true");
|
||||
auto e = p->equality_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, EqualityExpression_InvalidRHS) {
|
||||
auto p = parser("true == if (a) {}");
|
||||
auto* p = parser("true == if (a) {}");
|
||||
auto e = p->equality_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -85,7 +85,7 @@ TEST_F(ParserImplTest, EqualityExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, EqualityExpression_NoOr_ReturnsLHS) {
|
||||
auto p = parser("a true");
|
||||
auto* p = parser("a true");
|
||||
auto e = p->equality_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
|
|
@ -26,36 +26,36 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ExclusiveOrExpression_Parses) {
|
||||
auto p = parser("a ^ true");
|
||||
auto* p = parser("a ^ true");
|
||||
auto e = p->exclusive_or_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kXor, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ExclusiveOrExpression_InvalidLHS) {
|
||||
auto p = parser("if (a) {} ^ true");
|
||||
auto* p = parser("if (a) {} ^ true");
|
||||
auto e = p->exclusive_or_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ExclusiveOrExpression_InvalidRHS) {
|
||||
auto p = parser("true ^ if (a) {}");
|
||||
auto* p = parser("true ^ if (a) {}");
|
||||
auto e = p->exclusive_or_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -63,7 +63,7 @@ TEST_F(ParserImplTest, ExclusiveOrExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ExclusiveOrExpression_NoOr_ReturnsLHS) {
|
||||
auto p = parser("a true");
|
||||
auto* p = parser("a true");
|
||||
auto e = p->exclusive_or_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecl) {
|
||||
auto p = parser("fn main(a : i32, b : f32) -> void { return; }");
|
||||
auto* p = parser("fn main(a : i32, b : f32) -> void { return; }");
|
||||
auto f = p->function_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(f, nullptr);
|
||||
|
@ -33,19 +33,19 @@ TEST_F(ParserImplTest, FunctionDecl) {
|
|||
ASSERT_NE(f->return_type(), nullptr);
|
||||
EXPECT_TRUE(f->return_type()->IsVoid());
|
||||
|
||||
ASSERT_EQ(f->params().size(), 2);
|
||||
ASSERT_EQ(f->params().size(), 2u);
|
||||
EXPECT_EQ(f->params()[0]->name(), "a");
|
||||
EXPECT_EQ(f->params()[1]->name(), "b");
|
||||
|
||||
ASSERT_NE(f->return_type(), nullptr);
|
||||
EXPECT_TRUE(f->return_type()->IsVoid());
|
||||
|
||||
ASSERT_EQ(f->body().size(), 1);
|
||||
ASSERT_EQ(f->body().size(), 1u);
|
||||
EXPECT_TRUE(f->body()[0]->IsReturn());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecl_InvalidHeader) {
|
||||
auto p = parser("fn main() -> { }");
|
||||
auto* p = parser("fn main() -> { }");
|
||||
auto f = p->function_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(f, nullptr);
|
||||
|
@ -53,7 +53,7 @@ TEST_F(ParserImplTest, FunctionDecl_InvalidHeader) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionDecl_InvalidBody) {
|
||||
auto p = parser("fn main() -> void { return }");
|
||||
auto* p = parser("fn main() -> void { return }");
|
||||
auto f = p->function_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(f, nullptr);
|
||||
|
|
|
@ -24,20 +24,20 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader) {
|
||||
auto p = parser("fn main(a : i32, b: f32) -> void");
|
||||
auto* p = parser("fn main(a : i32, b: f32) -> void");
|
||||
auto f = p->function_header();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(f, nullptr);
|
||||
|
||||
EXPECT_EQ(f->name(), "main");
|
||||
ASSERT_EQ(f->params().size(), 2);
|
||||
ASSERT_EQ(f->params().size(), 2u);
|
||||
EXPECT_EQ(f->params()[0]->name(), "a");
|
||||
EXPECT_EQ(f->params()[1]->name(), "b");
|
||||
EXPECT_TRUE(f->return_type()->IsVoid());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_MissingIdent) {
|
||||
auto p = parser("fn () ->");
|
||||
auto* p = parser("fn () ->");
|
||||
auto f = p->function_header();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(f, nullptr);
|
||||
|
@ -45,7 +45,7 @@ TEST_F(ParserImplTest, FunctionHeader_MissingIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_InvalidIdent) {
|
||||
auto p = parser("fn 133main() -> i32");
|
||||
auto* p = parser("fn 133main() -> i32");
|
||||
auto f = p->function_header();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(f, nullptr);
|
||||
|
@ -53,7 +53,7 @@ TEST_F(ParserImplTest, FunctionHeader_InvalidIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_MissingParenLeft) {
|
||||
auto p = parser("fn main) -> i32");
|
||||
auto* p = parser("fn main) -> i32");
|
||||
auto f = p->function_header();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(f, nullptr);
|
||||
|
@ -61,7 +61,7 @@ TEST_F(ParserImplTest, FunctionHeader_MissingParenLeft) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_InvalidParamList) {
|
||||
auto p = parser("fn main(a :i32,) -> i32");
|
||||
auto* p = parser("fn main(a :i32,) -> i32");
|
||||
auto f = p->function_header();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(f, nullptr);
|
||||
|
@ -69,7 +69,7 @@ TEST_F(ParserImplTest, FunctionHeader_InvalidParamList) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_MissingParenRight) {
|
||||
auto p = parser("fn main( -> i32");
|
||||
auto* p = parser("fn main( -> i32");
|
||||
auto f = p->function_header();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(f, nullptr);
|
||||
|
@ -77,7 +77,7 @@ TEST_F(ParserImplTest, FunctionHeader_MissingParenRight) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_MissingArrow) {
|
||||
auto p = parser("fn main() i32");
|
||||
auto* p = parser("fn main() i32");
|
||||
auto f = p->function_header();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(f, nullptr);
|
||||
|
@ -85,7 +85,7 @@ TEST_F(ParserImplTest, FunctionHeader_MissingArrow) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_InvalidReturnType) {
|
||||
auto p = parser("fn main() -> invalid");
|
||||
auto* p = parser("fn main() -> invalid");
|
||||
auto f = p->function_header();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(f, nullptr);
|
||||
|
@ -93,7 +93,7 @@ TEST_F(ParserImplTest, FunctionHeader_InvalidReturnType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionHeader_MissingReturnType) {
|
||||
auto p = parser("fn main() ->");
|
||||
auto* p = parser("fn main() ->");
|
||||
auto f = p->function_header();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(f, nullptr);
|
||||
|
|
|
@ -28,27 +28,27 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, FunctionTypeDecl_Void) {
|
||||
auto v = tm()->Get(std::make_unique<ast::type::VoidType>());
|
||||
auto* v = tm()->Get(std::make_unique<ast::type::VoidType>());
|
||||
|
||||
auto p = parser("void");
|
||||
auto e = p->function_type_decl();
|
||||
auto* p = parser("void");
|
||||
auto* e = p->function_type_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e, v);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionTypeDecl_Type) {
|
||||
auto f32 = tm()->Get(std::make_unique<ast::type::F32Type>());
|
||||
auto vec2 = tm()->Get(std::make_unique<ast::type::VectorType>(f32, 2));
|
||||
auto* f32 = tm()->Get(std::make_unique<ast::type::F32Type>());
|
||||
auto* vec2 = tm()->Get(std::make_unique<ast::type::VectorType>(f32, 2));
|
||||
|
||||
auto p = parser("vec2<f32>");
|
||||
auto e = p->function_type_decl();
|
||||
auto* p = parser("vec2<f32>");
|
||||
auto* e = p->function_type_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e, vec2);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, FunctionTypeDecl_InvalidType) {
|
||||
auto p = parser("vec2<invalid>");
|
||||
auto e = p->function_type_decl();
|
||||
auto* p = parser("vec2<invalid>");
|
||||
auto* e = p->function_type_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
EXPECT_EQ(p->error(), "1:6: unknown type alias 'invalid'");
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDecl) {
|
||||
auto p = parser("const a : f32 = 1.");
|
||||
auto* p = parser("const a : f32 = 1.");
|
||||
auto e = p->global_constant_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -39,7 +39,7 @@ TEST_F(ParserImplTest, GlobalConstantDecl) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDecl_MissingEqual) {
|
||||
auto p = parser("const a: f32 1.");
|
||||
auto* p = parser("const a: f32 1.");
|
||||
auto e = p->global_constant_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -47,7 +47,7 @@ TEST_F(ParserImplTest, GlobalConstantDecl_MissingEqual) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDecl_InvalidVariable) {
|
||||
auto p = parser("const a: invalid = 1.");
|
||||
auto* p = parser("const a: invalid = 1.");
|
||||
auto e = p->global_constant_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -55,7 +55,7 @@ TEST_F(ParserImplTest, GlobalConstantDecl_InvalidVariable) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDecl_InvalidExpression) {
|
||||
auto p = parser("const a: f32 = if (a) {}");
|
||||
auto* p = parser("const a: f32 = if (a) {}");
|
||||
auto e = p->global_constant_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -63,7 +63,7 @@ TEST_F(ParserImplTest, GlobalConstantDecl_InvalidExpression) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalConstantDecl_MissingExpression) {
|
||||
auto p = parser("const a: f32 =");
|
||||
auto* p = parser("const a: f32 =");
|
||||
auto e = p->global_constant_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
|
|
@ -22,18 +22,18 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_Semicolon) {
|
||||
auto p = parser(";");
|
||||
auto* p = parser(";");
|
||||
p->global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_Import) {
|
||||
auto p = parser(R"(import "GLSL.std.430" as glsl;)");
|
||||
auto* p = parser(R"(import "GLSL.std.430" as glsl;)");
|
||||
p->global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
auto m = p->module();
|
||||
ASSERT_EQ(1, m.imports().size());
|
||||
ASSERT_EQ(1u, m.imports().size());
|
||||
|
||||
const auto& import = m.imports()[0];
|
||||
EXPECT_EQ("GLSL.std.430", import->path());
|
||||
|
@ -41,7 +41,7 @@ TEST_F(ParserImplTest, GlobalDecl_Import) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_Import_Invalid) {
|
||||
auto p = parser(R"(import as glsl;)");
|
||||
auto* p = parser(R"(import as glsl;)");
|
||||
p->global_decl();
|
||||
|
||||
ASSERT_TRUE(p->has_error());
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ParserImplTest, GlobalDecl_Import_Invalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_Import_Invalid_MissingSemicolon) {
|
||||
auto p = parser(R"(import "GLSL.std.430" as glsl)");
|
||||
auto* p = parser(R"(import "GLSL.std.430" as glsl)");
|
||||
p->global_decl();
|
||||
|
||||
ASSERT_TRUE(p->has_error());
|
||||
|
@ -57,117 +57,117 @@ TEST_F(ParserImplTest, GlobalDecl_Import_Invalid_MissingSemicolon) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_GlobalVariable) {
|
||||
auto p = parser("var<out> a : vec2<i32> = vec2<i32>(1, 2);");
|
||||
auto* p = parser("var<out> a : vec2<i32> = vec2<i32>(1, 2);");
|
||||
p->global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
auto m = p->module();
|
||||
ASSERT_EQ(m.global_variables().size(), 1);
|
||||
ASSERT_EQ(m.global_variables().size(), 1u);
|
||||
|
||||
auto v = m.global_variables()[0].get();
|
||||
auto* v = m.global_variables()[0].get();
|
||||
EXPECT_EQ(v->name(), "a");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_GlobalVariable_Invalid) {
|
||||
auto p = parser("var<out> a : vec2<invalid>;");
|
||||
auto* p = parser("var<out> a : vec2<invalid>;");
|
||||
p->global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:19: unknown type alias 'invalid'");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_GlobalVariable_MissingSemicolon) {
|
||||
auto p = parser("var<out> a : vec2<i32>");
|
||||
auto* p = parser("var<out> a : vec2<i32>");
|
||||
p->global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:23: missing ';' for variable declaration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_GlobalConstant) {
|
||||
auto p = parser("const a : i32 = 2;");
|
||||
auto* p = parser("const a : i32 = 2;");
|
||||
p->global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
auto m = p->module();
|
||||
ASSERT_EQ(m.global_variables().size(), 1);
|
||||
ASSERT_EQ(m.global_variables().size(), 1u);
|
||||
|
||||
auto v = m.global_variables()[0].get();
|
||||
auto* v = m.global_variables()[0].get();
|
||||
EXPECT_EQ(v->name(), "a");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_GlobalConstant_Invalid) {
|
||||
auto p = parser("const a : vec2<i32>;");
|
||||
auto* p = parser("const a : vec2<i32>;");
|
||||
p->global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:20: missing = for const declaration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_GlobalConstant_MissingSemicolon) {
|
||||
auto p = parser("const a : vec2<i32> = vec2<i32>(1, 2)");
|
||||
auto* p = parser("const a : vec2<i32> = vec2<i32>(1, 2)");
|
||||
p->global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:38: missing ';' for constant declaration");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_EntryPoint) {
|
||||
auto p = parser("entry_point vertex = main;");
|
||||
auto* p = parser("entry_point vertex = main;");
|
||||
p->global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
auto m = p->module();
|
||||
ASSERT_EQ(m.entry_points().size(), 1);
|
||||
ASSERT_EQ(m.entry_points().size(), 1u);
|
||||
EXPECT_EQ(m.entry_points()[0]->name(), "main");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_EntryPoint_Invalid) {
|
||||
auto p = parser("entry_point main;");
|
||||
auto* p = parser("entry_point main;");
|
||||
p->global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:13: missing pipeline stage for entry point");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_EntryPoint_MissingSemicolon) {
|
||||
auto p = parser("entry_point vertex = main");
|
||||
auto* p = parser("entry_point vertex = main");
|
||||
p->global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:26: missing ';' for entry point");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_TypeAlias) {
|
||||
auto p = parser("type A = i32;");
|
||||
auto* p = parser("type A = i32;");
|
||||
p->global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
auto m = p->module();
|
||||
ASSERT_EQ(m.alias_types().size(), 1);
|
||||
ASSERT_EQ(m.alias_types().size(), 1u);
|
||||
EXPECT_EQ(m.alias_types()[0]->name(), "A");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_TypeAlias_Invalid) {
|
||||
auto p = parser("type A = invalid;");
|
||||
auto* p = parser("type A = invalid;");
|
||||
p->global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:10: unknown type alias 'invalid'");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_TypeAlias_MissingSemicolon) {
|
||||
auto p = parser("type A = i32");
|
||||
auto* p = parser("type A = i32");
|
||||
p->global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:13: missing ';' for type alias");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_Function) {
|
||||
auto p = parser("fn main() -> void { return; }");
|
||||
auto* p = parser("fn main() -> void { return; }");
|
||||
p->global_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
||||
auto m = p->module();
|
||||
ASSERT_EQ(m.functions().size(), 1);
|
||||
ASSERT_EQ(m.functions().size(), 1u);
|
||||
EXPECT_EQ(m.functions()[0]->name(), "main");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalDecl_Function_Invalid) {
|
||||
auto p = parser("fn main() -> { return; }");
|
||||
auto* p = parser("fn main() -> { return; }");
|
||||
p->global_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:14: unable to determine function return type");
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithoutConstructor) {
|
||||
auto p = parser("var<out> a : f32");
|
||||
auto* p = parser("var<out> a : f32");
|
||||
auto e = p->global_variable_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -38,7 +38,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithoutConstructor) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithConstructor) {
|
||||
auto p = parser("var<out> a : f32 = 1.");
|
||||
auto* p = parser("var<out> a : f32 = 1.");
|
||||
auto e = p->global_variable_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -55,7 +55,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithConstructor) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration) {
|
||||
auto p = parser("[[binding 2, set 1]] var<out> a : f32");
|
||||
auto* p = parser("[[binding 2, set 1]] var<out> a : f32");
|
||||
auto e = p->global_variable_decl();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -69,16 +69,16 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration) {
|
|||
ASSERT_EQ(e->constructor(), nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsDecorated());
|
||||
auto v = e->AsDecorated();
|
||||
auto* v = e->AsDecorated();
|
||||
|
||||
auto& decos = v->decorations();
|
||||
ASSERT_EQ(decos.size(), 2);
|
||||
ASSERT_EQ(decos.size(), 2u);
|
||||
ASSERT_TRUE(decos[0]->IsBinding());
|
||||
ASSERT_TRUE(decos[1]->IsSet());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_InvalidDecoration) {
|
||||
auto p = parser("[[binding]] var<out> a : f32");
|
||||
auto* p = parser("[[binding]] var<out> a : f32");
|
||||
auto e = p->global_variable_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -86,7 +86,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_InvalidDecoration) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_InvalidConstExpr) {
|
||||
auto p = parser("var<out> a : f32 = if (a) {}");
|
||||
auto* p = parser("var<out> a : f32 = if (a) {}");
|
||||
auto e = p->global_variable_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -94,7 +94,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_InvalidConstExpr) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, GlobalVariableDecl_InvalidVariableDecl) {
|
||||
auto p = parser("var<invalid> a : f32;");
|
||||
auto* p = parser("var<invalid> a : f32;");
|
||||
auto e = p->global_variable_decl();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt) {
|
||||
auto p = parser("if (a == 4) { a = b; c = d; }");
|
||||
auto* p = parser("if (a == 4) { a = b; c = d; }");
|
||||
auto e = p->if_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -32,12 +32,13 @@ TEST_F(ParserImplTest, IfStmt) {
|
|||
ASSERT_TRUE(e->IsIf());
|
||||
ASSERT_NE(e->condition(), nullptr);
|
||||
ASSERT_TRUE(e->condition()->IsBinary());
|
||||
EXPECT_EQ(e->body().size(), 2);
|
||||
EXPECT_EQ(e->else_statements().size(), 0);
|
||||
EXPECT_EQ(e->body().size(), 2u);
|
||||
EXPECT_EQ(e->else_statements().size(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt_WithElse) {
|
||||
auto p = parser("if (a == 4) { a = b; c = d; } elseif(c) { d = 2; } else {}");
|
||||
auto* p =
|
||||
parser("if (a == 4) { a = b; c = d; } elseif(c) { d = 2; } else {}");
|
||||
auto e = p->if_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -45,19 +46,19 @@ TEST_F(ParserImplTest, IfStmt_WithElse) {
|
|||
ASSERT_TRUE(e->IsIf());
|
||||
ASSERT_NE(e->condition(), nullptr);
|
||||
ASSERT_TRUE(e->condition()->IsBinary());
|
||||
EXPECT_EQ(e->body().size(), 2);
|
||||
EXPECT_EQ(e->body().size(), 2u);
|
||||
|
||||
ASSERT_EQ(e->else_statements().size(), 2);
|
||||
ASSERT_EQ(e->else_statements().size(), 2u);
|
||||
ASSERT_NE(e->else_statements()[0]->condition(), nullptr);
|
||||
ASSERT_TRUE(e->else_statements()[0]->condition()->IsIdentifier());
|
||||
EXPECT_EQ(e->else_statements()[0]->body().size(), 1);
|
||||
EXPECT_EQ(e->else_statements()[0]->body().size(), 1u);
|
||||
|
||||
ASSERT_EQ(e->else_statements()[1]->condition(), nullptr);
|
||||
EXPECT_EQ(e->else_statements()[1]->body().size(), 0);
|
||||
EXPECT_EQ(e->else_statements()[1]->body().size(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt_InvalidCondition) {
|
||||
auto p = parser("if (a = 3) {}");
|
||||
auto* p = parser("if (a = 3) {}");
|
||||
auto e = p->if_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -65,7 +66,7 @@ TEST_F(ParserImplTest, IfStmt_InvalidCondition) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt_MissingCondition) {
|
||||
auto p = parser("if {}");
|
||||
auto* p = parser("if {}");
|
||||
auto e = p->if_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -73,7 +74,7 @@ TEST_F(ParserImplTest, IfStmt_MissingCondition) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt_InvalidBody) {
|
||||
auto p = parser("if (a) { fn main() -> void {}}");
|
||||
auto* p = parser("if (a) { fn main() -> void {}}");
|
||||
auto e = p->if_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -81,7 +82,7 @@ TEST_F(ParserImplTest, IfStmt_InvalidBody) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt_MissingBody) {
|
||||
auto p = parser("if (a)");
|
||||
auto* p = parser("if (a)");
|
||||
auto e = p->if_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -89,7 +90,7 @@ TEST_F(ParserImplTest, IfStmt_MissingBody) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt_InvalidElseif) {
|
||||
auto p = parser("if (a) {} elseif (a) { fn main() -> a{}}");
|
||||
auto* p = parser("if (a) {} elseif (a) { fn main() -> a{}}");
|
||||
auto e = p->if_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -97,7 +98,7 @@ TEST_F(ParserImplTest, IfStmt_InvalidElseif) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, IfStmt_InvalidElse) {
|
||||
auto p = parser("if (a) {} else { fn main() -> a{}}");
|
||||
auto* p = parser("if (a) {} else { fn main() -> a{}}");
|
||||
auto e = p->if_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ImportDecl_Import) {
|
||||
auto p = parser(R"(import "GLSL.std.450" as glsl)");
|
||||
auto* p = parser(R"(import "GLSL.std.450" as glsl)");
|
||||
|
||||
auto import = p->import_decl();
|
||||
ASSERT_NE(import, nullptr);
|
||||
|
@ -30,12 +30,12 @@ TEST_F(ParserImplTest, ImportDecl_Import) {
|
|||
|
||||
EXPECT_EQ("GLSL.std.450", import->path());
|
||||
EXPECT_EQ("glsl", import->name());
|
||||
EXPECT_EQ(1, import->line());
|
||||
EXPECT_EQ(1, import->column());
|
||||
EXPECT_EQ(1u, import->line());
|
||||
EXPECT_EQ(1u, import->column());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImportDecl_Import_WithNamespace) {
|
||||
auto p = parser(R"(import "GLSL.std.450" as std::glsl)");
|
||||
auto* p = parser(R"(import "GLSL.std.450" as std::glsl)");
|
||||
auto import = p->import_decl();
|
||||
ASSERT_NE(import, nullptr);
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
|
@ -43,7 +43,7 @@ TEST_F(ParserImplTest, ImportDecl_Import_WithNamespace) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImportDecl_Invalid_MissingPath) {
|
||||
auto p = parser(R"(import as glsl)");
|
||||
auto* p = parser(R"(import as glsl)");
|
||||
auto import = p->import_decl();
|
||||
ASSERT_EQ(import, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
|
@ -51,7 +51,7 @@ TEST_F(ParserImplTest, ImportDecl_Invalid_MissingPath) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImportDecl_Invalid_EmptyPath) {
|
||||
auto p = parser(R"(import "" as glsl)");
|
||||
auto* p = parser(R"(import "" as glsl)");
|
||||
auto import = p->import_decl();
|
||||
ASSERT_EQ(import, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
|
@ -59,7 +59,7 @@ TEST_F(ParserImplTest, ImportDecl_Invalid_EmptyPath) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImportDecl_Invalid_NameMissingTerminatingIdentifier) {
|
||||
auto p = parser(R"(import "GLSL.std.450" as glsl::)");
|
||||
auto* p = parser(R"(import "GLSL.std.450" as glsl::)");
|
||||
auto import = p->import_decl();
|
||||
ASSERT_EQ(import, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
|
@ -67,7 +67,7 @@ TEST_F(ParserImplTest, ImportDecl_Invalid_NameMissingTerminatingIdentifier) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImportDecl_Invalid_NameInvalid) {
|
||||
auto p = parser(R"(import "GLSL.std.450" as 12glsl)");
|
||||
auto* p = parser(R"(import "GLSL.std.450" as 12glsl)");
|
||||
auto import = p->import_decl();
|
||||
ASSERT_EQ(import, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
|
@ -75,7 +75,7 @@ TEST_F(ParserImplTest, ImportDecl_Invalid_NameInvalid) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImportDecl_Invalid_MissingName) {
|
||||
auto p = parser(R"(import "GLSL.std.450" as)");
|
||||
auto* p = parser(R"(import "GLSL.std.450" as)");
|
||||
auto import = p->import_decl();
|
||||
ASSERT_EQ(import, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
|
@ -83,7 +83,7 @@ TEST_F(ParserImplTest, ImportDecl_Invalid_MissingName) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ImportDecl_Invalid_MissingAs) {
|
||||
auto p = parser(R"(import "GLSL.std.450" glsl)");
|
||||
auto* p = parser(R"(import "GLSL.std.450" glsl)");
|
||||
auto import = p->import_decl();
|
||||
ASSERT_EQ(import, nullptr);
|
||||
ASSERT_TRUE(p->has_error());
|
||||
|
|
|
@ -26,36 +26,36 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, InclusiveOrExpression_Parses) {
|
||||
auto p = parser("a | true");
|
||||
auto* p = parser("a | true");
|
||||
auto e = p->inclusive_or_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kOr, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, InclusiveOrExpression_InvalidLHS) {
|
||||
auto p = parser("if (a) {} | true");
|
||||
auto* p = parser("if (a) {} | true");
|
||||
auto e = p->inclusive_or_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, InclusiveOrExpression_InvalidRHS) {
|
||||
auto p = parser("true | if (a) {}");
|
||||
auto* p = parser("true | if (a) {}");
|
||||
auto e = p->inclusive_or_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -63,7 +63,7 @@ TEST_F(ParserImplTest, InclusiveOrExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, InclusiveOrExpression_NoOr_ReturnsLHS) {
|
||||
auto p = parser("a true");
|
||||
auto* p = parser("a true");
|
||||
auto e = p->inclusive_or_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
|
|
@ -26,36 +26,36 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, LogicalAndExpression_Parses) {
|
||||
auto p = parser("a && true");
|
||||
auto* p = parser("a && true");
|
||||
auto e = p->logical_and_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kLogicalAnd, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, LogicalAndExpression_InvalidLHS) {
|
||||
auto p = parser("if (a) {} && true");
|
||||
auto* p = parser("if (a) {} && true");
|
||||
auto e = p->logical_and_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, LogicalAndExpression_InvalidRHS) {
|
||||
auto p = parser("true && if (a) {}");
|
||||
auto* p = parser("true && if (a) {}");
|
||||
auto e = p->logical_and_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -63,7 +63,7 @@ TEST_F(ParserImplTest, LogicalAndExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LogicalAndExpression_NoOr_ReturnsLHS) {
|
||||
auto p = parser("a true");
|
||||
auto* p = parser("a true");
|
||||
auto e = p->logical_and_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
|
|
@ -26,36 +26,36 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, LogicalOrExpression_Parses) {
|
||||
auto p = parser("a || true");
|
||||
auto* p = parser("a || true");
|
||||
auto e = p->logical_or_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kLogicalOr, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, LogicalOrExpression_InvalidLHS) {
|
||||
auto p = parser("if (a) {} || true");
|
||||
auto* p = parser("if (a) {} || true");
|
||||
auto e = p->logical_or_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, LogicalOrExpression_InvalidRHS) {
|
||||
auto p = parser("true || if (a) {}");
|
||||
auto* p = parser("true || if (a) {}");
|
||||
auto e = p->logical_or_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -63,7 +63,7 @@ TEST_F(ParserImplTest, LogicalOrExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LogicalOrExpression_NoOr_ReturnsLHS) {
|
||||
auto p = parser("a true");
|
||||
auto* p = parser("a true");
|
||||
auto e = p->logical_or_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
|
|
@ -22,51 +22,51 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_BodyNoContinuing) {
|
||||
auto p = parser("loop { nop; }");
|
||||
auto* p = parser("loop { nop; }");
|
||||
auto e = p->loop_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_EQ(e->body().size(), 1);
|
||||
ASSERT_EQ(e->body().size(), 1u);
|
||||
EXPECT_TRUE(e->body()[0]->IsNop());
|
||||
|
||||
EXPECT_EQ(e->continuing().size(), 0);
|
||||
EXPECT_EQ(e->continuing().size(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_BodyWithContinuing) {
|
||||
auto p = parser("loop { nop; continuing { kill; }}");
|
||||
auto* p = parser("loop { nop; continuing { kill; }}");
|
||||
auto e = p->loop_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_EQ(e->body().size(), 1);
|
||||
ASSERT_EQ(e->body().size(), 1u);
|
||||
EXPECT_TRUE(e->body()[0]->IsNop());
|
||||
|
||||
EXPECT_EQ(e->continuing().size(), 1);
|
||||
EXPECT_EQ(e->continuing().size(), 1u);
|
||||
EXPECT_TRUE(e->continuing()[0]->IsKill());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_NoBodyNoContinuing) {
|
||||
auto p = parser("loop { }");
|
||||
auto* p = parser("loop { }");
|
||||
auto e = p->loop_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
ASSERT_EQ(e->body().size(), 0);
|
||||
ASSERT_EQ(e->continuing().size(), 0);
|
||||
ASSERT_EQ(e->body().size(), 0u);
|
||||
ASSERT_EQ(e->continuing().size(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_NoBodyWithContinuing) {
|
||||
auto p = parser("loop { continuing { kill; }}");
|
||||
auto* p = parser("loop { continuing { kill; }}");
|
||||
auto e = p->loop_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
ASSERT_EQ(e->body().size(), 0);
|
||||
ASSERT_EQ(e->continuing().size(), 1);
|
||||
ASSERT_EQ(e->body().size(), 0u);
|
||||
ASSERT_EQ(e->continuing().size(), 1u);
|
||||
EXPECT_TRUE(e->continuing()[0]->IsKill());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_MissingBracketLeft) {
|
||||
auto p = parser("loop kill; }");
|
||||
auto* p = parser("loop kill; }");
|
||||
auto e = p->loop_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -74,7 +74,7 @@ TEST_F(ParserImplTest, LoopStmt_MissingBracketLeft) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_MissingBracketRight) {
|
||||
auto p = parser("loop { kill; ");
|
||||
auto* p = parser("loop { kill; ");
|
||||
auto e = p->loop_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -82,7 +82,7 @@ TEST_F(ParserImplTest, LoopStmt_MissingBracketRight) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_InvalidStatements) {
|
||||
auto p = parser("loop { kill }");
|
||||
auto* p = parser("loop { kill }");
|
||||
auto e = p->loop_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -90,7 +90,7 @@ TEST_F(ParserImplTest, LoopStmt_InvalidStatements) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, LoopStmt_InvalidContinuing) {
|
||||
auto p = parser("loop { continuing { kill }}");
|
||||
auto* p = parser("loop { continuing { kill }}");
|
||||
auto e = p->loop_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
|
|
@ -26,80 +26,80 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Multiply) {
|
||||
auto p = parser("a * true");
|
||||
auto* p = parser("a * true");
|
||||
auto e = p->multiplicative_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kMultiply, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Divide) {
|
||||
auto p = parser("a / true");
|
||||
auto* p = parser("a / true");
|
||||
auto e = p->multiplicative_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kDivide, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Modulo) {
|
||||
auto p = parser("a % true");
|
||||
auto* p = parser("a % true");
|
||||
auto e = p->multiplicative_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kModulo, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, MultiplicativeExpression_InvalidLHS) {
|
||||
auto p = parser("if (a) {} * true");
|
||||
auto* p = parser("if (a) {} * true");
|
||||
auto e = p->multiplicative_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, MultiplicativeExpression_InvalidRHS) {
|
||||
auto p = parser("true * if (a) {}");
|
||||
auto* p = parser("true * if (a) {}");
|
||||
auto e = p->multiplicative_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -107,7 +107,7 @@ TEST_F(ParserImplTest, MultiplicativeExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, MultiplicativeExpression_NoOr_ReturnsLHS) {
|
||||
auto p = parser("a true");
|
||||
auto* p = parser("a true");
|
||||
auto e = p->multiplicative_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
|
|
@ -29,26 +29,26 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ParamList_Single) {
|
||||
auto i32 = tm()->Get(std::make_unique<ast::type::I32Type>());
|
||||
auto* i32 = tm()->Get(std::make_unique<ast::type::I32Type>());
|
||||
|
||||
auto p = parser("a : i32");
|
||||
auto* p = parser("a : i32");
|
||||
auto e = p->param_list();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_EQ(e.size(), 1);
|
||||
EXPECT_EQ(e.size(), 1u);
|
||||
|
||||
EXPECT_EQ(e[0]->name(), "a");
|
||||
EXPECT_EQ(e[0]->type(), i32);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ParamList_Multiple) {
|
||||
auto i32 = tm()->Get(std::make_unique<ast::type::I32Type>());
|
||||
auto f32 = tm()->Get(std::make_unique<ast::type::F32Type>());
|
||||
auto vec2 = tm()->Get(std::make_unique<ast::type::VectorType>(f32, 2));
|
||||
auto* i32 = tm()->Get(std::make_unique<ast::type::I32Type>());
|
||||
auto* f32 = tm()->Get(std::make_unique<ast::type::F32Type>());
|
||||
auto* vec2 = tm()->Get(std::make_unique<ast::type::VectorType>(f32, 2));
|
||||
|
||||
auto p = parser("a : i32, b: f32, c: vec2<f32>");
|
||||
auto* p = parser("a : i32, b: f32, c: vec2<f32>");
|
||||
auto e = p->param_list();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_EQ(e.size(), 3);
|
||||
EXPECT_EQ(e.size(), 3u);
|
||||
|
||||
EXPECT_EQ(e[0]->name(), "a");
|
||||
EXPECT_EQ(e[0]->type(), i32);
|
||||
|
@ -61,14 +61,14 @@ TEST_F(ParserImplTest, ParamList_Multiple) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ParamList_Empty) {
|
||||
auto p = parser("");
|
||||
auto* p = parser("");
|
||||
auto e = p->param_list();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
EXPECT_EQ(e.size(), 0);
|
||||
EXPECT_EQ(e.size(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ParamList_HangingComma) {
|
||||
auto p = parser("a : i32,");
|
||||
auto* p = parser("a : i32,");
|
||||
auto e = p->param_list();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
EXPECT_EQ(p->error(), "1:8: found , but no variable declaration");
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ParenRhsStmt) {
|
||||
auto p = parser("(a + b)");
|
||||
auto* p = parser("(a + b)");
|
||||
auto e = p->paren_rhs_stmt();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -30,7 +30,7 @@ TEST_F(ParserImplTest, ParenRhsStmt) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ParenRhsStmt_MissingLeftParen) {
|
||||
auto p = parser("true)");
|
||||
auto* p = parser("true)");
|
||||
auto e = p->paren_rhs_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -38,7 +38,7 @@ TEST_F(ParserImplTest, ParenRhsStmt_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ParenRhsStmt_MissingRightParen) {
|
||||
auto p = parser("(true");
|
||||
auto* p = parser("(true");
|
||||
auto e = p->paren_rhs_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -46,7 +46,7 @@ TEST_F(ParserImplTest, ParenRhsStmt_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ParenRhsStmt_InvalidExpression) {
|
||||
auto p = parser("(if (a() {})");
|
||||
auto* p = parser("(if (a() {})");
|
||||
auto e = p->paren_rhs_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -54,7 +54,7 @@ TEST_F(ParserImplTest, ParenRhsStmt_InvalidExpression) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, ParenRhsStmt_MissingExpression) {
|
||||
auto p = parser("()");
|
||||
auto* p = parser("()");
|
||||
auto e = p->paren_rhs_stmt();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
|
|
@ -36,9 +36,9 @@ class PipelineStageTest : public testing::TestWithParam<PipelineStageData> {
|
|||
PipelineStageTest() = default;
|
||||
~PipelineStageTest() = default;
|
||||
|
||||
void SetUp() { ctx_.Reset(); }
|
||||
void SetUp() override { ctx_.Reset(); }
|
||||
|
||||
void TearDown() { impl_ = nullptr; }
|
||||
void TearDown() override { impl_ = nullptr; }
|
||||
|
||||
ParserImpl* parser(const std::string& str) {
|
||||
impl_ = std::make_unique<ParserImpl>(&ctx_, str);
|
||||
|
@ -52,7 +52,7 @@ class PipelineStageTest : public testing::TestWithParam<PipelineStageData> {
|
|||
|
||||
TEST_P(PipelineStageTest, Parses) {
|
||||
auto params = GetParam();
|
||||
auto p = parser(params.input);
|
||||
auto* p = parser(params.input);
|
||||
|
||||
auto stage = p->pipeline_stage();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
|
@ -70,7 +70,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
PipelineStageData{"compute", ast::PipelineStage::kCompute}));
|
||||
|
||||
TEST_F(ParserImplTest, PipelineStage_NoMatch) {
|
||||
auto p = parser("not-a-stage");
|
||||
auto* p = parser("not-a-stage");
|
||||
auto stage = p->pipeline_stage();
|
||||
ASSERT_EQ(stage, ast::PipelineStage::kNone);
|
||||
|
||||
|
|
|
@ -31,45 +31,45 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Array_ConstantIndex) {
|
||||
auto p = parser("a[1]");
|
||||
auto* p = parser("a[1]");
|
||||
auto e = p->postfix_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsArrayAccessor());
|
||||
auto ary = e->AsArrayAccessor();
|
||||
auto* ary = e->AsArrayAccessor();
|
||||
|
||||
ASSERT_TRUE(ary->array()->IsIdentifier());
|
||||
auto ident = ary->array()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = ary->array()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(ary->idx_expr()->IsConstructor());
|
||||
ASSERT_TRUE(ary->idx_expr()->AsConstructor()->IsScalarConstructor());
|
||||
auto c = ary->idx_expr()->AsConstructor()->AsScalarConstructor();
|
||||
auto* c = ary->idx_expr()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(c->literal()->IsInt());
|
||||
EXPECT_EQ(c->literal()->AsInt()->value(), 1);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Array_ExpressionIndex) {
|
||||
auto p = parser("a[1 + b / 4]");
|
||||
auto* p = parser("a[1 + b / 4]");
|
||||
auto e = p->postfix_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsArrayAccessor());
|
||||
auto ary = e->AsArrayAccessor();
|
||||
auto* ary = e->AsArrayAccessor();
|
||||
|
||||
ASSERT_TRUE(ary->array()->IsIdentifier());
|
||||
auto ident = ary->array()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = ary->array()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(ary->idx_expr()->IsBinary());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Array_MissingIndex) {
|
||||
auto p = parser("a[]");
|
||||
auto* p = parser("a[]");
|
||||
auto e = p->postfix_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -77,7 +77,7 @@ TEST_F(ParserImplTest, PostfixExpression_Array_MissingIndex) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Array_MissingRightBrace) {
|
||||
auto p = parser("a[1");
|
||||
auto* p = parser("a[1");
|
||||
auto e = p->postfix_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -85,7 +85,7 @@ TEST_F(ParserImplTest, PostfixExpression_Array_MissingRightBrace) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Array_InvalidIndex) {
|
||||
auto p = parser("a[if(a() {})]");
|
||||
auto* p = parser("a[if(a() {})]");
|
||||
auto e = p->postfix_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -93,45 +93,45 @@ TEST_F(ParserImplTest, PostfixExpression_Array_InvalidIndex) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Call_Empty) {
|
||||
auto p = parser("a()");
|
||||
auto* p = parser("a()");
|
||||
auto e = p->postfix_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsCall());
|
||||
auto c = e->AsCall();
|
||||
auto* c = e->AsCall();
|
||||
|
||||
ASSERT_TRUE(c->func()->IsIdentifier());
|
||||
auto func = c->func()->AsIdentifier();
|
||||
ASSERT_EQ(func->name().size(), 1);
|
||||
auto* func = c->func()->AsIdentifier();
|
||||
ASSERT_EQ(func->name().size(), 1u);
|
||||
EXPECT_EQ(func->name()[0], "a");
|
||||
|
||||
EXPECT_EQ(c->params().size(), 0);
|
||||
EXPECT_EQ(c->params().size(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Call_WithArgs) {
|
||||
auto p = parser("std::test(1, b, 2 + 3 / b)");
|
||||
auto* p = parser("std::test(1, b, 2 + 3 / b)");
|
||||
auto e = p->postfix_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsCall());
|
||||
auto c = e->AsCall();
|
||||
auto* c = e->AsCall();
|
||||
|
||||
ASSERT_TRUE(c->func()->IsIdentifier());
|
||||
auto func = c->func()->AsIdentifier();
|
||||
ASSERT_EQ(func->name().size(), 2);
|
||||
auto* func = c->func()->AsIdentifier();
|
||||
ASSERT_EQ(func->name().size(), 2u);
|
||||
EXPECT_EQ(func->name()[0], "std");
|
||||
EXPECT_EQ(func->name()[1], "test");
|
||||
|
||||
EXPECT_EQ(c->params().size(), 3);
|
||||
EXPECT_EQ(c->params().size(), 3u);
|
||||
EXPECT_TRUE(c->params()[0]->IsConstructor());
|
||||
EXPECT_TRUE(c->params()[1]->IsIdentifier());
|
||||
EXPECT_TRUE(c->params()[2]->IsBinary());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Call_InvalidArg) {
|
||||
auto p = parser("a(if(a) {})");
|
||||
auto* p = parser("a(if(a) {})");
|
||||
auto e = p->postfix_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -139,7 +139,7 @@ TEST_F(ParserImplTest, PostfixExpression_Call_InvalidArg) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Call_HangingComma) {
|
||||
auto p = parser("a(b, )");
|
||||
auto* p = parser("a(b, )");
|
||||
auto e = p->postfix_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -147,7 +147,7 @@ TEST_F(ParserImplTest, PostfixExpression_Call_HangingComma) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_Call_MissingRightParen) {
|
||||
auto p = parser("a(");
|
||||
auto* p = parser("a(");
|
||||
auto e = p->postfix_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -155,24 +155,24 @@ TEST_F(ParserImplTest, PostfixExpression_Call_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_MemberAccessor) {
|
||||
auto p = parser("a.b");
|
||||
auto* p = parser("a.b");
|
||||
auto e = p->postfix_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
ASSERT_TRUE(e->IsMemberAccessor());
|
||||
|
||||
auto m = e->AsMemberAccessor();
|
||||
auto* m = e->AsMemberAccessor();
|
||||
ASSERT_TRUE(m->structure()->IsIdentifier());
|
||||
ASSERT_EQ(m->structure()->AsIdentifier()->name().size(), 1);
|
||||
ASSERT_EQ(m->structure()->AsIdentifier()->name().size(), 1u);
|
||||
EXPECT_EQ(m->structure()->AsIdentifier()->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(m->member()->IsIdentifier());
|
||||
ASSERT_EQ(m->member()->AsIdentifier()->name().size(), 1);
|
||||
ASSERT_EQ(m->member()->AsIdentifier()->name().size(), 1u);
|
||||
EXPECT_EQ(m->member()->AsIdentifier()->name()[0], "b");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_MemberAccesssor_InvalidIdent) {
|
||||
auto p = parser("a.if");
|
||||
auto* p = parser("a.if");
|
||||
auto e = p->postfix_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -180,7 +180,7 @@ TEST_F(ParserImplTest, PostfixExpression_MemberAccesssor_InvalidIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_MemberAccessor_MissingIdent) {
|
||||
auto p = parser("a.");
|
||||
auto* p = parser("a.");
|
||||
auto e = p->postfix_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -188,7 +188,7 @@ TEST_F(ParserImplTest, PostfixExpression_MemberAccessor_MissingIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PostfixExpression_NonMatch_returnLHS) {
|
||||
auto p = parser("a b");
|
||||
auto* p = parser("a b");
|
||||
auto e = p->postfix_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
|
|
@ -36,24 +36,24 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Ident) {
|
||||
auto p = parser("a");
|
||||
auto* p = parser("a");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
ASSERT_TRUE(e->IsIdentifier());
|
||||
auto ident = e->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = e->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Ident_WithNamespace) {
|
||||
auto p = parser("a::b::c::d");
|
||||
auto* p = parser("a::b::c::d");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
ASSERT_TRUE(e->IsIdentifier());
|
||||
auto ident = e->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 4);
|
||||
auto* ident = e->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 4u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
EXPECT_EQ(ident->name()[1], "b");
|
||||
EXPECT_EQ(ident->name()[2], "c");
|
||||
|
@ -61,7 +61,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Ident_WithNamespace) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Ident_MissingIdent) {
|
||||
auto p = parser("a::");
|
||||
auto* p = parser("a::");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -69,19 +69,19 @@ TEST_F(ParserImplTest, PrimaryExpression_Ident_MissingIdent) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl) {
|
||||
auto p = parser("vec4<i32>(1, 2, 3, 4))");
|
||||
auto* p = parser("vec4<i32>(1, 2, 3, 4))");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
ASSERT_TRUE(e->IsConstructor());
|
||||
ASSERT_TRUE(e->AsConstructor()->IsTypeConstructor());
|
||||
auto ty = e->AsConstructor()->AsTypeConstructor();
|
||||
auto* ty = e->AsConstructor()->AsTypeConstructor();
|
||||
|
||||
ASSERT_EQ(ty->values().size(), 4);
|
||||
ASSERT_EQ(ty->values().size(), 4u);
|
||||
const auto& val = ty->values();
|
||||
ASSERT_TRUE(val[0]->IsConstructor());
|
||||
ASSERT_TRUE(val[0]->AsConstructor()->IsScalarConstructor());
|
||||
auto ident = val[0]->AsConstructor()->AsScalarConstructor();
|
||||
auto* ident = val[0]->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(ident->literal()->IsInt());
|
||||
EXPECT_EQ(ident->literal()->AsInt()->value(), 1);
|
||||
|
||||
|
@ -105,7 +105,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_InvalidTypeDecl) {
|
||||
auto p = parser("vec4<if>(2., 3., 4., 5.)");
|
||||
auto* p = parser("vec4<if>(2., 3., 4., 5.)");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -113,7 +113,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_InvalidTypeDecl) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_MissingLeftParen) {
|
||||
auto p = parser("vec4<f32> 2., 3., 4., 5.)");
|
||||
auto* p = parser("vec4<f32> 2., 3., 4., 5.)");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -121,7 +121,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_MissingRightParen) {
|
||||
auto p = parser("vec4<f32>(2., 3., 4., 5.");
|
||||
auto* p = parser("vec4<f32>(2., 3., 4., 5.");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -129,7 +129,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_InvalidValue) {
|
||||
auto p = parser("i32(if(a) {})");
|
||||
auto* p = parser("i32(if(a) {})");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -137,19 +137,19 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_InvalidValue) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_ConstLiteral_True) {
|
||||
auto p = parser("true");
|
||||
auto* p = parser("true");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_FALSE(p->has_error());
|
||||
ASSERT_NE(e, nullptr);
|
||||
ASSERT_TRUE(e->IsConstructor());
|
||||
ASSERT_TRUE(e->AsConstructor()->IsScalarConstructor());
|
||||
auto init = e->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = e->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
EXPECT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_ParenExpr) {
|
||||
auto p = parser("(a == b)");
|
||||
auto* p = parser("(a == b)");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
@ -157,7 +157,7 @@ TEST_F(ParserImplTest, PrimaryExpression_ParenExpr) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_ParenExpr_MissingRightParen) {
|
||||
auto p = parser("(a == b");
|
||||
auto* p = parser("(a == b");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -165,7 +165,7 @@ TEST_F(ParserImplTest, PrimaryExpression_ParenExpr_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_ParenExpr_MissingExpr) {
|
||||
auto p = parser("()");
|
||||
auto* p = parser("()");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -173,7 +173,7 @@ TEST_F(ParserImplTest, PrimaryExpression_ParenExpr_MissingExpr) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_ParenExpr_InvalidExpr) {
|
||||
auto p = parser("(if (a) {})");
|
||||
auto* p = parser("(if (a) {})");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -181,15 +181,15 @@ TEST_F(ParserImplTest, PrimaryExpression_ParenExpr_InvalidExpr) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Cast) {
|
||||
auto f32_type = tm()->Get(std::make_unique<ast::type::F32Type>());
|
||||
auto* f32_type = tm()->Get(std::make_unique<ast::type::F32Type>());
|
||||
|
||||
auto p = parser("cast<f32>(1)");
|
||||
auto* p = parser("cast<f32>(1)");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
ASSERT_TRUE(e->IsCast());
|
||||
|
||||
auto c = e->AsCast();
|
||||
auto* c = e->AsCast();
|
||||
ASSERT_EQ(c->type(), f32_type);
|
||||
|
||||
ASSERT_TRUE(c->expr()->IsConstructor());
|
||||
|
@ -197,7 +197,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Cast_MissingGreaterThan) {
|
||||
auto p = parser("cast<f32(1)");
|
||||
auto* p = parser("cast<f32(1)");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -205,7 +205,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast_MissingGreaterThan) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Cast_MissingType) {
|
||||
auto p = parser("cast<>(1)");
|
||||
auto* p = parser("cast<>(1)");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -213,7 +213,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast_MissingType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Cast_InvalidType) {
|
||||
auto p = parser("cast<invalid>(1)");
|
||||
auto* p = parser("cast<invalid>(1)");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -221,7 +221,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast_InvalidType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Cast_MissingLeftParen) {
|
||||
auto p = parser("cast<f32>1)");
|
||||
auto* p = parser("cast<f32>1)");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -229,7 +229,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Cast_MissingRightParen) {
|
||||
auto p = parser("cast<f32>(1");
|
||||
auto* p = parser("cast<f32>(1");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -237,7 +237,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Cast_MissingExpression) {
|
||||
auto p = parser("cast<f32>()");
|
||||
auto* p = parser("cast<f32>()");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -245,7 +245,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast_MissingExpression) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_Cast_InvalidExpression) {
|
||||
auto p = parser("cast<f32>(if (a) {})");
|
||||
auto* p = parser("cast<f32>(if (a) {})");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -253,15 +253,15 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast_InvalidExpression) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_As) {
|
||||
auto f32_type = tm()->Get(std::make_unique<ast::type::F32Type>());
|
||||
auto* f32_type = tm()->Get(std::make_unique<ast::type::F32Type>());
|
||||
|
||||
auto p = parser("as<f32>(1)");
|
||||
auto* p = parser("as<f32>(1)");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
ASSERT_TRUE(e->IsAs());
|
||||
|
||||
auto c = e->AsAs();
|
||||
auto* c = e->AsAs();
|
||||
ASSERT_EQ(c->type(), f32_type);
|
||||
|
||||
ASSERT_TRUE(c->expr()->IsConstructor());
|
||||
|
@ -269,7 +269,7 @@ TEST_F(ParserImplTest, PrimaryExpression_As) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_As_MissingGreaterThan) {
|
||||
auto p = parser("as<f32(1)");
|
||||
auto* p = parser("as<f32(1)");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -277,7 +277,7 @@ TEST_F(ParserImplTest, PrimaryExpression_As_MissingGreaterThan) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_As_MissingType) {
|
||||
auto p = parser("as<>(1)");
|
||||
auto* p = parser("as<>(1)");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -285,7 +285,7 @@ TEST_F(ParserImplTest, PrimaryExpression_As_MissingType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_As_InvalidType) {
|
||||
auto p = parser("as<invalid>(1)");
|
||||
auto* p = parser("as<invalid>(1)");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -293,7 +293,7 @@ TEST_F(ParserImplTest, PrimaryExpression_As_InvalidType) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_As_MissingLeftParen) {
|
||||
auto p = parser("as<f32>1)");
|
||||
auto* p = parser("as<f32>1)");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -301,7 +301,7 @@ TEST_F(ParserImplTest, PrimaryExpression_As_MissingLeftParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_As_MissingRightParen) {
|
||||
auto p = parser("as<f32>(1");
|
||||
auto* p = parser("as<f32>(1");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -309,7 +309,7 @@ TEST_F(ParserImplTest, PrimaryExpression_As_MissingRightParen) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_As_MissingExpression) {
|
||||
auto p = parser("as<f32>()");
|
||||
auto* p = parser("as<f32>()");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -317,7 +317,7 @@ TEST_F(ParserImplTest, PrimaryExpression_As_MissingExpression) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, PrimaryExpression_As_InvalidExpression) {
|
||||
auto p = parser("as<f32>(if (a) {})");
|
||||
auto* p = parser("as<f32>(if (a) {})");
|
||||
auto e = p->primary_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
|
|
@ -26,102 +26,102 @@ namespace wgsl {
|
|||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, RelationalExpression_Parses_LessThan) {
|
||||
auto p = parser("a < true");
|
||||
auto* p = parser("a < true");
|
||||
auto e = p->relational_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kLessThan, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, RelationalExpression_Parses_GreaterThan) {
|
||||
auto p = parser("a > true");
|
||||
auto* p = parser("a > true");
|
||||
auto e = p->relational_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kGreaterThan, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, RelationalExpression_Parses_LessThanEqual) {
|
||||
auto p = parser("a <= true");
|
||||
auto* p = parser("a <= true");
|
||||
auto e = p->relational_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kLessThanEqual, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, RelationalExpression_Parses_GreaterThanEqual) {
|
||||
auto p = parser("a >= true");
|
||||
auto* p = parser("a >= true");
|
||||
auto e = p->relational_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
||||
ASSERT_TRUE(e->IsBinary());
|
||||
auto rel = e->AsBinary();
|
||||
auto* rel = e->AsBinary();
|
||||
EXPECT_EQ(ast::BinaryOp::kGreaterThanEqual, rel->op());
|
||||
|
||||
ASSERT_TRUE(rel->lhs()->IsIdentifier());
|
||||
auto ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1);
|
||||
auto* ident = rel->lhs()->AsIdentifier();
|
||||
ASSERT_EQ(ident->name().size(), 1u);
|
||||
EXPECT_EQ(ident->name()[0], "a");
|
||||
|
||||
ASSERT_TRUE(rel->rhs()->IsConstructor());
|
||||
ASSERT_TRUE(rel->rhs()->AsConstructor()->IsScalarConstructor());
|
||||
auto init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
auto* init = rel->rhs()->AsConstructor()->AsScalarConstructor();
|
||||
ASSERT_TRUE(init->literal()->IsBool());
|
||||
ASSERT_TRUE(init->literal()->AsBool()->IsTrue());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, RelationalExpression_InvalidLHS) {
|
||||
auto p = parser("if (a) {} < true");
|
||||
auto* p = parser("if (a) {} < true");
|
||||
auto e = p->relational_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_EQ(e, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, RelationalExpression_InvalidRHS) {
|
||||
auto p = parser("true < if (a) {}");
|
||||
auto* p = parser("true < if (a) {}");
|
||||
auto e = p->relational_expression();
|
||||
ASSERT_TRUE(p->has_error());
|
||||
ASSERT_EQ(e, nullptr);
|
||||
|
@ -129,7 +129,7 @@ TEST_F(ParserImplTest, RelationalExpression_InvalidRHS) {
|
|||
}
|
||||
|
||||
TEST_F(ParserImplTest, RelationalExpression_NoOr_ReturnsLHS) {
|
||||
auto p = parser("a true");
|
||||
auto* p = parser("a true");
|
||||
auto e = p->relational_expression();
|
||||
ASSERT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e, nullptr);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue