Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 92 lines (85 sloc) 1.726 kB
528c1b7 @JeffBezanson reorganizing tests.
JeffBezanson authored
1 # ranges
2 @assert size(10:1:0) == (0,)
3 @assert length(1:.2:2) == 6
f6f2e44 @StefanKarpinski Refactor ranges to store their length instead of stop value.
StefanKarpinski authored
4 @assert length(1.:.2:2.) == 6
528c1b7 @JeffBezanson reorganizing tests.
JeffBezanson authored
5 @assert length(2:-.2:1) == 6
f6f2e44 @StefanKarpinski Refactor ranges to store their length instead of stop value.
StefanKarpinski authored
6 @assert length(2.:-.2:1.) == 6
528c1b7 @JeffBezanson reorganizing tests.
JeffBezanson authored
7 @assert length(2:.2:1) == 0
f6f2e44 @StefanKarpinski Refactor ranges to store their length instead of stop value.
StefanKarpinski authored
8 @assert length(2.:.2:1.) == 0
528c1b7 @JeffBezanson reorganizing tests.
JeffBezanson authored
9
723a9e5 @JeffBezanson adding tests for some Range issues that have come up
JeffBezanson authored
10 @assert length(1:0) == 0
11 @assert length(0.0:-0.5) == 0
12 @assert length(1:2:0) == 0
c486666 @JeffBezanson fixing some uses of linspace()
JeffBezanson authored
13 L32 = linspace(int32(1), int32(4), 4)
14 L64 = linspace(int64(1), int64(4), 4)
723a9e5 @JeffBezanson adding tests for some Range issues that have come up
JeffBezanson authored
15 @assert L32[1] == 1 && L64[1] == 1
16 @assert L32[2] == 2 && L64[2] == 2
17 @assert L32[3] == 3 && L64[3] == 3
18 @assert L32[4] == 4 && L64[4] == 4
19
055c573 @JeffBezanson adding tests for some recent issues
JeffBezanson authored
20 r = [5:-1:1]
21 @assert r[1]==5
22 @assert r[2]==4
23 @assert r[3]==3
24 @assert r[4]==2
25 @assert r[5]==1
26
528c1b7 @JeffBezanson reorganizing tests.
JeffBezanson authored
27 # comprehensions
28 X = [ i+2j | i=1:5, j=1:5 ]
29 @assert X[2,3] == 8
30 @assert X[4,5] == 14
1945dcf @JeffBezanson a bit of library cleanup
JeffBezanson authored
31 @assert isequal(ones(2,3) * ones(2,3)', [3. 3.; 3. 3.])
32 @assert isequal([ [1,2] | i=1:2, : ], [1 2; 1 2])
528c1b7 @JeffBezanson reorganizing tests.
JeffBezanson authored
33 # where element type is a Union. try to confuse type inference.
34 foo32_64(x) = (x<2) ? int32(x) : int64(x)
35 boo32_64() = [ foo32_64(i) | i=1:2 ]
36 let a36 = boo32_64()
37 @assert a36[1]==1 && a36[2]==2
38 end
39
0f3dbc4 @JeffBezanson fixing #478
JeffBezanson authored
40 @assert (10.^[-1])[1] == 0.1
41 @assert (10.^[-1.])[1] == 0.1
42
528c1b7 @JeffBezanson reorganizing tests.
JeffBezanson authored
43 # hash table
44 h = HashTable()
45 for i=1:10000
46 h[i] = i+1
47 end
48 for i=1:10000
49 @assert (h[i] == i+1)
50 end
51 for i=1:2:10000
52 del(h, i)
53 end
54 for i=1:2:10000
55 h[i] = i+1
56 end
57 for i=1:10000
58 @assert (h[i] == i+1)
59 end
60 for i=1:10000
61 del(h, i)
62 end
63 @assert isempty(h)
64 h[77] = 100
65 @assert h[77]==100
66 for i=1:10000
67 h[i] = i+1
68 end
69 for i=1:2:10000
70 del(h, i)
71 end
72 for i=10001:20000
73 h[i] = i+1
74 end
75 for i=2:2:10000
76 @assert h[i]==i+1
77 end
78 for i=10000:20000
79 @assert h[i]==i+1
80 end
055c573 @JeffBezanson adding tests for some recent issues
JeffBezanson authored
81
82 let
83 z = HashTable()
84 get_KeyError = false
85 try
86 z["a"]
87 catch _e123_
88 get_KeyError = isa(_e123_,KeyError)
89 end
90 @assert get_KeyError
91 end
Something went wrong with that request. Please try again.