Skip to content

Question: examples for testing async functions? #1

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

Open
shichen85 opened this issue Aug 28, 2024 · 2 comments
Open

Question: examples for testing async functions? #1

shichen85 opened this issue Aug 28, 2024 · 2 comments
Labels
question Further information is requested

Comments

@shichen85
Copy link

Hello, thanks for the well-documented project! A quick question: do you have any examples for testing async functions such as http_get() or buffer_save_async(), where the response comes back a few frames later in the Async event?

@DAndrewBox DAndrewBox added the question Further information is requested label Aug 29, 2024
@DAndrewBox
Copy link
Owner

DAndrewBox commented Aug 29, 2024

@shichen85 Thank you for the input!
Right now it has no support for E2E tests related to http requests or code using the async event since I haven't found a way to simulate in one frame the async_load you should receive outside the async events, but it's on my backlog and was an idea that I had during the first iterations.

Hopefully I'll be able to implement it for later releases, I will tag this issue/question when that happens!

@shichen85
Copy link
Author

@shichen85 Thank you for the input! Right now it has no support for E2E tests related to http requests or code using the async event since I haven't found a way to simulate in one frame the async_load you should receive outside the async events, but it's on my backlog and was an idea that I had during the first iterations.

Hopefully I'll be able to implement it for later releases, I will tag this issue/question when that happens!

Thanks for the reply!

I have never not thought about using synchronous simulations to test async logics before, but after taking a look at your implementation of GMTL_core_test_events I can see how that can work, and it is very inspiring! Perhaps using event_perform_async followed by event_perform_object on an object that is meant to handle async events could achieve the purpose.

Testing async logic has long been my desire, but it took me a while to figure out how to support them in GML. I eventually developed a testing GML library called Olympus that was inspired by MochaJS, and I structured each test/it block to behave like a Javascript Promise so that I could wait for them to resolve or reject and pass the result back to test/it block to analyze and match. Here is an example of testing http_get. I am mostly happy with the implementation and have been using that to test various async functions or objects in my runtime test suite, but I think the function signature is still hard to reason through for first time users.

Anyways, I am very excited for more discussions on testing in the GML space. Hit me up if you ever want to talk more on it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants