Fill in some disabled tests

This CL completes a few of the DISABLED tests.

Change-Id: I38806fb9381240d6e3da700f1fb2dac5f899ca6d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19000
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
dan sinclair 2020-04-07 19:27:49 +00:00
parent 1c9b486d6e
commit 0e9d9ed60f
4 changed files with 28 additions and 11 deletions

View File

@ -28,12 +28,13 @@ TEST_F(ParserImplTest, Empty) {
ASSERT_TRUE(p->Parse()) << p->error();
}
TEST_F(ParserImplTest, DISABLED_Parses) {
TEST_F(ParserImplTest, Parses) {
auto p = parser(R"(
import "GLSL.std.430" as glsl;
[[location 0]] var<out> gl_FragColor : vec4<f32>;
entry_point vertex = main;
fn main() -> void {
gl_FragColor = vec4<f32>(.4, .2, .3, 1);
}
@ -42,11 +43,12 @@ fn main() -> void {
auto m = p->module();
ASSERT_EQ(1, m.imports().size());
// TODO(dsinclair) check rest of AST ...
ASSERT_EQ(1, m.entry_points().size());
ASSERT_EQ(1, m.functions().size());
ASSERT_EQ(1, m.global_variables().size());
}
TEST_F(ParserImplTest, DISABLED_HandlesError) {
TEST_F(ParserImplTest, HandlesError) {
auto p = parser(R"(
import "GLSL.std.430" as glsl;
@ -56,7 +58,7 @@ fn main() -> { # missing return type
ASSERT_FALSE(p->Parse());
ASSERT_TRUE(p->has_error());
EXPECT_EQ(p->error(), "4:15: missing return type for function");
EXPECT_EQ(p->error(), "4:15: unable to determine function return type");
}
TEST_F(ParserImplTest, GetRegisteredType) {

View File

@ -30,7 +30,7 @@ TEST_F(ParserTest, Empty) {
ASSERT_TRUE(p.Parse()) << p.error();
}
TEST_F(ParserTest, DISABLED_Parses) {
TEST_F(ParserTest, Parses) {
Context ctx;
Parser p(&ctx, R"(
@ -38,6 +38,7 @@ import "GLSL.std.430" as glsl;
[[location 0]] var<out> gl_FragColor : vec4<f32>;
entry_point vertex = main;
fn main() -> void {
gl_FragColor = vec4<f32>(.4, .2, .3, 1);
}
@ -46,11 +47,12 @@ fn main() -> void {
auto m = p.module();
ASSERT_EQ(1, m.imports().size());
// TODO(dsinclair) check rest of AST ...
ASSERT_EQ(1, m.entry_points().size());
ASSERT_EQ(1, m.functions().size());
ASSERT_EQ(1, m.global_variables().size());
}
TEST_F(ParserTest, DISABLED_HandlesError) {
TEST_F(ParserTest, HandlesError) {
Context ctx;
Parser p(&ctx, R"(
import "GLSL.std.430" as glsl;
@ -61,7 +63,7 @@ fn main() -> { # missing return type
ASSERT_FALSE(p.Parse());
ASSERT_TRUE(p.has_error());
EXPECT_EQ(p.error(), "4:15: missing return type for function");
EXPECT_EQ(p.error(), "4:15: unable to determine function return type");
}
} // namespace

View File

@ -39,6 +39,9 @@ class Generator : public writer::Writer {
/// @returns the result data
std::string result() const { return impl_.result(); }
/// @returns the error
std::string error() const { return impl_.error(); }
private:
GeneratorImpl impl_;
};

View File

@ -23,7 +23,17 @@ namespace {
using GeneratorImplTest = testing::Test;
TEST_F(GeneratorImplTest, DISABLED_Generate) {}
TEST_F(GeneratorImplTest, Generate) {
ast::Module m;
m.AddImport(std::make_unique<ast::Import>("GLSL.std.430", "a"));
GeneratorImpl g;
ASSERT_TRUE(g.Generate(m)) << g.error();
EXPECT_EQ(g.result(), R"(import "GLSL.std.430" as a;
)");
}
} // namespace
} // namespace wgsl