GithubHelp home page GithubHelp logo

Comments (11)

javatlacati avatar javatlacati commented on May 29, 2024 8

Actually having a testing framework is all you pre-require to get it included inside Codewars, for your consideration

from one.

BaseMax avatar BaseMax commented on May 29, 2024 7

Dear ismael suggest a c library for unit testing.

https://github.com/ThrowTheSwitch/Unity
cc #55

from one.

javatlacati avatar javatlacati commented on May 29, 2024 6

Yes, but.. if I write

main {
   ret 0
}

how do I test it without converting it to another language?
Do you have any One-Language-based testing framework?

perhaps to do something like:

assertToBe(main, 0,"expected return value to be 0")

from one.

BaseMax avatar BaseMax commented on May 29, 2024 6

Hi Ruslan;

We are happy you to join our team and be with us. It will be great if you accept our invite to join this org even if you do not have the opportunity to work, you can advise us.

perhaps to do something like:
assertToBe(main, 0,"expected return value to be 0")

It was a very good offer.

Best;

from one.

abdorah avatar abdorah commented on May 29, 2024 5

Hello friends, if we agree with using this framework I have a few points to discuss:
1- https://github.com/ThrowTheSwitch/Unity/blob/master/docs/UnityGettingStartedGuide.md here is a good place to start learning about it.
2- @BaseMax does using unity require any changes on the code structure?
3- what do you think guys from this attempt to use unity?
4- In terms of what should we test first; I think that we can start by:
ast, compile, error, file, lexer, parser, token. Then we can continue our tests on the remaining files of the project.

from one.

BaseMax avatar BaseMax commented on May 29, 2024 5

Thank you Kotbi. @abdorah
Yeah, auto testing (unit-test, ...) is necessary for this project.

http://www.throwtheswitch.org/unity

Yes, it's a good library, which I have no problem with.

These are the files that I think need to be tested:

  • lexer.test.c
  • parser.test.c
  • ast.test.c

In the lexical stage we will have a series of test texts that we have to have in front of a presentation of tokens. (token types array)
And check if the tokens we get from the program are equal to the tokens we expect.

from one.

BaseMax avatar BaseMax commented on May 29, 2024 4

Now I see your fork. It's good, you moved the test file to another directory. ๐Ÿ‘

arg-test is also a good idea.
You can pass fake argc,argv parameters and compare results.

If you have done this. please send your PR. It's welcome. @abdorah
Thanks

from one.

abdorah avatar abdorah commented on May 29, 2024 4

Thank you @BaseMax !
I took into consideration the files that you said that they need tests. I started with lexer.test.c . Also, I omitted the file arg-test because I think that we can leave it to the end (We can use it to make something similar to an integration test, what do you think?).
This is what I did so far: https://github.com/abdorah/One/blob/master/unit-tests/
It is basically something like this:

#include "unity.h"
#include "error.h"
#include "lexer.h"

char *filename;
char *input;
ErrorsContainer *errors;
Lexer *lex;

void setUp(void)
{
    //This is the initialization for the variables needed for the unit testing.
    filename = "tests/1-hello-world.et";
    input = "";
    ErrorsInit(errors);
	lex = lexerInit(filename, input, errors);
}

void tearDown(void)
{
	lexerFree(lex);
}

void test_function_should_check_lex(void)
{
	TEST_ASSERT_EQUAL_INT(EXIT_SUCCESS, lexerCheck(lex, errors));
}

int main(void)
{
	UNITY_BEGIN();
	RUN_TEST(test_function_should_check_lex);
	return UNITY_END();
}

This can be improved (especially the variables I used).
Thank you for your review.

from one.

BaseMax avatar BaseMax commented on May 29, 2024 3

from one.

jbampton avatar jbampton commented on May 29, 2024

We have some tests that run on pull request.

We plan to add more. We also use pre-commit.

from one.

jbampton avatar jbampton commented on May 29, 2024

Codewars training hey ?

You will have to ask @BaseMax what he thinks

from one.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.