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>
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>
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>
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>
Jean Privat [Wed, 3 Sep 2014 14:19:04 +0000 (10:19 -0400)]
src: cleanup importations
Signed-off-by: Jean Privat <jean@pryen.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Jean Privat [Thu, 28 Aug 2014 02:37:34 +0000 (22:37 -0400)]
tests: fix errlist
Signed-off-by: Jean Privat <jean@pryen.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Alexis Laferrière [Thu, 21 Aug 2014 18:23:27 +0000 (14:23 -0400)]
lib: intro the `standard::numeric` module
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Jean Privat [Wed, 27 Aug 2014 20:26:49 +0000 (16:26 -0400)]
Merge: phase: Do not revisit all annotations for each phase
Instead of one visit per phase per module, do one single visit per module that collect the nodes.
With the standard `nitg nitg.nit`, the gain is approx 4%. Not so bad.
Pull-Request: #690
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Wed, 27 Aug 2014 15:40:58 +0000 (11:40 -0400)]
phase: Do not revisit all annotations for each phase
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 27 Aug 2014 15:11:16 +0000 (11:11 -0400)]
Merge: Less char boxings
Because of the way the boxing is done in nitg-s, the services in the `Text::chars` view cause unnecessary boxing of chars.
After profiling, we found that the biggest consumers of such boxing are `Lexer::get_token` and `BufferedIStream::read_all`.
Thus, the idea is to implement a efficient `Text::[]` method that do not use the `chars` view. Then to update the two consumers to use it instead.
With `nitg nitg.nit`, the total gain is approx 5%, and the number of boxes of char is reduced by 70% (from 4.8Mboxes to 1.4Mboxes).
Note: this is only an easy workaround until the boxing is done better in nitg (mid-term goal)
Pull-Request: #688
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Wed, 27 Aug 2014 15:11:12 +0000 (11:11 -0400)]
Merge: Clean make
The various Makefile need some love. So, a new recipe `full` can be used to build programs from examples and contrib.
The `clean` recipe is also updated to work and clean stuff.
However, some questions:
1. Should the `clean` recipe clean the binaries? I did not fine a definitive answer on the Internet.
2. Should the binaries be .gitignored?
Note: In a near future, Jenkins may also check that all the Makefile, and their `clean` work as expected.
Pull-Request: #687
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Wed, 27 Aug 2014 06:06:46 +0000 (02:06 -0400)]
nitunit: factorize test_dir processing into test_base.
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Alexandre Terrasa [Wed, 27 Aug 2014 06:09:00 +0000 (02:09 -0400)]
nitunit: split module into one executable and a group named `testing`.
Introduce module `test_doc` that implements "doc-units".
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Wed, 27 Aug 2014 03:42:44 +0000 (23:42 -0400)]
contrib/sort_downloads: use relative nitg binary
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 26 Aug 2014 17:53:05 +0000 (13:53 -0400)]
Makefile: clean the clean recipes
And remove the useless dist-clean recipe
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 27 Aug 2014 02:15:47 +0000 (22:15 -0400)]
parser: Lexer.get_token use String[j] instead of String.chars[]
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 27 Aug 2014 02:15:02 +0000 (22:15 -0400)]
lib/stream: BufferedIStream.read_all use Buffer[j] instead of Buffer.chars[]
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 27 Aug 2014 02:11:56 +0000 (22:11 -0400)]
lib/string: redefine [] for FlatString and FlatBuffer without using chars
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 26 Aug 2014 17:14:39 +0000 (13:14 -0400)]
Makefile: add recipe `full` to build examples and programs.
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 27 Aug 2014 00:52:45 +0000 (20:52 -0400)]
examples/mnit_*: add icon in .gitignore
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 26 Aug 2014 17:32:51 +0000 (13:32 -0400)]
examples/mnit_*: add Makefile recipe to build svg_to_icons
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 27 Aug 2014 00:49:23 +0000 (20:49 -0400)]
leapfrog: add .gitignore
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 26 Aug 2014 17:33:05 +0000 (13:33 -0400)]
leapfrog: fix Makefile
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 27 Aug 2014 00:48:30 +0000 (20:48 -0400)]
online_ide: add .gitignore
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 26 Aug 2014 18:02:55 +0000 (14:02 -0400)]
jwrapper: add .gitignore
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 27 Aug 2014 00:42:10 +0000 (20:42 -0400)]
nitcc: .gitignore .out files
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 27 Aug 2014 00:40:02 +0000 (20:40 -0400)]
nitcc: generate info files with .out instead of .txt
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 27 Aug 2014 00:48:01 +0000 (20:48 -0400)]
gitignore: ingore all bin/ and doc/ in examples/
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 26 Aug 2014 22:56:25 +0000 (18:56 -0400)]
Merge: lib/standard: optimize Array.to_s
Micro-optimized version of Array::to_s based on the results of benchmarks available in PR #685.
`./bin/nitg ./src/nitg.nit`
Before : `15.080 s`
After : `13.928 s`
Pull-Request: #686
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 26 Aug 2014 22:54:40 +0000 (18:54 -0400)]
Merge: Bench string
Added a few benches for variations of String and Array.
Also added a array_debug module on the same idea as hash_debug (PR #664) to track the use of to_s in Array (other functions may be supported someday if needed).
The UTF-8 benchmarks only work with the no-index version for now.
Pull-Request: #685
Reviewed-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 26 Aug 2014 22:53:45 +0000 (18:53 -0400)]
Merge: Utf8 strings - noindex
Added a few features missing from UTF8 Strings without index.
NOTE : It is slow and space-consuming (lots of allocated characters and no GC), however by experimenting a bit (read : force UnicodeChar as a Universal intern class), the performance is surprisingly close to the old ones and the memory-use becomes acceptable once again :
* < 10% loss for iteration (with iterator, not index, this is much slower) and concat
* substring is slower by a significant margin (75%), however considering the cost of the ancient one (close to none), I guess this is still acceptable.
Pull-Request: #684
Reviewed-by: Jean Privat <jean@pryen.org>
Lucas Bajolet [Tue, 26 Aug 2014 19:56:04 +0000 (15:56 -0400)]
tests: Update tests for conformance with modifications.
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
Lucas Bajolet [Tue, 26 Aug 2014 18:27:57 +0000 (14:27 -0400)]
lib/standard/string: Array.to_s micro-optimization
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
Lucas Bajolet [Tue, 26 Aug 2014 18:32:46 +0000 (14:32 -0400)]
lib/standard/array: new NativeArray/NativeString are now usable everywhere.
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
Lucas Bajolet [Tue, 26 Aug 2014 14:40:12 +0000 (10:40 -0400)]
lib/array_debug: Added array_debug module to keep stats on Array use in a program.
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
Lucas Bajolet [Thu, 21 Aug 2014 19:23:59 +0000 (15:23 -0400)]
benchmarks/string: Added benchmark for Array.to_s
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
Jean Privat [Tue, 26 Aug 2014 15:28:02 +0000 (11:28 -0400)]
c_src: Fix uname in Makefile
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 26 Aug 2014 00:55:47 +0000 (20:55 -0400)]
Merge: New constructors
A very long development for a very important but experimental feature: the new-style constructors.
Most of the cleaning and other stuff was committed under interdependent PR.
So what remain here is the hardcore fundamental stuff.
I didn't find a simple way to have nice commits. So I went for some kind of incremental features.
## First commit
It is the worse since it introduces the new-style constructors in the model, semantic analysis and engines.
With the new-style constructors, the point is to understand that the syntax `var a = new A(some_b)` is in fact the following sequence
~~~
var a = ALLOC_INSTANCE(A)
a.b=(some_b)
a.init()
~~~
Where the `a.b=` part is a standard method call for the accessor `b=`.
Therefore, each constructor has a sequence of methods to call, they are called `initializers`.
Since redefinitions of constructor can provide different initializers, the initializers are attached to the MMethodDef class.
Because of this, a MMethodDef for a new-style constructor has two signatures, the real empty msigntature seen by the programmer that implements the constructor, and the one seen by the programmer that uses it to instantiate objects trough `new`, so called `new_msignature`.
~~~
class A
var b: B
# here, an implicit init, with, by rule of inheritance, the empty signature
end
var a = new A(some_b) # here the `new` takes a single B
~~~
Note that the `new_msignature` has to be conform with the `inititializers` since the arguments of the `new` are used for the invocations of the inititializers.
Modules `modelize_property` (and `auto_super_init` in a lesser extend) is modified to use new-style constructors for the default/automatic/free/implicit constructors.
Explicit constructors (named or not) use the old-style-constructors.
The code in these two modules is quite complex because it has to deal with the various implicit combinations of the old-style and new-style constructors.
For the engines (and rta), modifications are made to handle correctly the implementations of:
1. the invocation of the new-style constructors. by invoking each initializer, and
2. the implicit body of the new-style default/automatic/free/implicit constructors; they do just a call to super since the initializations of the attributes is done outside the init: in the sequence code of the new.
While user-defined constructor is not present in this commit, all the implicit init are converted.
The boostrap still works, and most tests pass.
## Second commit
Just introduce (and use) the annotation `old_style_init` that is used to mark explicit constructors to use the old semantic (and implementation).
The annotation can be put on a single `init`, or on the whole module.
## Third commit
'simple' `init` are those defined without name nor parameters (and that are public).
They are converted to the new-style constructors.
This is just magic because things, like the boostrap and most tests, still work as expected.
Now, programmers can use the default init and get the initializers automatically called.
Basically, instead of writing
~~~
class A
var b: B
init(b: B)
do
self.b = b
rest_of_init
end
end
var a = new A(some_b)
~~~
just write
~~~
class A
var b: B
init
do
rest_of_init
end
end
var a = new A(some_b) # Same client, but less code in the A class
~~~
And simple subclasses get easier
~~~
class SubA
super A
var c: C
init
do
some_other_stuff
end
end
var sa = new SubA(some_b, some_c)
# Done in order:
# 1. set b
# 2. set c
# 3. rest_of_init
# 4. some_other_stuff
~~~
## Fourth commit
Update existing tests.
## Last commit
add a new test that illustrates combination and the linearization of the simple init
## What is next?
### User-definer initializers
Conflict on initializers are detected, but currently there is no simple way for the used to define its own sequence of initializers.
* what syntax to use? something like `init is initializers(a,b,c) do ...`?
* what rules? are any sequence allowed?
### Not-simple constructors
The status of the constructors that remains is still unclear.
* named constructors are the simpler case since the proposed specification want to have them working like standard method but usable with a new. In fact, they will behave as a simple version of the old-style-constructors, with less shenanigans.
* init with parameters, still accepted for compatibility but they should be migrated. If not migratable, more investigation and thinking will be required
* private init. Since the root `init` of Object is public, subclasses cannot change its visibility. So how to indicate that a class cannot be instantiated publicly? Again, more investigation and thinking.
Pull-Request: #679
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Jean Privat [Wed, 20 Aug 2014 01:43:12 +0000 (21:43 -0400)]
tests: add base_init_basic.nit
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 20 Aug 2014 00:52:23 +0000 (20:52 -0400)]
tests: update to pass tests
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Wed, 20 Aug 2014 00:37:50 +0000 (20:37 -0400)]
modelize_property: simple inits are new-style
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Mon, 25 Aug 2014 17:01:13 +0000 (13:01 -0400)]
Merge: tests: do not check whitespace errors in *.res files
Pull-Request: #682
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Lucas Bajolet [Mon, 25 Aug 2014 16:47:04 +0000 (12:47 -0400)]
string_exp/utf8_noindex: Update README
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
Lucas Bajolet [Mon, 25 Aug 2014 16:43:09 +0000 (12:43 -0400)]
lib/string_exp/utf8_noindex: Access is now done from the nearest point of insertion (begin, end or cache)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
Jean Privat [Sat, 23 Aug 2014 19:59:09 +0000 (15:59 -0400)]
tests: do not check whitespace errors in *.res files
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Sat, 23 Aug 2014 19:49:58 +0000 (15:49 -0400)]
Merge: Intro `user/group_exists` and apply a few small fixes
Pull-Request: #678
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Alexis Laferrière [Fri, 18 Jul 2014 16:01:08 +0000 (12:01 -0400)]
lib/curl: use more precise return types
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Lucas Bajolet [Mon, 18 Aug 2014 17:22:07 +0000 (13:22 -0400)]
bench/strings: Added bench for UTF-8 strings without index
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
Jean Privat [Wed, 20 Aug 2014 00:36:41 +0000 (20:36 -0400)]
src: new annotation old_style_init
Signed-off-by: Jean Privat <jean@pryen.org>
Jean Privat [Tue, 19 Aug 2014 23:53:37 +0000 (19:53 -0400)]
src: introduce new constructors
Signed-off-by: Jean Privat <jean@pryen.org>
Alexis Laferrière [Fri, 1 Aug 2014 23:19:44 +0000 (19:19 -0400)]
lib/privileges: prevent seg faults with asserts and require in doc
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Fri, 1 Aug 2014 23:19:08 +0000 (19:19 -0400)]
lib: intro `user_exists` and `group_exists`
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Alexis Laferrière [Wed, 6 Aug 2014 17:45:22 +0000 (13:45 -0400)]
sendmail: fix missing empty line between header and body
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Jean Privat [Tue, 19 Aug 2014 00:33:07 +0000 (20:33 -0400)]
Merge: Auto super init call next method
If one redefines a constructor in a subclass (a real redefinition, not just a look-alike init with the same name) the auto-super-init phase automatically inserted a call to a compatible constructor in the super-class, so a call to itself, so a fatal infinite recursive call :/
It is an old bug, but nobody did real redefinitions of constructors, except that it will be the norm with the new constructors. So just let solve the bug now, before people start to complain.
Pull-Request: #676
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Lucas Bajolet [Mon, 18 Aug 2014 15:59:07 +0000 (11:59 -0400)]
lib/string_exp/utf8_noindex: Added cache for last access.
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>