Skip to content

Commit

Permalink
Added fuzzer crash samples as testdata entries (#1299)
Browse files Browse the repository at this point in the history
For issues #1248, #1249, #1257, #1263
Before the samples were only recorded as fuzzer corpus files which are less 'durable'
  • Loading branch information
pk19604014 authored May 26, 2022
1 parent 8c34227 commit 39d26a6
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
20 changes: 20 additions & 0 deletions explorer/testdata/basic_syntax/fail_alternative_uses_choice.carbon
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: %{not} %{explorer} %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
// RUN: %{not} %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: %{explorer} %s

package ExplorerTest api;

choice Ch {
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/basic_syntax/fail_alternative_uses_choice.carbon:[[@LINE+1]]: could not resolve 'Ch'
Opt(Ch)
}

fn Main() -> i32 {
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: %{not} %{explorer} %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
// RUN: %{not} %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: %{explorer} %s

package ExplorerTest api;

fn f() -> auto {
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/experimental_continuation/fail_auto_return_await.carbon:[[@LINE+1]]: control-flow reaches end of function that provides a `->` return type without reaching a return statement
__await;
}

fn Main() -> i32 {
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: %{not} %{explorer} %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
// RUN: %{not} %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: %{explorer} %s

package ExplorerTest api;

fn f() {
__continuation k {
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/experimental_continuation/fail_recursive_continuation.carbon:[[@LINE+1]]: could not resolve 'k'
__run k;
}
}

fn Main() -> i32 {
return 0;
}
21 changes: 21 additions & 0 deletions explorer/testdata/function/fail_invalid_fnty.carbon
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: %{not} %{explorer} %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
// RUN: %{not} %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: %{explorer} %s

package ExplorerTest api;

// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/function/fail_invalid_fnty.carbon:[[@LINE+3]]: type error in negation
// CHECK: expected: i32
// CHECK: actual: Bool
fn f(g: __Fn(-true) -> true) {
}

fn Main() -> i32 {
return 0;
}

0 comments on commit 39d26a6

Please sign in to comment.