Skip to content

Fix formatting of some test files to pass autofmt tests. #2265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions xls/dslx/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1162,8 +1162,6 @@ dslx_lang_test(name = "parametric_to_value")

dslx_lang_test(
name = "constexpr_with_typed_stuff_after",
# TODO(leary): 2023-10-20 Puts inline comment in a bad spot.
test_autofmt = False,
)

dslx_lang_test(name = "for_up_to_constexpr_cast")
Expand Down Expand Up @@ -1212,9 +1210,6 @@ dslx_lang_test(
compare = "none",
# No normal 'function' entry point, it is a test proc.
convert_to_ir = False,
# TODO(leary): 2023-10-20 Arrays of channels are being formatted
# incorrectly.
test_autofmt = False,
)

dslx_lang_test(
Expand All @@ -1228,8 +1223,6 @@ dslx_lang_test(
name = "proc_smoke",
# No normal 'function' entry point, it is a test proc.
convert_to_ir = False,
# TODO(leary): 2023-10-20 Comment adorning proc next fn is being deleted.
test_autofmt = False,
)

dslx_lang_test(
Expand Down Expand Up @@ -1272,8 +1265,6 @@ dslx_lang_test(
name = "send_if_recv_if",
convert_to_ir = False,
dslx_entry = "main",
# TODO(leary): 2023-10-20 Crashes! (assertion failure)
test_autofmt = False,
)

xls_dslx_ir(
Expand All @@ -1286,8 +1277,6 @@ dslx_lang_test(
name = "non_blocking_receives",
convert_to_ir = False,
dslx_entry = "proc_main",
# TODO(leary): 2023-10-20 Crashes! (assertion failure)
test_autofmt = False,
)

xls_dslx_ir(
Expand Down
19 changes: 8 additions & 11 deletions xls/dslx/tests/constexpr_with_typed_stuff_after.x
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,18 @@
// functions/tests as expected.

const MY_CONST = u32:42;
type MyBits = bits[MY_CONST]; // This name reference forces constexpr eval.

struct Simple {
x: u32
}
const SIMPLE = Simple{ x: u32:2 };
type MyBits = bits[MY_CONST]; // This name reference forces constexpr eval.

struct Simple { x: u32 }

const SIMPLE = Simple { x: u32:2 };

// The struct access requires type information, but we forced constexpr eval
// higher up in the file.
const TWO = SIMPLE.x;

fn main() -> (u32, bits[42]) {
(TWO, MyBits:0)
}
fn main() -> (u32, bits[42]) { (TWO, MyBits:0) }

#[test]
fn test_main() {
assert_eq(main(), (u32:2, bits[42]:0))
}
fn test_main() { assert_eq(main(), (u32:2, bits[42]:0)) }
124 changes: 59 additions & 65 deletions xls/dslx/tests/non_blocking_receives.x
Original file line number Diff line number Diff line change
Expand Up @@ -15,97 +15,91 @@
import std;

proc test_impl {
in0: chan<u32> in;
in1: chan<u32> in;
out0 : chan<u32> out;
in0: chan<u32> in;
in1: chan<u32> in;
out0: chan<u32> out;

init { u32:0 }
config(in0: chan<u32> in, in1: chan<u32> in, out0: chan<u32> out) { (in0, in1, out0) }

config(in0: chan<u32> in,
in1: chan<u32> in,
out0: chan<u32> out) {
(in0, in1, out0)
}
init { u32:0 }

next(state: u32) {
let (tok0, i0, valid0) = recv_non_blocking(join(), in0, u32:123);
let (tok1, i1, valid1) = recv_non_blocking(join(), in1, u32:42);
next(state: u32) {
let (tok0, i0, valid0) = recv_non_blocking(join(), in0, u32:123);
let (tok1, i1, valid1) = recv_non_blocking(join(), in1, u32:42);

let o0 = u32:0;
let o0 = if(valid0) { o0 + i0 } else { o0 };
let o0 = if(valid1) { o0 + i1 } else { o0 };
let o0 = u32:0;
let o0 = if valid0 { o0 + i0 } else { o0 };
let o0 = if valid1 { o0 + i1 } else { o0 };

let tok_recv = join(tok0, tok1);
let tok_send = send(tok_recv, out0, o0);
let tok_recv = join(tok0, tok1);
let tok_send = send(tok_recv, out0, o0);

let state = o0;
let state = o0;

state
}
state
}
}

pub proc proc_main {
init { () }
config(in0: chan<u32> in, in1: chan<u32> in, out0: chan<u32> out) {
spawn test_impl(in0, in1, out0);
}

config(in0: chan<u32> in,
in1: chan<u32> in,
out0: chan<u32> out) {
spawn test_impl(in0, in1, out0);
}
init { () }

next(state: ()) { () }
next(state: ()) { () }
}

#[test_proc]
proc test_main {
terminator: chan<bool> out;
in0: chan<u32> out;
in1: chan<u32> out;
out0: chan<u32> in;
terminator: chan<bool> out;
in0: chan<u32> out;
in1: chan<u32> out;
out0: chan<u32> in;

init { () }
config(terminator: chan<bool> out) {
let (in0_s, in0_r) = chan<u32>("in0");
let (in1_s, in1_r) = chan<u32>("in1");
let (out0_s, out0_r) = chan<u32>("out0");

config(terminator: chan<bool> out) {
let (in0_s, in0_r) = chan<u32>("in0");
let (in1_s, in1_r) = chan<u32>("in1");
let (out0_s, out0_r) = chan<u32>("out0");
spawn proc_main(in0_r, in1_r, out0_s);

spawn proc_main(in0_r, in1_r, out0_s);
(terminator, in0_s, in1_s, out0_r)
}

(terminator, in0_s, in1_s, out0_r)
}
init { () }

next(state: ()) {
// Not sending on either channel means output is 0.
let (tok, v) = recv(join(), out0);
assert_eq(v, u32:0);
let (tok, v) = recv(tok, out0);
assert_eq(v, u32:0);
next(state: ()) {
// Not sending on either channel means output is 0.
let (tok, v) = recv(join(), out0);
assert_eq(v, u32:0);
let (tok, v) = recv(tok, out0);
assert_eq(v, u32:0);

// Sending on on channel means output is the input.
let tok = send(tok, in0, u32:3);
let (tok, v) = recv(tok, out0);
assert_eq(v, u32:3);
// Sending on on channel means output is the input.
let tok = send(tok, in0, u32:3);
let (tok, v) = recv(tok, out0);
assert_eq(v, u32:3);

let (tok, v) = recv(tok, out0);
assert_eq(v, u32:0);
let (tok, v) = recv(tok, out0);
assert_eq(v, u32:0);

let tok = send(tok, in1, u32:5);
let (tok, v) = recv(tok, out0);
assert_eq(v, u32:5);
let tok = send(tok, in1, u32:5);
let (tok, v) = recv(tok, out0);
assert_eq(v, u32:5);

let (tok, v) = recv(tok, out0);
assert_eq(v, u32:0);
let (tok, v) = recv(tok, out0);
assert_eq(v, u32:0);

// Sending on both channels means output is the sum of inputs.
let tok = send(tok, in0, u32:10);
let tok = send(tok, in1, u32:20);
let (tok, v) = recv(tok, out0);
assert_eq(v, u32:30);
// Sending on both channels means output is the sum of inputs.
let tok = send(tok, in0, u32:10);
let tok = send(tok, in1, u32:20);
let (tok, v) = recv(tok, out0);
assert_eq(v, u32:30);

let (tok, v) = recv(tok, out0);
assert_eq(v, u32:0);
let (tok, v) = recv(tok, out0);
assert_eq(v, u32:0);

let tok = send(tok, terminator, true);
}
let tok = send(tok, terminator, true);
}
}
54 changes: 28 additions & 26 deletions xls/dslx/tests/proc_channel_arrays.x
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,40 @@

// Test demonstrating use (and correct implementation) of arrays of channels.
proc consumer {
send_chans: chan<u16>[128] out;
recv_chans: chan<u16>[128][64] in;

init { () }
config(send_chans: chan<u16>[128] out, recv_chans: chan<u16>[128][64] in) {
(send_chans, recv_chans)
}
next(state: ()) {
let (tok, i) = recv(join(), recv_chans[0][0]);
let tok = send(tok, send_chans[1], i + i);
}
send_chans: chan<u16>[128] out;
recv_chans: chan<u16>[128][64] in;

config(send_chans: chan<u16>[128] out, recv_chans: chan<u16>[128][64] in) {
(send_chans, recv_chans)
}

init { () }

next(state: ()) {
let (tok, i) = recv(join(), recv_chans[0][0]);
let tok = send(tok, send_chans[1], i + i);
}
}

#[test_proc]
proc producer {
ps: chan<u16>[128][64][32] out;
cs: chan<u16>[128][64][32] in;
terminator: chan<bool> out;
ps: chan<u16>[128][64][32] out;
cs: chan<u16>[128][64][32] in;
terminator: chan<bool> out;

init { () }
config(terminator: chan<bool> out) {
let (ps, cs) = chan<u16>[128][64][32]("multidim_chan");
spawn consumer(ps[0][1], cs[0]);
(ps, cs, terminator)
}

config(terminator: chan<bool> out) {
let (ps, cs) = chan<u16>[128][64][32]("multidim_chan");
spawn consumer(ps[0][1], cs[0]);
(ps, cs, terminator)
}
init { () }

next(state: ()) {
let tok = send(join(), ps[0][0][0], u16:1);
let (tok, result) = recv(tok, cs[0][1][1]);
assert_eq(result, u16:2);
next(state: ()) {
let tok = send(join(), ps[0][0][0], u16:1);
let (tok, result) = recv(tok, cs[0][1][1]);
assert_eq(result, u16:2);

let tok = send(tok, terminator, true);
}
let tok = send(tok, terminator, true);
}
}
48 changes: 22 additions & 26 deletions xls/dslx/tests/proc_smoke.x
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,33 @@
// limitations under the License.

proc proc_under_test {
a: u32;
input_r: chan<u32> in;
a: u32;
input_r: chan<u32> in;

init { () }
config(r: chan<u32> in) { (u32:0, r) }

config(r: chan<u32> in) {
(u32:0, r)
}
init { () }

next(state: ()) {
let (tok, _) = recv(join(), input_r);
}
next(state: ()) { let (tok, _) = recv(join(), input_r); }
}

#[test_proc]
proc test_main {
input_s: chan<u32> out;
terminator_s: chan<bool> out;

init { u32:0 }

config(terminator_s: chan<bool> out) {
let (s, r) = chan<u32>("c");
spawn proc_under_test(r);
(s, terminator_s)
}

// Run for two iterations then exit.
next(iter: u32) {
let tok = send(join(), input_s, u32:0);
let tok = send_if(tok, terminator_s, iter == u32:2, true);
iter + u32:1
}
input_s: chan<u32> out;
terminator_s: chan<bool> out;

config(terminator_s: chan<bool> out) {
let (s, r) = chan<u32>("c");
spawn proc_under_test(r);
(s, terminator_s)
}

init { u32:0 }

// Run for two iterations then exit.
next(iter: u32) {
let tok = send(join(), input_s, u32:0);
let tok = send_if(tok, terminator_s, iter == u32:2, true);
iter + u32:1
}
}
Loading