Skip to content

Commit

Permalink
fix several method overwrites in the test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jan 22, 2016
1 parent 6d4e848 commit da7b49d
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 57 deletions.
1 change: 0 additions & 1 deletion examples/lru.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ BoundedLRU() = BoundedLRU{Any, Any}()

isempty(lru::LRU) = isempty(lru.q)
length(lru::LRU) = length(lru.q)
haskey(lru::LRU, key) = haskey(lru.ht, key)

## associative ##

Expand Down
8 changes: 1 addition & 7 deletions test/ccall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ b = ccall((:test_1, libccalltest), Struct1, (Struct1,), a)
@test !(a === b)
@test b.x == s1.x + 1 && b.y == s1.y - 2

function foos1(s::Struct1)
@test !(s === a)
@test s == a
s
end

ci32 = Complex{Int32}(Int32(10),Int32(31))
ba = ccall((:test_2a, libccalltest), Complex{Int32}, (Complex{Int32},), ci32)
bb = ccall((:test_2b, libccalltest), Complex{Int32}, (Complex{Int32},), ci32)
Expand Down Expand Up @@ -134,7 +128,7 @@ verbose && Libc.flush_cstdio()
verbose && println("Testing cfunction roundtrip: ")
# cfunction roundtrip
for (t,v) in ((Complex{Int32},:ci32),(Complex{Int64},:ci64),
(Complex64,:cf32),(Complex128,:cf64),(Struct1,:s1))
(Complex64,:cf32),(Complex128,:cf64),(Struct1,:s1))
fname = symbol("foo"*string(v))
fname1 = symbol("foo1"*string(v))
@eval begin
Expand Down
41 changes: 23 additions & 18 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,17 @@ function fooo_3()
y
end
@test fooo_3() === 100
function foo()
local x::Int8
function bar()
x = 100
end
let
function foo()
local x::Int8
function bar()
x = 100
end
bar()
x
x
end
@test foo() === convert(Int8,100)
end
@test foo() === convert(Int8,100)

function bar{T}(x::T)
local z::Complex{T}
Expand Down Expand Up @@ -421,14 +423,14 @@ glotest()
# issue #7234
begin
glob_x2 = 24
f7234() = (glob_x2 += 1)
f7234_a() = (glob_x2 += 1)
end
@test_throws UndefVarError f7234()
@test_throws UndefVarError f7234_a()
begin
global glob_x2 = 24
f7234() = (glob_x2 += 1)
f7234_b() = (glob_x2 += 1)
end
@test_throws UndefVarError f7234()
@test_throws UndefVarError f7234_b()
# existing globals can be inherited by non-function blocks
for i = 1:2
glob_x2 += 1
Expand Down Expand Up @@ -1233,14 +1235,15 @@ end
@test isa(foo4075(Foo4075(Int64(1),2.0),:y), Float64)

# issue #3167
function foo(x)
ret=Array(typeof(x[1]), length(x))
for j = 1:length(x)
ret[j] = x[j]
let
function foo(x)
ret=Array(typeof(x[1]), length(x))
for j = 1:length(x)
ret[j] = x[j]
end
return ret
end
return ret
end
let x = Array(Union{Dict{Int64,AbstractString},Array{Int64,3},Number,AbstractString,Void}, 3)
x = Array(Union{Dict{Int64,AbstractString},Array{Int64,3},Number,AbstractString,Void}, 3)
x[1] = 1.0
x[2] = 2.0
x[3] = 3.0
Expand Down Expand Up @@ -3089,10 +3092,12 @@ end
# issue 11858
type Foo11858
x::Float64
Foo11858(x::Float64) = new(x)
end

type Bar11858
x::Float64
Bar11858(x::Float64) = new(x)
end

g11858(x::Float64) = x
Expand Down
16 changes: 8 additions & 8 deletions test/dates/accessors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# test_dates(-10000,10000) takes about 15 seconds
# test_dates(year(typemin(Date)),year(typemax(Date))) is full range
# and would take.......a really long time
function test_dates(from,to)
function test_dates1(from,to)
y = m = d = 0
test_day = Dates.totaldays(from,1,1)
for y in from:to
Expand All @@ -54,10 +54,10 @@ function test_dates(from,to)
end
end
end
test_dates(0,2100)
test_dates1(0,2100)

# Test year, month, day, hour, minute
function test_dates()
function test_dates1()
y = m = d = h = mi = 0
for m = 1:12
for d = 1:Dates.daysinmonth(y,m)
Expand All @@ -77,10 +77,10 @@ function test_dates()
end
end
end
test_dates()
test_dates1()

# Test second, millisecond
function test_dates()
function test_dates2()
y = m = d = h = mi = s = ms = 0
for y in [-2013,-1,0,1,2013]
for m in [1,6,12]
Expand All @@ -102,9 +102,9 @@ function test_dates()
end
end
end
test_dates()
test_dates2()

function test_dates(from,to)
function test_dates2(from,to)
y = m = d = 0
for y in from:to
for m = 1:12
Expand All @@ -117,7 +117,7 @@ function test_dates(from,to)
end
end
end
test_dates(0,2100)
test_dates2(0,2100)

# week function
# Tests from https://en.wikipedia.org/wiki/ISO_week_date
Expand Down
4 changes: 2 additions & 2 deletions test/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test_inlined_symbols(test_outer, Tuple{Int64})
# Make sure that an error is thrown for the undeclared
# y in the else branch.
# https://github.com/JuliaLang/julia/issues/12620
@inline function foo(x)
@inline function foo_inl(x)
if x
y = 2
else
Expand All @@ -60,7 +60,7 @@ test_inlined_symbols(test_outer, Tuple{Int64})
end
function bar()
for i = 1:3
foo(i==1)
foo_inl(i==1)
end
end
@test_throws UndefVarError bar()
Expand Down
7 changes: 4 additions & 3 deletions test/mpfr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -839,9 +839,10 @@ i3 = trunc(Integer,f)
@test i3+1 > f
@test i3+1 >= f

err(z, x) = abs(z - x) / abs(x)
@test 1e-60 > err(eta(parse(BigFloat,"1.005")), parse(BigFloat,"0.693945708117842473436705502427198307157819636785324430166786"))
@test 1e-60 > err(exp(eta(big(1.0))), 2.0)
let err(z, x) = abs(z - x) / abs(x)
@test 1e-60 > err(eta(parse(BigFloat,"1.005")), parse(BigFloat,"0.693945708117842473436705502427198307157819636785324430166786"))
@test 1e-60 > err(exp(eta(big(1.0))), 2.0)
end

# issue #8318
@test convert(Int64,big(500_000_000_000_000.)) == 500_000_000_000_000
Expand Down
9 changes: 9 additions & 0 deletions test/string.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# This file is a part of Julia. License is MIT: http://julialang.org/license

## generic string uses only endof and next; used for testing ##

immutable GenericString <: AbstractString
string::AbstractString
end

Base.endof(s::GenericString) = endof(s.string)
Base.next(s::GenericString, i::Int) = next(s.string, i)

include("strings/basic.jl")
include("strings/types.jl")
include("strings/search.jl")
Expand Down
9 changes: 0 additions & 9 deletions test/strings/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,6 @@ tstr = tstStringType("12");
@test_throws ErrorException endof(tstr)
@test_throws ErrorException next(tstr, Bool(1))

## generic string uses only endof and next ##

immutable GenericString <: AbstractString
string::AbstractString
end

Base.endof(s::GenericString) = endof(s.string)
Base.next(s::GenericString, i::Int) = next(s.string, i)

gstr = GenericString("12");
@test typeof(string(gstr))==GenericString
@test bytestring()==""
Expand Down
9 changes: 0 additions & 9 deletions test/strings/search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@
astr = "Hello, world.\n"
u8str = "∀ ε > 0, ∃ δ > 0: |x-y| < δ ⇒ |f(x)-f(y)| < ε"

## generic string uses only endof and next ##

immutable GenericString <: AbstractString
string::AbstractString
end

Base.endof(s::GenericString) = endof(s.string)
Base.next(s::GenericString, i::Int) = next(s.string, i)

# I think these should give error on 4 also, and "" is not treated
# consistently with SubString("",1,1), nor with Char[]
for ind in (0, 5)
Expand Down

0 comments on commit da7b49d

Please sign in to comment.