Skip to content
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

console_dbg outputs wrong expression #172

Closed
Madoshakalaka opened this issue Nov 26, 2021 · 5 comments
Closed

console_dbg outputs wrong expression #172

Madoshakalaka opened this issue Nov 26, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@Madoshakalaka
Copy link
Contributor

Madoshakalaka commented Nov 26, 2021

Describe the Bug

console_dbg!(anything) will output ::std::format!("{:?}", v) to the console

Steps to Reproduce

producing code with Yew:

use yew::prelude::*;

#[function_component(App)]
fn app() -> Html {
    let a = 1;
    gloo_console::console_dbg!(a);
    gloo_console::console_dbg!(a + 1);
    html! {
    }
}

fn main() {
    yew::start_app::<App>();
}

Expected Behavior

Should output [src\main.rs:6] a = 1 and [src\main.rs:7] a + 1 = 2 to the console.

Actual Behavior

nuts:

image

@Madoshakalaka Madoshakalaka added the bug Something isn't working label Nov 26, 2021
@ranile
Copy link
Collaborator

ranile commented Nov 26, 2021

Welp... Looks like wrong expression is being stringifyed. Free free to submit a PR correcting it.

Also, do you know of a way to unit test this? I don't know how we'd read console output in tests run with wasm-bindgen


Actual Behavior

nuts:

I'm sure Risu is proud

@Madoshakalaka
Copy link
Contributor Author

Also, do you know of a way to unit test this?

No clue, will ask some people...

@Madoshakalaka
Copy link
Contributor Author

some more experienced web dev ( @eddieantonio ) says this:

It's javascript; you could shadow the global console object and provide your own with a mock/spy/stub/whatever they're calling it these days and assert that it's being called with the right args

@ranile
Copy link
Collaborator

ranile commented Nov 26, 2021

some more experienced web dev ( @eddieantonio ) says this:

It's javascript; you could shadow the global console object and provide your own with a mock/spy/stub/whatever they're calling it these days and assert that it's being called with the right args

Interesting. I have no idea how that would happen in a wasm-bindgen test environment though

@Madoshakalaka
Copy link
Contributor Author

Madoshakalaka commented Nov 26, 2021

Free free to submit a PR correcting it.

working on it

Madoshakalaka added a commit to Madoshakalaka/gloo that referenced this issue Nov 26, 2021
@ranile ranile closed this as completed in 91eb9e0 Nov 28, 2021
ranile added a commit that referenced this issue Dec 20, 2021
* closes #173, fixes #172

* remove extra comma

* add function to access head

* rustfmt

* Fix typo

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants