nit.git
9 years agosrc: transform all old writable in annotations
Jean Privat [Fri, 5 Sep 2014 00:49:39 +0000 (20:49 -0400)]
src: transform all old writable in annotations

So just insert an `is`, and move it after the initial value if any.

~~~
sed -i '/ is /!s/\(\( redef\)\?\( protected\)\? writable\)\(.*\)/\4 is\1/'
~~~

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Nitdoc: some cleaning and fixes.
Jean Privat [Fri, 5 Sep 2014 10:34:42 +0000 (06:34 -0400)]
Merge: Nitdoc: some cleaning and fixes.

Some small fixes for nitdoc before the introduction of new features.

No concrete impact on visual for now.

Pull-Request: #718
Reviewed-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Introduce `nitpretty`: a pretty printer for nit source files.
Jean Privat [Fri, 5 Sep 2014 10:34:22 +0000 (06:34 -0400)]
Merge: Introduce `nitpretty`: a pretty printer for nit source files.

# Commit summary

First commit introduce the tool (formated with nitpretty).
Second commit add tests for nitpretty.
Last two commits propose an update of lib files formatted with nitpretty.

# Tool Description

`nitpretty` is a tool able to pretty print Nit files.

Usage:

    $ nitpretty source.nit

Main options:

* `-o res.nit` output result into `res.nit`
* `--diff` show diff between `source` and `res`
* `--meld` open diff with `meld`
* `--check` check the format of multiple source files
* `--check --meld` perform `--check` and open `meld` for each difference

## Specification

The specification of the pretty printing is described here.

* Default indentation level is one `' '` character and
is increased by one for each indentation level.
* Default line max-size is 80.

### Comments

There is many categories of comments:

`Licence comments` are attached to the top of the file
no blank line before, one after.

    # This is a licence comment

    # Documentation for module `foo`
    module foo

`ADoc` are documentation comments attached to a `AModule`, `AClassdef`, `APropdef`.

They are printed before the definition with a blank line before and no after
at the same indentation level than the definition.

    # Documentation for module `foo`
    module foo

    # Documentation for class `Bar`
    class Bar
         # Documentation for method `baz`
         fun baz do end
    end

`Block comments` are comments composed of one or more line rattached to nothing.
They are displayed with one blank line before and after at current indent level.

    <blank>
    # block
    # comment
    <blank>

`Attached comments` are comments attached to a production.
They are printed as this.

    fun foo do # attached comment
    end

`nitpretty` automatically remove multiple blanks between comments:

    # Licence
    # ...
    <blank>
    # Block comment

### Inlinging

Productions are automatically inlined when possible.

Conditions:

* the production must be syntactically inlinable
* the inlined production length is less than `PrettyPrinterVisitor::max-size`
* the production do not contains any comments

### Modules

* There is a blank between the module declaration and its imports
* There is no blank between imports and only one after
* There is a blank between each exten block definition
* There is a blank between each class definition
* There is always a blank line at the end of the module

Example:

    # Documentation for module `foo`
    module foo

    import a
    # import b
    import c

    # Documentation for class `Bar`
    class Bar end

    class Baz end # not a `ADoc` comment

### Classes

* There is no blank between the class definition and its super-classes declarations
* There is no blank between two inlined property definition
* There is a blank between each block definition
* There no blank line at the end of the class definition

Example:

    # Documentation for class `Bar`
    class Bar end

    class Baz
         super Bar

         fun a is abstract
         private fun b do end

         fun c do
              # ...
         end
    end

Generic types have no espace after or before brackets and are separated by a comma and a space:

    class A[E: Type1, F: Type1] do end

### Blocks

* Inlined productions have no blank lines between them
* Block productions have a blank before and after

    var a = 10
    var b = 0

    if a > b then
         # is positive
         print "positive"
    end

    print "end"

### Calls and Binary Ops

Arguments are always printed separated with a comma and a space:

    foo(a, b, c)

Binary ops are always printed wrapped with spaces:

    var c = 1 + 2

Calls and binary ops can be splitted to feat the `max-size` constraint.
Breaking priority is given to arguments declaration after the comma.

    return foo("aaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbb",
       "cccccccccccccccccccccccccc")

Binary ops can also be broken to feet the `maz-size` limit:

    return "aaaaaaaaaaaaaaaaaaaaaaaaaa" + "bbbbbbbbbbbbbbbbbbbbbbbbbbb" +
       "cccccccccccccccccccccccccc"

# Fiability of the tool

I tested it on lib/ and verified manually all the changes. The result displayed in the two lasts commits contains no manual transformation (except to adjust some misplaced comments).

I guess that some constructs are not treated as well as they can, I need some user feedback.

There maybe still cases in src/ that are not printed without some bugs so I will not say that it's safe to print and replace files you are working on and have no copy of.

How to stay safe? Simple, commit before applying pretty printing and check the diff after or use options `--diff` or `--meld` to apply changes manually.

I used the option combination `--check --meld` to check and edit all the lib/ files one by one. It was surprinsingly fast but boring...

I also ran the tool on src/ and it ended up with no failures but there still formatting to update, I propose the lazy way: futures users may apply the formatter before commiting files.

# TODO

It can be cool to integrate this with vim or a Nit IDE.
It can also be integrated with some tests hooks before merging.

The `collect_length` calculation is based on `Token::collect_text` so the length is based on the tokens as they are written and not how they will be trasnformed. Furthermore, possibles spaces or trailing comments are not taken into account.

This have two impacts:

* some lines are not break at 80 chars and may overflow by a few chars
* when appliying the pretty printer on an already pretty printed file, some new transformation can append (because some `end` tokens have been removed by the previous execution and production is now shorter and can be inlined).

Possible fixes:

* ran the tool while the fix point if not reached :p
* redefines the `collect_length` method for all production to take spaces into accounts
* pre-do a transformation, test the length of the result then apply the inlining

All but first, can be long to implement for the possibles outcomes so I forward this to future-me "if needed later".

Pull-Request: #645
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agonitdoc: update tests
Alexandre Terrasa [Fri, 5 Sep 2014 03:53:51 +0000 (23:53 -0400)]
nitdoc: update tests

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agonitdoc:sanitize generated html
Alexandre Terrasa [Fri, 5 Sep 2014 03:26:17 +0000 (23:26 -0400)]
nitdoc:sanitize generated html

Fixes #669.

Remaining errors are related to duplicated html ids in comments.
Those are generated by the markdown parser and will be fixed in
a further pull request.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agonitdoc: clean some useless super-strings
Alexandre Terrasa [Fri, 5 Sep 2014 02:17:58 +0000 (22:17 -0400)]
nitdoc: clean some useless super-strings

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agonitdoc: make `TplLink::text` type less specific
Alexandre Terrasa [Fri, 5 Sep 2014 02:23:54 +0000 (22:23 -0400)]
nitdoc: make `TplLink::text` type less specific

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agonitdoc: fix `TplArticle::is_empty`
Alexandre Terrasa [Fri, 5 Sep 2014 02:23:03 +0000 (22:23 -0400)]
nitdoc: fix `TplArticle::is_empty`

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agonitdoc: fix `MEntity::tpl_anchor` documentation
Alexandre Terrasa [Fri, 5 Sep 2014 02:21:40 +0000 (22:21 -0400)]
nitdoc: fix `MEntity::tpl_anchor` documentation

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agonitdoc: clean some templates generation
Alexandre Terrasa [Thu, 4 Sep 2014 19:04:07 +0000 (15:04 -0400)]
nitdoc: clean some templates generation

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agonitdoc: fix scroll bar display
Alexandre Terrasa [Thu, 4 Sep 2014 18:59:50 +0000 (14:59 -0400)]
nitdoc: fix scroll bar display

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agonitdoc: remove unused method `sort_by_public_owner`
Alexandre Terrasa [Mon, 25 Aug 2014 04:56:51 +0000 (00:56 -0400)]
nitdoc: remove unused method `sort_by_public_owner`

Fixes #668

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agonitdoc: avoid conflicts in MEntity urls
Alexandre Terrasa [Mon, 25 Aug 2014 04:55:17 +0000 (00:55 -0400)]
nitdoc: avoid conflicts in MEntity urls

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agonitdoc: avoid crash on empty mclassdef list.
Alexandre Terrasa [Mon, 25 Aug 2014 03:24:22 +0000 (23:24 -0400)]
nitdoc: avoid crash on empty mclassdef list.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agonitdoc: clean breadcrumbs generation.
Alexandre Terrasa [Mon, 25 Aug 2014 03:18:11 +0000 (23:18 -0400)]
nitdoc: clean breadcrumbs generation.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agonitdoc: move page url into `NitdocPage`
Alexandre Terrasa [Mon, 25 Aug 2014 03:01:37 +0000 (23:01 -0400)]
nitdoc: move page url into `NitdocPage`

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agoMerge: Clean benchs
Jean Privat [Fri, 5 Sep 2014 00:21:51 +0000 (20:21 -0400)]
Merge: Clean benchs

update benchs/bebch_engines.sh to fix issues, add options and programs.

Preview of updated version is available at http://info.uqam.ca/~privat/nitdoc/ ; was run in background on a busy machine, so numbers have a lot of uncertainty.
bench_engines is quite interesting.

Pull-Request: #714
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agoMerge: tests: improve documentation
Jean Privat [Fri, 5 Sep 2014 00:21:48 +0000 (20:21 -0400)]
Merge: tests: improve documentation

Closes #711

Pull-Request: #713
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agotests: improve documentation
Jean Privat [Thu, 4 Sep 2014 16:13:38 +0000 (12:13 -0400)]
tests: improve documentation

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agobench: add generated files for xml and html to .gitignore
Jean Privat [Thu, 4 Sep 2014 15:55:51 +0000 (11:55 -0400)]
bench: add generated files for xml and html to .gitignore

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agobenchs: produce .xml files conform with junit
Jean Privat [Thu, 4 Sep 2014 15:54:38 +0000 (11:54 -0400)]
benchs: produce .xml files conform with junit

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agobenchs: add more engines and gc options
Jean Privat [Thu, 4 Sep 2014 00:10:51 +0000 (20:10 -0400)]
benchs: add more engines and gc options

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agobenchs: update compilation options (faster, slower, etc.)
Jean Privat [Thu, 4 Sep 2014 00:09:39 +0000 (20:09 -0400)]
benchs: update compilation options (faster, slower, etc.)

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agobenchs: use the bootstraped nitg because it is correcly compiled since d055af3c72
Jean Privat [Thu, 4 Sep 2014 00:08:27 +0000 (20:08 -0400)]
benchs: use the bootstraped nitg because it is correcly compiled since d055af3c72

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agobenchs: update run programs. Remove pep8analysis because it is too fast
Jean Privat [Thu, 4 Sep 2014 00:06:38 +0000 (20:06 -0400)]
benchs: update run programs. Remove pep8analysis because it is too fast

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: add meta-tests related to the execution control
Jean Privat [Thu, 4 Sep 2014 00:55:53 +0000 (20:55 -0400)]
tests: add meta-tests related to the execution control

* zzz_tests/zzz_test_args.nit
* zzz_tests/zzz_test_envvar.nit
* zzz_tests/zzz_test_in.nit
* zzz_tests/zzz_test_post_proc.nit
* zzz_tests/zzz_test_write.nit

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: add licence to existing zzz_tests files
Jean Privat [Thu, 4 Sep 2014 14:01:16 +0000 (10:01 -0400)]
tests: add licence to existing zzz_tests files

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: skip nitpretty for niti.
Alexandre Terrasa [Thu, 4 Sep 2014 01:01:38 +0000 (21:01 -0400)]
tests: skip nitpretty for niti.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agoMerge: Kill oldstyle attributes
Jean Privat [Thu, 4 Sep 2014 00:20:40 +0000 (20:20 -0400)]
Merge: Kill oldstyle attributes

Remove remaining usage of old style attributes declarations `var _foo`.

Also remove the annotation `old_style_init` in the parser.

Pull-Request: #712
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agoMerge: Clean src
Jean Privat [Thu, 4 Sep 2014 00:20:35 +0000 (20:20 -0400)]
Merge: Clean src

Since there is groups in the c_src compiler, use them in src to regroupe related concerns.

Thus, this PR creates new groups:

* modelize (AST-> model)
* semantize (AST+model -> augmented AST)
* frontend (modelize+semantize+other stuff)
* compiler (all compiler-related things)
* interpreter (all interpreter related things)

Some more things remain to discuss latter:

* the status of platforms things: I moved them to compiler, does this make sense?
* I let the nit*.nit and test_*.nit at the top level to have a fast glance of what are the entry points/main modules. Is this a good idea?
* what to do with the remaining modules in the src directory?

Pull-Request: #706
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agopep8analysis: update and remove old-style attributes
Jean Privat [Wed, 3 Sep 2014 18:04:19 +0000 (14:04 -0400)]
pep8analysis: update and remove old-style attributes

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: update sav because ligne changes in lib
Jean Privat [Wed, 3 Sep 2014 17:47:32 +0000 (13:47 -0400)]
tests: update sav because ligne changes in lib

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoparser: regenerate parser_abs.nit
Jean Privat [Wed, 3 Sep 2014 17:48:31 +0000 (13:48 -0400)]
parser: regenerate parser_abs.nit

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoparser: remove old-style attributes in xss
Jean Privat [Wed, 3 Sep 2014 15:37:23 +0000 (11:37 -0400)]
parser: remove old-style attributes in xss

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoparser: batch remove old style attribute
Jean Privat [Wed, 3 Sep 2014 15:54:34 +0000 (11:54 -0400)]
parser: batch remove old style attribute

~~~
sed -i 's/var _n\(.*: nullable.*\)/var n\1 is writable/' parser/parser_nodes.nit
sed -i 's/var _n\(.*\)/var n\1 is writable, noinit/' parser/parser_nodes.nit
sed -i '/fun n_\(.*\)/d' parser/parser_nodes.nit
sed -i '/init do end/d' parser/parser_nodes.nit
~~~

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoparser: remove manual old-style attributes
Jean Privat [Wed, 3 Sep 2014 18:08:23 +0000 (14:08 -0400)]
parser: remove manual old-style attributes

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoparser: _location it no more nullable, so use isset for magic when needed
Jean Privat [Wed, 3 Sep 2014 18:07:32 +0000 (14:07 -0400)]
parser: _location it no more nullable, so use isset for magic when needed

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: add tests for nitpretty
Alexandre Terrasa [Mon, 4 Aug 2014 00:08:23 +0000 (20:08 -0400)]
tests: add tests for nitpretty

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agosrc: Introduce nitpretty, a pretty printer for Nit
Alexandre Terrasa [Mon, 4 Aug 2014 00:07:32 +0000 (20:07 -0400)]
src: Introduce nitpretty, a pretty printer for Nit

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agosrc: move model_vis to model
Jean Privat [Wed, 3 Sep 2014 14:11:15 +0000 (10:11 -0400)]
src: move model_vis to model

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agocontrib/online_ide: fix import of interpreter modules
Jean Privat [Tue, 2 Sep 2014 18:59:37 +0000 (14:59 -0400)]
contrib/online_ide: fix import of interpreter modules

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agosrc: create groups for related things
Jean Privat [Tue, 2 Sep 2014 16:09:19 +0000 (12:09 -0400)]
src: create groups for related things

File are moved, some minimal change in importations

* modelize
* semantize
* frontend
* compiler
* interpreter

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agosrc: clean white-spaces and license in some files
Jean Privat [Tue, 2 Sep 2014 19:00:23 +0000 (15:00 -0400)]
src: clean white-spaces and license in some files

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agosrc/metrics: clean importations
Jean Privat [Wed, 3 Sep 2014 13:55:20 +0000 (09:55 -0400)]
src/metrics: clean importations

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib: remove remaining declaration of old-style attributes.
Jean Privat [Wed, 3 Sep 2014 15:06:07 +0000 (11:06 -0400)]
lib: remove remaining declaration of old-style attributes.

Since new-style attributes still allows low-level access to the real
attributes, the migration was easy; although some intrude imports where required.

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoniti: remove dependency on common_ffi
Jean Privat [Wed, 3 Sep 2014 13:37:08 +0000 (09:37 -0400)]
niti: remove dependency on common_ffi

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agosrc: cleanup importations
Jean Privat [Wed, 3 Sep 2014 14:19:04 +0000 (10:19 -0400)]
src: cleanup importations

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agosrc: add new hub modules to regroup related things together.
Jean Privat [Wed, 3 Sep 2014 14:18:21 +0000 (10:18 -0400)]
src: add new hub modules to regroup related things together.

modelize: for modelize_*
semantize: for typing/auto_super_init/scope/flow/etc.
compiler: for compiler related things
interpreter: for interpreter related things

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: lib: add standard/error.nit
Jean Privat [Wed, 3 Sep 2014 09:51:32 +0000 (05:51 -0400)]
Merge: lib: add standard/error.nit

This could help people to implement some error handling in libraries.

It is inspired by #701 and ideas from Alexandre Terrasa.

Pull-Request: #707
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agoMerge: Proposition of a new image source for `shoot`
Jean Privat [Wed, 3 Sep 2014 09:51:02 +0000 (05:51 -0400)]
Merge: Proposition of a new image source for `shoot`

The ressources are extracted from the projet PyCaptain. See `ships.svg`.

Pull-Request: #421
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agolib: add standard/error.nit
Jean Privat [Tue, 2 Sep 2014 18:37:36 +0000 (14:37 -0400)]
lib: add standard/error.nit

This could help people to implement some error handling in libraries.

It is inspired by #701 and ideas from Alexandre Terrasa.

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agopep8analysis: rename its Error class to P8Error.
Jean Privat [Tue, 2 Sep 2014 19:05:58 +0000 (15:05 -0400)]
pep8analysis: rename its Error class to P8Error.

One day, name conflicts will be resolved sanely... one day...

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: String: Bugfixes
Jean Privat [Wed, 3 Sep 2014 01:31:55 +0000 (21:31 -0400)]
Merge: String: Bugfixes

When rewriting the to_s method in Array, an error was subtle enough to fight its way through the tests but was discovered when reworking the Ropes (yup, be prepared, it'll appear once more).

Oh and there was a bug in the substring_from method (well, more of a lack of efficiency then a real bug).

Pull-Request: #699
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agolib/standard/string: reverse iterator fix on substring. Fixes #709
Lucas Bajolet [Tue, 2 Sep 2014 20:25:07 +0000 (16:25 -0400)]
lib/standard/string: reverse iterator fix on substring. Fixes #709

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: Nitunit: Allow external test files.
Jean Privat [Tue, 2 Sep 2014 20:17:19 +0000 (16:17 -0400)]
Merge: Nitunit: Allow external test files.

Unit testing can now be achieved in two ways:

* using `DocUnits` in code comments
* using `TestSuites` with test unit files

`DocUnits` are executable pieces of code found in the documentation of modules,
classes and properties.
They are used for documentation purpose, they should be kept simple and illustrative.
More advanced unit testing can be done using TestSuites.

`TestSuites` are test files coupled to a tested module.
They contain a list of test methods called TestCase.

## Working with `DocUnits`

With DocUnits, executable code can be placed in comments of modules, classes and properties.
 The execution can be verified using `assert`

 Example with a class:

    module foo
    #    var foo = new Foo
    #    assert foo.bar == 10
    class Foo
        var bar = 10
    end

 Everything used in the test must be declared.
To test a method you have to instanciate its class:

    module foo
    #    var foo = new Foo
    #    assert foo.bar == 10
    class Foo
        #    var foo = new Foo
        #    assert foo.baz(1, 2) == 3
        fun baz(a, b: Int) do return a + b
    end

 `nitunit` is used to test Nit files:

    $ nitunit foo.nit

## Working with `TestSuites`

 TestSuites are Nit files that define a set of TestCase for a particular module.

 The test suite must be called `test_` followed by the name of the module to test.
 So for the module `foo.nit` the test suite will be called `test_foo.nit`.

 The structure of a test suite is the following:

    # test suite for module `foo`
    module test_foo
    import foo # can be intrude to test private things
    class TestFoo
        # test case for `foo::Foo::baz`
        fun test_baz do
            var subject = new Foo
            assert subject.baz(1, 2) == 3
        end
    end

 Test suite can be executed using the same `nitunit` command:

    $ nitunit foo.nit

 `nitunit` will execute a test for each method named `test_*` in a class named `Test*`
 so multiple tests can be executed for a single method:

    class TestFoo
        fun test_baz_1 do
            var subject = new Foo
            assert subject.baz(1, 2) == 3
        end
        fun test_baz_2 do
            var subject = new Foo
            assert subject.baz(1, -2) == -1
        end
    end

 `TestSuites` also provide methods to configure the test run:

 `before_test` and `after_test`: methods called before/after each test case.
 They can be used to factorize repetitive tasks:

    class TestFoo
        var subject: Foo
        # Mandatory empty init
        init do end
        # Method executed before each test
        fun before_test do
            subject = new Foo
        end
        fun test_baz_1 do
            assert subject.baz(1, 2) == 3
        end
        fun test_baz_2 do
            assert subject.baz(1, -2) == -1
        end
    end

 When using custom test attributes, a empty init must be declared to allow automatic test running.

 `before_module` and `after_module`: methods called before/after each test suite.
 They have to be declared at top level:

    module test_bdd_connector
    import bdd_connector
    # Testing the bdd_connector
    class TestConnector
        # test cases using a server
    end
    # Method executed before testing the module
    fun before_module do
        # start server before all test cases
    end
    # Method executed after testing the module
    fun after_module do
        # stop server after all test cases
    end

## Generating test suites

 Write test suites for big modules can be a pepetitive and boring task...
 To make it easier, `nitunit` can generate test skeletons for Nit modules:

    $ nitunit --gen-suite foo.nit

 This will generate the test suite `test_foo` containing test case stubs for all public
 methods found in `foo.nit`.

 Useful options with `--gen-suite`:

* `--private`: also generate tests for protected and private methods
* `--force`: force generation of the skeleton (existing test suite will be overwritten)

Pull-Request: #627
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: Move `android::java_io` to `java::io`
Jean Privat [Tue, 2 Sep 2014 20:16:34 +0000 (16:16 -0400)]
Merge: Move `android::java_io` to `java::io`

Fix #696

Pull-Request: #705
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agotests: Added test for the special case of Array.to_s with a Rope.
Lucas Bajolet [Fri, 29 Aug 2014 19:53:43 +0000 (15:53 -0400)]
tests: Added test for the special case of Array.to_s with a Rope.

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agolib/standard/string: bugfix in Array::to_s when encoutering another structure than...
Lucas Bajolet [Fri, 29 Aug 2014 14:35:43 +0000 (10:35 -0400)]
lib/standard/string: bugfix in Array::to_s when encoutering another structure than a FlatString

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agolib/standard/string: Proper handling of trivial cases in substring_from.
Lucas Bajolet [Fri, 29 Aug 2014 19:45:34 +0000 (15:45 -0400)]
lib/standard/string: Proper handling of trivial cases in substring_from.

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agotests: update shoot_logic sav file
Alexis Laferrière [Tue, 2 Sep 2014 14:54:29 +0000 (10:54 -0400)]
tests: update shoot_logic sav file

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agonitunit: update tests.
Alexandre Terrasa [Tue, 2 Sep 2014 15:43:42 +0000 (11:43 -0400)]
nitunit: update tests.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agotests: remove java_io from cc.skip
Alexis Laferrière [Tue, 2 Sep 2014 15:02:53 +0000 (11:02 -0400)]
tests: remove java_io from cc.skip

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agoandroid: update users of `java::io`
Alexis Laferrière [Mon, 1 Sep 2014 15:57:11 +0000 (11:57 -0400)]
android: update users of `java::io`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agojava: move `android::java_io` to `java::io` & remove refs to android
Alexis Laferrière [Mon, 1 Sep 2014 15:55:51 +0000 (11:55 -0400)]
java: move `android::java_io` to `java::io` & remove refs to android

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agolib: java is a group
Alexis Laferrière [Mon, 1 Sep 2014 15:51:45 +0000 (11:51 -0400)]
lib: java is a group

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agoexamples/shoot: use new images
Alexis Laferrière [Sat, 3 May 2014 15:36:33 +0000 (11:36 -0400)]
examples/shoot: use new images

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agoexamples/shoot: add vectorial images from PyCaptain
Alexis Laferrière [Sat, 26 Apr 2014 01:02:04 +0000 (21:02 -0400)]
examples/shoot: add vectorial images from PyCaptain

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agoversion 0.6.8 v0.6.8
Jean Privat [Tue, 2 Sep 2014 13:05:35 +0000 (09:05 -0400)]
version 0.6.8

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Test libs
Jean Privat [Fri, 29 Aug 2014 19:16:42 +0000 (15:16 -0400)]
Merge: Test libs

Improve libs so that all tests on them pass.

Currently, ./testfull.sh does test only a subset of the files in lib/.
With this PR all files in lib are considered.

Changes are:

* some lib files are fixed to allow an independent build for each engine.
* targetless-mnit and linux-mnit automatically exit in a testing environment
* platforms tests are silent, so that niti and sav are easier to manage.

Pull-Request: #698
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agotests: testfull includes all sources in lib/
Jean Privat [Fri, 29 Aug 2014 03:33:12 +0000 (23:33 -0400)]
tests: testfull includes all sources in lib/

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: add java_io to cc.skip
Jean Privat [Thu, 28 Aug 2014 21:01:52 +0000 (17:01 -0400)]
tests: add java_io to cc.skip

See #696

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/string_exp: add a missing FFI `import UnicodeChar.len`
Jean Privat [Thu, 28 Aug 2014 20:42:47 +0000 (16:42 -0400)]
lib/string_exp: add a missing FFI `import UnicodeChar.len`

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/mnit: globally protect from NIT_TESTING
Jean Privat [Thu, 28 Aug 2014 20:42:00 +0000 (16:42 -0400)]
lib/mnit: globally protect from NIT_TESTING

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: add more .res (or skip) for some libs
Jean Privat [Thu, 28 Aug 2014 20:06:10 +0000 (16:06 -0400)]
tests: add more .res (or skip) for some libs

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: remove mnit_linux related tests from exec.skip
Jean Privat [Thu, 28 Aug 2014 03:06:15 +0000 (23:06 -0400)]
tests: remove mnit_linux related tests from exec.skip

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/mnit_linux: globally protect from NIT_TESTING
Jean Privat [Thu, 28 Aug 2014 03:01:08 +0000 (23:01 -0400)]
lib/mnit_linux: globally protect from NIT_TESTING

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: Not executable plateforms produce empty .res
Jean Privat [Thu, 28 Aug 2014 19:23:46 +0000 (15:23 -0400)]
tests: Not executable plateforms produce empty .res

This reduce the number of .res files and accommodate niti

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/android: use min_api_version in intent and shared_preferences
Jean Privat [Thu, 28 Aug 2014 18:56:55 +0000 (14:56 -0400)]
lib/android: use min_api_version in intent and shared_preferences

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Clean tests
Jean Privat [Fri, 29 Aug 2014 01:20:40 +0000 (21:20 -0400)]
Merge: Clean tests

Great scripts to test stuff; most come from unpublished scripts from our Jenkins instance.
A lot of cleaning in the tests/sav directory.
And some unpublished tests

The `search_tests.sh` script is quite useful to retrieve the original program for some test:
~~~.sh
$ ./search_tests.sh hello_world sav/base_var_type_evolution_null_alt3.res
../examples/hello_world.nit
base_var_type_evolution_null.nit
~~~

It will be also used by Jenkins to check that each sav/*res file has a corresponding test; since commit 'tests: add missing test files whose sav files where committed' show that sometime the .res are committed but without the corresponding .nit

The `search_tests_git.sh` looks in the git commit to found modified things to tests.
Basically, the simple usage is to perform all engines on the result:

~~~.sh
$ ./testall.sh `./search_tests_git.sh origin/master HEAD`
~~~

Pull-Request: #691
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agotests: add time and timestamp in tests.sh
Jean Privat [Thu, 28 Aug 2014 20:58:08 +0000 (16:58 -0400)]
tests: add time and timestamp in tests.sh

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: nitdoc: cache `concern_rank`
Jean Privat [Thu, 28 Aug 2014 21:06:44 +0000 (17:06 -0400)]
Merge: nitdoc: cache `concern_rank`

Improve performance of nitdoc by 60 times in some cases!

Fixes #692, nitdoc on RnR goes from 8 min to 7 sec.

Thanks-to: Jean Privat <jean@pryen.org>

Pull-Request: #695
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agotests: add search_tests_git.sh
Jean Privat [Thu, 28 Aug 2014 14:21:33 +0000 (10:21 -0400)]
tests: add search_tests_git.sh

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: add search_tests.sh to retrieve the original nit files of tests
Jean Privat [Thu, 28 Aug 2014 05:13:11 +0000 (01:13 -0400)]
tests: add search_tests.sh to retrieve the original nit files of tests

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: activate some exising tests in examples/
Jean Privat [Thu, 28 Aug 2014 04:51:35 +0000 (00:51 -0400)]
tests: activate some exising tests in examples/

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: add missing test files whose sav files where committed
Jean Privat [Thu, 28 Aug 2014 04:42:06 +0000 (00:42 -0400)]
tests: add missing test files whose sav files where committed

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: remove remaining and obsolete sav/ files
Jean Privat [Thu, 28 Aug 2014 20:31:33 +0000 (16:31 -0400)]
tests: remove remaining and obsolete sav/ files

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: split testfull.sh into listfull.sh that just lists testfiles
Jean Privat [Thu, 28 Aug 2014 03:33:53 +0000 (23:33 -0400)]
tests: split testfull.sh into listfull.sh that just lists testfiles

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: fix errlist
Jean Privat [Thu, 28 Aug 2014 02:37:34 +0000 (22:37 -0400)]
tests: fix errlist

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agomisc: make public some scripts used by Jenkins
Jean Privat [Thu, 28 Aug 2014 02:16:20 +0000 (22:16 -0400)]
misc: make public some scripts used by Jenkins

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agonitdoc: cache `concern_rank`
Alexis Laferrière [Thu, 28 Aug 2014 16:07:07 +0000 (12:07 -0400)]
nitdoc: cache `concern_rank`

Improve performance of nitdoc by 60 times in some cases!

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agoMerge: Less OES in opengles
Jean Privat [Thu, 28 Aug 2014 16:03:41 +0000 (12:03 -0400)]
Merge: Less OES in opengles

Because of things explained in the debian bug [754397](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=754397), the compilation of mnit project fails on linux systems with a recent mesa library.

One way to solve the problem is to not rely on the OES symbols that cause the issue.
Fortunately, it seems that classes and methods that use those symbols are unused and tagged broken, so just remove them.

Closes #689
Closes #677

Pull-Request: #694
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agolib/mnit/opengles: cleanup C dependencies.
Jean Privat [Thu, 28 Aug 2014 15:05:15 +0000 (11:05 -0400)]
lib/mnit/opengles: cleanup C dependencies.

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/mnit/opengles1.nit: remove unused part that rely on _OES symbols
Jean Privat [Thu, 28 Aug 2014 15:04:22 +0000 (11:04 -0400)]
lib/mnit/opengles1.nit: remove unused part that rely on _OES symbols

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Calculator refactor & numerics proposition
Jean Privat [Thu, 28 Aug 2014 05:15:41 +0000 (01:15 -0400)]
Merge: Calculator refactor & numerics proposition

* Modularize calculator.nit into 3 modules and move to a project structure.
* Rewrite the code behind the displayed string.
* Use numerics to switch nicely between `Float` and `Int`
* No more weird bug with the C button.

The Android UI will follow in another PR.

Pull-Request: #646
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agonitunit: add README for group `testing` and redirect from nitunit doc.
Alexandre Terrasa [Sat, 2 Aug 2014 17:48:47 +0000 (13:48 -0400)]
nitunit: add README for group `testing` and redirect from nitunit doc.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agonitunit: allow test-suite skeleton generation.
Alexandre Terrasa [Wed, 27 Aug 2014 06:10:11 +0000 (02:10 -0400)]
nitunit: allow test-suite skeleton generation.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agonitunit: allow testing from external files called test-suites.
Alexandre Terrasa [Wed, 27 Aug 2014 06:09:39 +0000 (02:09 -0400)]
nitunit: allow testing from external files called test-suites.

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agocalculator: add Makefile
Alexis Laferrière [Wed, 6 Aug 2014 00:48:35 +0000 (20:48 -0400)]
calculator: add Makefile

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agocalculator: major logic refactor, move up display code & use numerics
Alexis Laferrière [Sun, 3 Aug 2014 19:11:01 +0000 (15:11 -0400)]
calculator: major logic refactor, move up display code & use numerics

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agocalculator: move to a project folder
Alexis Laferrière [Sun, 3 Aug 2014 14:54:14 +0000 (10:54 -0400)]
calculator: move to a project folder

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>