Skip to content

Update asinit #982

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
Dec 1, 2019
Merged

Update asinit #982

merged 1 commit into from
Dec 1, 2019

Conversation

dcodeIO
Copy link
Member

@dcodeIO dcodeIO commented Nov 30, 2019

This PR updates asinit to

  • Use the loader
  • Generate dependencies for the loader and the compiler
  • Include exemplary tests
  • Refer to the new documentation instead of the wiki

fixes #919
fixes #977

@MaxGraey
Copy link
Member

Not sure about this naive tests. What about just add stub command like

{
  "test": "echo \"visit https://docs.assemblyscript.org/community/built-with-assemblyscript#testing\""
}

?

@dcodeIO
Copy link
Member Author

dcodeIO commented Nov 30, 2019

My thinking is that it's just four lines of code and does the job. Can ofc include a comment inside of that file for anyone interested in more elaborate testing :)

@MaxGraey
Copy link
Member

MaxGraey commented Nov 30, 2019

This tests will be unnecessary for general (complex) testings and users will install jest/ava or as-pest anyway. But first they are need to remove "default" test files

@dcodeIO
Copy link
Member Author

dcodeIO commented Nov 30, 2019

Of course that's super simple, but that's the point of scaffolding to me. My expectation is that someone will look at the file, see how simple it actually is, and either go with it if that's all they need (like, I would totally do that for simple modules) or replace it with whatever they fancy, learning something in the process.

@dcodeIO
Copy link
Member Author

dcodeIO commented Nov 30, 2019

To add to that: I'd even go as far as not to endorse let's say jest over as-pect or vice-versa as different projects have different requirements. Like, ideally someone would start with their very own piece of testing code, getting used to the loader this way and only pick something else once it benefits them. As such I'd not even link somewhere that favors one solution over another.

@MaxGraey
Copy link
Member

All this once again gives me a reminder that it would be nice to have the built-in in langusge testing capabilities like in Go, Rust or Kotlin

@dcodeIO
Copy link
Member Author

dcodeIO commented Nov 30, 2019

You mean something like a @test decorator that marks a function to be only run when testing?

@MaxGraey
Copy link
Member

MaxGraey commented Nov 30, 2019

Yes. Something like:

export function add(a: i32, b: i32): i32 {
   return a + b;
}

// this removed by DCE (in debug/release) but not during `npx asc --test`
@test
function testAdd1() {
   assert.notEqual(add(1, 1), 0);
}

@test("should 1 + 2 == 3 ")
function testAdd3() {
   assert.equal(add(1, 2), 3);
}

@jtenner
Copy link
Contributor

jtenner commented Nov 30, 2019

The sarcastic jerk in me is screaming about undoing a years worth of my work. Sure.

There's also a part of me that would wholeheartedly endorse a @test decorator and would love it.

Jest worked really well for as2d because it requires specialized bootstrapping.

Aspect works well for libraries written in nothing but assemblyscript.

@test decorator has the same use case as aspect but comes built into the language and remains standardized and supported by the language itself.

@dcodeIO
Copy link
Member Author

dcodeIO commented Nov 30, 2019

Wouldn't say that such a mechanism replaces as-pect. If I understood this correctly it'd rather provide a common entry point one can opt to use, and there'll still be benefits in using a testing framework to actually implement tests. Goes out of scope of this PR, though, so suggesting to continue in a separate issue :)

@dcodeIO dcodeIO merged commit d88a654 into master Dec 1, 2019
@dcodeIO dcodeIO deleted the update-asinit branch January 1, 2020 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

asinit should include a test script
3 participants