Skip to content

The test keyword - proposal #1370

Description

@eladb

Community Note

Please vote by adding a 👍 reaction to the issue to help us prioritize.
If you are interested to work on this issue, please leave a comment.

Feature Spec

Before:

bring cloud;
let b = new cloud.Bucket();

new cloud.Function(inflight (_: str) => {
  assert(b.list().length == 0);
}) as "test:bucket starts empty";

new cloud.Function(inflight (_: str) => {
  assert(b.list().length == 0);
  b.put("file1.txt", "hello");
  assert(b.list().length == 1);
  assert(b.get("file1.txt") == "hello");
}) as "test:get after put";

After:

bring cloud;
let b = new cloud.Bucket();

test "bucket starts empty" {
  assert(b.list().length == 0);
}

test "get after put" {
  assert(b.list().length == 0);
  b.put("file1.txt", "hello");
  assert(b.list().length == 1);
  assert(b.get("file1.txt") == "hello");
}

I really don't like that it's basically breaking 1000 grammatical rules and would love
feedback, but I tried to design this "backwards" from what my ideal experience as a developer > would be and this is what I came up with.

I think experimenting with this in the short term is likely going to be a useful exercise.

Use Cases

Exploring language support for making tests first-class citizens.

Make tests really easy to write.

Implementation Notes

We should make a cloud.Test resource first and then have test sugar down to it.

Component

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status
    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions