1# Test file for Julia 2 3# Comment 4 5#= Multi-line 6 comment =# 7 8#BEGIN 9 10#END 11 12using Random, LinearAlgebra 13x = 1 + 1 14using DataFrames, Tables, 15 HDF5, # this is a comment 16 Plots 17using DataFrames, Tables, 18 19 # this is a comment 20 Plots 21x = x ± 2 22using SparseArrays: SparseMatrixCSC 23using Sockets: Sockets, connect, 24 listen, 25 getaddrinfo 26x = x^3 27using Statistics: 28 std, 29 stdm 30 31""" 32 Multi-line string 33""" 34``` 35 Multi-line command 36``` 37raw"string\a\\a" 38 39"string $testvar interpolation" 40"string \$testvar interpolation" 41"string $(collect(1:10) .^ 3) interpolation" 42"string \$(collect(1:10) .^ 3) interpolation" 43 44let z = zip(1:2, 3:4, 5:6) 45 @test size(z) == (2,) 46 @test collect(z) == [(1,3,5), (2,4,6)] 47 @test eltype(z) == Tuple{Int,Int,Int} 48end 49 50@testset "generic conversion from Integer" begin 51 x = rand(Int128) 52 @test BigInt(x) % Int128 === x 53 y = rand(UInt128) 54 @test BigInt(y) % UInt128 === y 55end 56 57@testset "show" begin 58 @test sprint(show, BitSet()) == "BitSet([])" 59 @test sprint(show, BitSet([1,2,3])) == "BitSet([1, 2, 3])" 60 show(IOBuffer(), BitSet()) 61end 62 63cmd = `$(Base.julia_cmd()) --depwarn=error --startup-file=no boundscheck_exec.jl` 64if !success(pipeline(cmd; stdout=stdout, stderr=stderr)) 65 error("boundscheck test failed, cmd : $cmd") 66end 67 68@test iterate(I, CartesianIndex(3, typemax(Int)))[1] == CartesianIndex(4,typemax(Int)) 69@test iterate(I, CartesianIndex(4, typemax(Int))) === nothing 70@test_throws MethodError write(IOBuffer(), ASCIIChar('x')) 71@test_throws MethodError read(IOBuffer('x'), ASCIIChar) 72 73let header = "julia [switches] -- [programfile] [args...]" 74 @test startswith(read(`$exename -h`, String), header) 75 @test startswith(read(`$exename --help`, String), header) 76end 77 78@test isequal(exp(complex( Inf, NaN)), complex(-Inf, NaN)) 79@test isequal(exp(complex( Inf, Inf)), complex(-Inf, NaN)) 80 81# Numbers 820b10 830o01_70 840x00000000000000001111__22_2233334444 85-0x0002im 861.0e10 870.00025f0 88-1.5__5f0 890xdeadbeefim 900x1.8p3 910x.4p-1 92 93chars = ['0', '1', '2', '3', 'a', 'b', 'c', 'd', 'e', 'X', 'Y', 'Z', 94 '', '', '', '', '', '', '', ''] 95 96@test docstrings_equal(@doc(ModuleMacroDoc), doc"I am a module") 97match(r"^\s*(?:#|$)", "# a comment") 98 99abstract type Test2 end 100 101function ∇abc∇def(a::Int, 102 b:: Int, 103 c::Dict{String, Int}, 104 d:: Dict{String, Vector{eltype(var1)}}, 105 f::AbstractVector{<:Number}, 106 g::T, 107 h::T) where {T <: Number} 108 x::Int = 1 109 z = collect(1:10) 110 return z[3:end] .+ x .- a 111end 112 113mutable struct TestType <: AbstractVector{Number} 114 field1::Int 115 ∇field2::Vector 116end 117 118struct ParametricType{T, V <: Tuple} 119 field1 120 field2::Float 121 122 function ParametricType{T, V}(r, d) where {T, V <: Tuple} 123 return new{T, V}(r, d) 124 end 125end 126