Commit Graph
2497 Commits
Author SHA1 Message Date
Otto Lin 989553d7bf Add Date/Time/NaiveDateTime.compare/2 (#5349) 2016-10-24 08:55:44 +02:00
José Valim f0b84922d9 Ensure we consistently wrap variables in quotes 2016-10-22 22:25:18 +02:00
Aleksei Magusev 582e8be0c1 Restructure doc samples in DocsTest 2016-10-22 21:12:09 +02:00
Aleksei Magusev 50a4831a82 Test all available doc kinds in the test for Code.get_docs/2 2016-10-22 20:53:37 +02:00
Aleksei Magusev c3ae2a4efa Fully validate the shape of the options for import/2 2016-10-22 20:53:34 +02:00
Aleksei Magusev 1e0d26d139 Favor ==/2 operator over match in assertions 2016-10-22 20:50:19 +02:00
Aleksei Magusev 35a4ecbb69 Make actual testing of doc attributes instead of occasional matching 2016-10-22 20:50:19 +02:00
Eksperimental 20e835020a File.rmdir!/1: give a less confusing error message when directory is not empty (#5299) 2016-10-14 11:39:55 +02:00
Eksperimental 029e92b5c7 Enforce rule of only guards should start with "is_" (#5300) 2016-10-13 10:05:38 +02:00
Eksperimental aa030d22cd Reword "pseudo-variables" with "compilation environment macros" (#5308)
As discussed in https://github.com/elixir-lang/elixir/pull/5301#pullrequestreview-3711427.
2016-10-12 00:49:47 +02:00
Aleksei Magusev 1e75af0046 Add test for unused var warning when defined inside case/2 (and similar)
819d81c28e commit has brought this warning and fixed #5024 issue.
2016-10-10 23:39:24 +02:00
Aleksei Magusev a1e5ab1c4f Enhance Dialyzer test for and/2 and or/2 expansion 2016-10-09 16:49:15 +02:00
Aleksei Magusev 41789b186a Suppress unused variable warning in Kernel.FnTest 2016-10-09 12:40:32 +02:00
Aleksei Magusev 2969eca83f Simplify assertion formatting in Kernel.FnTest 2016-10-09 12:38:34 +02:00
Aleksei Magusev 0554391852 Merge pull request #5295 from lexmag/new-and
Compile or/2 and and/2 to case/2 when in non-guard context
2016-10-09 11:02:31 +02:00
Aleksei Magusev cbe86c9b83 Add Dialyzer test for and/2 and or/2 expansion 2016-10-08 23:38:23 +02:00
Aleksei Magusev d4d546bf6a Add test for variable usage during in/2 expansion 2016-10-08 22:54:19 +02:00
José Valim c19ed9f910 Introduce Float.ratio/1 and fix Float.{ceil/2, floor/2, round/2}
The previous implementations for ceil, floor and round were
not formalized and were likely prone to multiple roundings
as we performed multiplication and division by a power of
10 on the given float.

The new implementation correctly converts the float to an
exact integer representation and perform all operations using
arbitrary precision integers. The only float operation occurs
when converting the ratio back to a float.

The current implementation is more expensive due to its reliance
on big integers. Faster implementations are available in literature
where the latest one seems to be Errol:

  https://cseweb.ucsd.edu/~lerner/papers/fp-printing-popl16.pdf

This change also introduces Float.ratio/1 which receives a
float and returns a pair of integers whose ratio is exactly equal
to the original float and with a positive denominator.

Closes #3400
2016-10-07 18:46:33 +02:00
Aleksei Magusev 9d67a0262b Expand in/2 test samples only once 2016-10-07 01:29:20 +02:00
Ben Olive 181450530a Implement Stream.zip/1 and Enum.zip/1 (#5289) 2016-10-04 16:12:07 +02:00
Magnus Lång 8bd6c17a6b Fix Dialyzer warnings on opaque protocol calls (#5286)
Prior to this change, calling a protocol function with an opaque type
would yield a warning, as Dialyzer concludes that the impl_for/1
function can't handle opaque arguments, since all clauses would
destructure their arguments in some way.

By adding a catch-all clause that does not destructure its argument,
Dialyzer no longer draws this conclusion, and the warnings go away.

As noted in the protocol.ex comment, this is technically a hack as it
relies on Dialyzer not being smart enough. However, I would not expect
it to break soon, if ever.
2016-10-04 14:17:11 +02:00
Michał Muskała 5054a26145 Fix Macro.to_string when printing keywords (#5270)
It was incorrect when given a literal atom resembling an alias.

Fixes #5268
2016-09-29 10:48:01 +02:00
James Fish 662ecf9be7 Fix Task.shutdown/1,2 infinite block when no monitor (#5252)
If the monitor no longer exists Task.shutdown/2 would block forever
waiting for it. Always setup new monitor and try to get the right down
result.
2016-09-25 19:13:44 +01:00
Aleksei Magusev 25e51bb498 Add extra test for string concatenation as match usage
This case has been fixed in 78c7ddc03f.
2016-09-25 01:44:20 +02:00
Alexei Sholik cf8f7c96a2 Use singular names for time units, as in Erlang/OTP 19.1. Fix #5236 (#5244) 2016-09-22 23:28:13 +03:00
Aleksei Magusev 9cd972dbde Remove unnecessary whitespaces in "colors" test for IO.ANSI 2016-09-21 23:41:00 +02:00
José Valim 8e2a1e5851 Remove Kernel.rand/0 and Kernel.rand/1
Since Enum.random/1 already provides the Kernel.rand/1
functionality.
2016-09-21 23:39:33 +02:00
James Fish 357bb4f914 Update dialyzer tests for OTP-19.1/dialyzer-3.0.2 2016-09-21 15:31:46 +01:00
ToadJamb 2cd5506fba Add light foreground and background colors to IO.ANSI (#5231) 2016-09-20 11:09:24 +02:00
Aleksei Magusev 742cb73097 Tidy up Enum.concat/1,2 tests 2016-09-20 00:57:54 +02:00
Vitalii Elenhaupt 810965e193 Extended test suite for Enum.concat/2 (#5229) 2016-09-19 11:32:28 +02:00
Aleksei Magusev e6971f966c Return given value value in Module.put_attribute/3 (#5218) 2016-09-15 11:12:02 +02:00
José Valim 8d2c5baa9b Add DateTime.from_naive/2 2016-09-15 10:09:31 +02:00
José Valim 50293b46f1 Keep markdown formatting on IO.ANSI.Docs
The previous format would use | before code blocks
and would remove # from headings, we have reverted
those changes to make the printed documentation and
help be closer to what it would look on source while
providing more information (in the case of headings).
2016-09-13 22:05:49 +02:00
José Valim 0396197026 Ensure take/2 does not consume next element on suspend 2016-09-11 00:05:53 +02:00
Michał Muskała dadf98fbff Introduce Process.send_after/4 (#5182) 2016-09-07 22:39:12 +02:00
José Valim b0102791c5 Correctly use stack name in all commands 2016-09-07 14:06:13 +02:00
José Valim 024a958726 Avoid naming conflicts 2016-09-07 13:53:00 +02:00
José Valim 6b6382a445 Ensure lhs of in/2 is expanded only once 2016-09-07 13:35:40 +02:00
José Valim 786da1ffe0 Add Kernel.rand/0 and Kernel.rand/1
Thanks to Hal Fulton for the proposal and original code.
2016-09-07 13:07:52 +02:00
Andrea Leopardi d977e6dd4a Wrap fn calls in parens in Macro.to_string/1 (#5170)
Right now, application of anonymous function literals in
Macro.to_string/2 is represented like this:

    iex> Macro.to_string(quote do: (fn x -> x end).(1))
    "fn x -> x end.(1)"

While this is valid, I think it's far more common to have such calls
with the literal fn wrapped in parens:

    (fn x -> x end).(1)

This commit makes Macro.to_string/2 behave like this.
2016-08-28 17:34:59 +02:00
Andrea Leopardi 97796f4d55 Improve UndefinedFunctionError when using macros without require (#5156) 2016-08-26 23:51:25 +02:00
Andrea Leopardi 1b94cc7322 Don't crash in macro_exported?/3 when dealing with Erlang modules (#5165)
Right now, Kernel.macro_exported?/3 blindly calls __info__/1 on the
given module, but since __info__/1 is defined by Elixir when compiling
modules, this breaks if an Erlang module is passed to
macro_exported?/3. This commit fixes this behaviour by always returning
"false" in macro_exported?/3 when an Erlang module is given.
2016-08-26 20:20:58 +02:00
Aleksei Magusev eb67c2b21b Fix {Enum, Stream}.map_every/3 behaviour when nth is 0 2016-08-19 23:37:40 +02:00
Aleksei Magusev e0b1cf45c7 Fix DateTime.from_unix!/2 to actually raise ArgumentError 2016-08-19 22:47:03 +02:00
José Valim 00d47ba522 Refactor and optimize aggregations over lists 2016-08-15 22:02:28 +02:00
Myron Marston 21d235bacc Add min/2, max/2 and min_max/2 to Enum (#5140) 2016-08-15 21:30:21 +02:00
Michał Muskała 8277dcd776 Make sure bad remote call errors have file/line info (#5116)
Change how we mark the generated AST for suppressing dialyzer errors -
instead of [generated: true, location: 0], we provide proper line number.
This means, however, that on OTP 18, those nodes won't be recognized
as generated and warnings will be issued.
It was decided that proper error messages are more important than
avoiding bogus dialyzer warnings.
The old mark for generated code is left in places that made compiler
issue warnings on 18.

The bad remote call dialyzer warnings can be suppressed with the
@dialyzer :no_fail_call
module attribute.
2016-08-15 13:18:09 +01:00
Otto Lin c26c269834 Support Enum.map_every/3 and Stream.map_every/3 (#5141) 2016-08-14 14:27:14 +02:00
Aleksei Magusev c1c53da900 Rename args -> argv in OptionParserTest 2016-08-13 14:08:37 +02:00