Warning, /frameworks/syntax-highlighting/autotests/input/test.jl is written in an unsupported language. File is not indexed.
0001 # Test file for Julia 0002 0003 # Comment 0004 0005 #= Multi-line 0006 comment =# 0007 0008 #BEGIN 0009 0010 #END 0011 0012 using Random, LinearAlgebra 0013 x = 1 + 1 0014 using DataFrames, Tables, 0015 HDF5, # this is a comment 0016 Plots 0017 using DataFrames, Tables, 0018 0019 # this is a comment 0020 Plots 0021 x = x ยฑ 2 0022 using SparseArrays: SparseMatrixCSC 0023 using Sockets: Sockets, connect, 0024 listen, 0025 getaddrinfo 0026 x = x^3 0027 using Statistics: 0028 std, 0029 stdm 0030 0031 """ 0032 Multi-line string 0033 """ 0034 ``` 0035 Multi-line command 0036 ``` 0037 raw"string\a\\a" 0038 0039 "string $testvar interpolation" 0040 "string \$testvar interpolation" 0041 "string $(collect(1:10) .^ 3) interpolation" 0042 "string \$(collect(1:10) .^ 3) interpolation" 0043 0044 let z = zip(1:2, 3:4, 5:6) 0045 @test size(z) == (2,) 0046 @test collect(z) == [(1,3,5), (2,4,6)] 0047 @test eltype(z) == Tuple{Int,Int,Int} 0048 end 0049 0050 @testset "generic conversion from Integer" begin 0051 x = rand(Int128) 0052 @test BigInt(x) % Int128 === x 0053 y = rand(UInt128) 0054 @test BigInt(y) % UInt128 === y 0055 end 0056 0057 @testset "show" begin 0058 @test sprint(show, BitSet()) == "BitSet([])" 0059 @test sprint(show, BitSet([1,2,3])) == "BitSet([1, 2, 3])" 0060 show(IOBuffer(), BitSet()) 0061 end 0062 0063 cmd = `$(Base.julia_cmd()) --depwarn=error --startup-file=no boundscheck_exec.jl` 0064 if !success(pipeline(cmd; stdout=stdout, stderr=stderr)) 0065 error("boundscheck test failed, cmd : $cmd") 0066 end 0067 0068 @test iterate(I, CartesianIndex(3, typemax(Int)))[1] == CartesianIndex(4,typemax(Int)) 0069 @test iterate(I, CartesianIndex(4, typemax(Int))) === nothing 0070 @test_throws MethodError write(IOBuffer(), ASCIIChar('x')) 0071 @test_throws MethodError read(IOBuffer('x'), ASCIIChar) 0072 0073 let header = "julia [switches] -- [programfile] [args...]" 0074 @test startswith(read(`$exename -h`, String), header) 0075 @test startswith(read(`$exename --help`, String), header) 0076 end 0077 0078 @test isequal(exp(complex( Inf, NaN)), complex(-Inf, NaN)) 0079 @test isequal(exp(complex( Inf, Inf)), complex(-Inf, NaN)) 0080 0081 # Numbers 0082 0b10 0083 0o01_70 0084 0x00000000000000001111_22_2233334444 0085 -0x0002im 0086 1.0e10 0087 0.00025f0 0088 -1.5_5f0 0089 0xdeadbeefim 0090 0x1.8p3 0091 0x.4p-1 0092 # Invalid number 0093 0x000__22 0094 0095 chars = ['0', '1', '2', '3', 'a', 'b', 'c', 'd', 'e', 'X', 'Y', 'Z', 0096 '๐ ', '๐ ', '๐ ', '๐ ', '๐ก', '๐ข', '๐ฃ', '๐ฎ'] 0097 0098 @test docstrings_equal(@doc(ModuleMacroDoc), doc"I am a module") 0099 match(r"^\s*(?:#|$)", "# a comment") 0100 0101 abstract type Test2 end 0102 0103 function โabcโdef(a::Int, 0104 b:: Int, 0105 c::Dict{String, Int}, 0106 d:: Dict{String, Vector{eltype(var1)}}, 0107 f::AbstractVector{<:Number}, 0108 g::T, 0109 h::T) where {T <: Number} 0110 x::Int = 1 0111 z = collect(1:10) 0112 return z[3:end] .+ x .- a 0113 end 0114 0115 mutable struct TestType <: AbstractVector{Number} 0116 field1::Int 0117 โfield2::Vector 0118 end 0119 0120 struct ParametricType{T, V <: Tuple} 0121 field1 0122 field2::Float 0123 0124 function ParametricType{T, V}(r, d) where {T, V <: Tuple} 0125 return new{T, V}(r, d) 0126 end 0127 end