Skip to content

Commit

Permalink
Fix 'ambiguous' test, re-add tests, add NEWS and differences with R
Browse files Browse the repository at this point in the history
  • Loading branch information
nalimilan committed Dec 2, 2017
1 parent a4f57b6 commit 31031cd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ New language features
`@generated` and normal implementations of part of a function. Surrounding code
will be common to both versions ([#23168]).

* The `missing` singleton object (of type `Missing`) has been added to represent
missing values ([#24653]). It propagates through standard operators and mathematical functions,
and implements three-valued logic, similar to SQLs `NULL` and R's `NA`.

Language changes
----------------

Expand Down Expand Up @@ -1666,3 +1670,4 @@ Command-line option changes
[#24320]: https://github.com/JuliaLang/julia/issues/24320
[#24396]: https://github.com/JuliaLang/julia/issues/24396
[#24413]: https://github.com/JuliaLang/julia/issues/24413
[#24653]: https://github.com/JuliaLang/julia/issues/24653
5 changes: 4 additions & 1 deletion doc/src/manual/noteworthy-differences.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ For users coming to Julia from R, these are some noteworthy differences:
code is often achieved by using devectorized loops.
* Julia is eagerly evaluated and does not support R-style lazy evaluation. For most users, this
means that there are very few unquoted expressions or column names.
* Julia does not support the `NULL` type.
* Julia does not support the `NULL` type. The closest equivalent is [`nothing`](@ref), but it
behaves like a scalar value rather than like a list. Use `x == nothing` instead of `is.null(x)`.
* In Julia, missing values are represented by the [`missing`](@ref) object rather than by `NA`.
Use [`ismissing(x)`](@ref) instead of `isna(x)`.
* Julia lacks the equivalent of R's `assign` or `get`.
* In Julia, `return` does not require parentheses.
* In R, an idiomatic way to remove unwanted values is to use logical indexing, like in the expression
Expand Down
2 changes: 2 additions & 0 deletions test/ambiguous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ end
pop!(need_to_handle_undef_sparam, which(Base.convert, Tuple{Type{Union{Missing, T}} where T, Any}))
pop!(need_to_handle_undef_sparam, which(Base.promote_rule, Tuple{Type{Union{Missing, S}} where S, Type{T} where T}))
pop!(need_to_handle_undef_sparam, which(Base.zero, Tuple{Type{Union{Missing, T}} where T}))
pop!(need_to_handle_undef_sparam, which(Base.one, Tuple{Type{Union{Missing, T}} where T}))
pop!(need_to_handle_undef_sparam, which(Base.oneunit, Tuple{Type{Union{Missing, T}} where T}))
@test need_to_handle_undef_sparam == Set()
end
end
Expand Down
4 changes: 4 additions & 0 deletions test/missing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ Base.one(::Type{Unit}) = 1
@test oneunit(Union{T, Missing}) === T(1)
end

@test_throws MethodError zero(Union{Symbol, Missing})
@test_throws MethodError one(Union{Symbol, Missing})
@test_throws MethodError oneunit(Union{Symbol, Missing})

for T in (Unit,)
@test zero(Union{T, Missing}) === T(0)
@test one(Union{T, Missing}) === 1
Expand Down

0 comments on commit 31031cd

Please sign in to comment.