Files
Nim/tests
Vindaar e80be6173d Add parse bin int, fixes #8018 (#8020)
* clarify `parseHexInt`, `parseOctInt` docstring and exception msgs

* add `parseBinInt` based on `parseutil.parseBin` implementation

Adds a `parseBinInt`, which parses a binary integer string and returns
it as an integer. This is based on the implementation of
`parseutil.parseBin`, removing the unnecessary parts.

* add tests for all `parse(Hex|Oct|Bin)Int` procs

* replace `parse*Int` proc impls by call to parseutil procs

Replaces the `parse(Hex|Oct|Bin)Int` procedure implementation by calls
to the `parseutil` procs, which receive a mutable argument.

Has the main advantage that the empty string as well as a "prefix
only" string, e.g. "0x" counts as an invalid integer.

Also moves the `parseOctInt` proc further up in the file so that all
`parse` procs are below one another.

* replace `var L` by `let L` in `parse` procs

There's no reason for the usage of `var` here.

* add `maxLen` optional arg for `parseutil.parse(Oct|Bin)`

Plus small change to test cases.

* update changelog about `parse*Int` procs

* fix `rejectParse` template in `tstrutils`

* make sure only `s.len` chars are parsed, if `maxLen+start` > s.len

Fixes a previous bug in `parseHex` (and now affected `parseOct` and
`parseBin`), which allowed to set `start + maxLen` to be larger than
the strings length. This resulted in an out of bounds access.

* move `parse*Int` proc change to breaking changes, add double `
2018-06-13 13:32:12 -04:00
..
2017-07-25 09:28:23 +02:00
2018-04-24 11:45:08 +02:00
2018-06-10 23:42:53 +03:00
2018-02-10 20:55:22 +01:00
2015-03-17 17:50:32 +01:00
2018-04-06 10:53:21 +02:00
2018-03-23 13:28:22 +01:00
2018-02-10 20:55:22 +01:00
2018-02-10 20:55:22 +01:00
2018-05-02 13:34:54 +02:00
2014-01-13 02:10:03 +01:00
2018-02-10 20:55:22 +01:00
2018-05-02 13:34:54 +02:00
2018-05-14 21:38:18 +02:00
2018-05-02 13:34:54 +02:00
2018-06-10 22:27:51 +03:00
2018-05-02 13:34:54 +02:00
2018-05-02 13:34:54 +02:00
2018-05-05 21:45:07 +02:00
2018-01-18 09:04:32 +01:00
2018-06-10 22:27:51 +03:00
2018-06-07 15:28:41 +03:00
2018-04-15 17:34:03 +02:00
2018-01-21 03:04:22 +01:00
2018-02-10 20:55:22 +01:00
2016-08-04 19:36:13 +02:00
2018-06-13 12:18:21 +02:00
2018-05-02 13:34:54 +02:00
2018-05-02 13:34:54 +02:00
2018-04-30 02:56:19 +02:00
2018-02-10 20:55:22 +01:00
2018-05-02 13:34:54 +02:00
2018-05-14 21:38:18 +02:00
2016-01-05 07:52:56 +07:00
2018-05-02 13:34:54 +02:00
2018-05-02 13:34:54 +02:00
2017-11-18 23:03:16 +01:00
2017-02-01 12:09:24 +01:00
2018-04-06 13:10:22 +02:00
2018-06-06 02:22:33 -03:00
2018-05-25 16:21:33 +02:00
2018-05-05 21:45:07 +02:00
2018-06-06 22:29:31 +07:00
2018-05-14 21:38:18 +02:00
2017-07-25 09:28:23 +02:00
2018-04-21 23:58:24 +02:00
2018-06-04 13:38:26 +02:00
2013-03-16 23:53:07 +01:00

This directory contains the test cases.

Each test must have a filename of the form: t*.nim

Note: Tests are only compiled by default. In order to get the tester to execute the compiled binary, you need to specify a spec with an action key (see below for details).

Specs

Each test can contain a spec in a discard """ ... """ block.

Check out the parseSpec procedure in the specs module for a full and reliable reference

action

Specifies what action this test should take.

Default: compile

Options:

  • compile - compiles the module and fails the test if compilations fails.
  • run - compiles and runs the module, fails the test if compilation or execution of test code fails.
  • reject - compiles the module and fails the test if compilation succeeds.

There are certain spec keys that imply run, including output and outputsub.

cmd

Specifies the Nim command to use for compiling the test.

There are a number of variables that are replaced in this spec option:

  • $target - the compilation target, e.g. c.
  • $options - the options for the compiler.
  • $file - the filename of the test.
  • $filedir - the directory of the test file.

Example:

discard """
  cmd: "nim $target --nimblePath:./nimbleDir/simplePkgs $options $file"
"""

Categories

Each folder under this directory represents a test category, which can be tested by running koch tests cat <category>.

The folder rodfiles contains special tests that test incremental compilation via symbol files.

The folder dll contains simple DLL tests.

The folder realtimeGC contains a test for validating that the realtime GC can run properly without linking against the nimrtl.dll/so. It includes a C client and platform specific build files for manual compilation.