mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 13:51:05 +01:00
Add `EXTRA-ARGS:` support to file_test, to add arguments without overriding the default arguments. Use `EXTRA-ARGS: --no-dump-sem-ir` to turn off SemIR dumping and thus SemIR testing in the int builtin tests, which validate correct behavior through diagnostics instead. This doesn't get us any closer to supporting more targeted SemIR dumping / testing, but this seems to be a generally useful feature anyway. Most existing tests using `ARGS` have been switched over to using `EXTRA-ARGS`. Requested in review of #4716.
90 lines
3.5 KiB
Plaintext
90 lines
3.5 KiB
Plaintext
// 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
|
|
//
|
|
// EXTRA-ARGS: --no-dump-sem-ir
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/int/uadd.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/uadd.carbon
|
|
|
|
// --- int_add.carbon
|
|
|
|
fn Add(a: i32, b: i32) -> i32 = "int.uadd";
|
|
|
|
var arr: [i32; Add(1, 2)];
|
|
let arr_p: [i32; 3]* = &arr;
|
|
|
|
fn RuntimeCallIsValid(a: i32, b: i32) -> i32 {
|
|
return Add(a, b);
|
|
}
|
|
|
|
// --- fail_bad_decl.carbon
|
|
|
|
package FailBadDecl;
|
|
|
|
// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "int.uadd" [InvalidBuiltinSignature]
|
|
// CHECK:STDERR: fn TooFew(a: i32) -> i32 = "int.uadd";
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
fn TooFew(a: i32) -> i32 = "int.uadd";
|
|
// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "int.uadd" [InvalidBuiltinSignature]
|
|
// CHECK:STDERR: fn TooMany(a: i32, b: i32, c: i32) -> i32 = "int.uadd";
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
fn TooMany(a: i32, b: i32, c: i32) -> i32 = "int.uadd";
|
|
// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "int.uadd" [InvalidBuiltinSignature]
|
|
// CHECK:STDERR: fn BadReturnType(a: i32, b: i32) -> bool = "int.uadd";
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
fn BadReturnType(a: i32, b: i32) -> bool = "int.uadd";
|
|
fn JustRight(a: i32, b: i32) -> i32 = "int.uadd";
|
|
|
|
// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:20: error: array bound is not a constant [InvalidArrayExpr]
|
|
// CHECK:STDERR: var too_few: [i32; TooFew(1)];
|
|
// CHECK:STDERR: ^~~~~~~~~
|
|
// CHECK:STDERR:
|
|
var too_few: [i32; TooFew(1)];
|
|
// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:21: error: array bound is not a constant [InvalidArrayExpr]
|
|
// CHECK:STDERR: var too_many: [i32; TooMany(1, 2, 3)];
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
var too_many: [i32; TooMany(1, 2, 3)];
|
|
// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:28: error: array bound is not a constant [InvalidArrayExpr]
|
|
// CHECK:STDERR: var bad_return_type: [i32; BadReturnType(1, 2)];
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
|
|
// CHECK:STDERR:
|
|
var bad_return_type: [i32; BadReturnType(1, 2)];
|
|
|
|
// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+6]]:21: error: 3 arguments passed to function expecting 2 arguments [CallArgCountMismatch]
|
|
// CHECK:STDERR: var bad_call: [i32; JustRight(1, 2, 3)];
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
|
|
// CHECK:STDERR: fail_bad_decl.carbon:[[@LINE-21]]:1: note: calling function declared here [InCallToEntity]
|
|
// CHECK:STDERR: fn JustRight(a: i32, b: i32) -> i32 = "int.uadd";
|
|
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
var bad_call: [i32; JustRight(1, 2, 3)];
|
|
|
|
fn RuntimeCallIsValidTooFew(a: i32) -> i32 {
|
|
return TooFew(a);
|
|
}
|
|
|
|
fn RuntimeCallIsValidTooMany(a: i32, b: i32, c: i32) -> i32 {
|
|
return TooMany(a, b, c);
|
|
}
|
|
|
|
fn RuntimeCallIsValidBadReturnType(a: i32, b: i32) -> bool {
|
|
return BadReturnType(a, b);
|
|
}
|
|
|
|
// --- overflow.carbon
|
|
|
|
package Overflow;
|
|
|
|
fn Add(a: i32, b: i32) -> i32 = "int.uadd";
|
|
|
|
// Overflow is OK.
|
|
let a: i32 = Add(0x7FFFFFFF, 0);
|
|
let b: i32 = Add(0x7FFFFFFF, 1);
|