summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorhenil <dedaniahenil@gmail.com>2020-10-05 16:23:01 +0530
committerDavid Peter <sharkdp@users.noreply.github.com>2020-10-05 14:24:16 +0200
commit78c9a5d45bcf6e1fcf351d7f9f8dda4c383e3a79 (patch)
treed6594e7a69eb6af26b44ccee3985dbb5dd36aa15 /tests
parent5fa164516560386900e019435892747b6f88c0ed (diff)
add julia test file
Diffstat (limited to 'tests')
-rw-r--r--tests/syntax-tests/highlighted/Julia/test.jl73
-rw-r--r--tests/syntax-tests/source/Julia/test.jl73
2 files changed, 146 insertions, 0 deletions
diff --git a/tests/syntax-tests/highlighted/Julia/test.jl b/tests/syntax-tests/highlighted/Julia/test.jl
new file mode 100644
index 00000000..37987877
--- /dev/null
+++ b/tests/syntax-tests/highlighted/Julia/test.jl
@@ -0,0 +1,73 @@
+# The `test.jl` file has been adapted from [https://github.com/mitmath/18S191/blob/master/lecture_notebooks/Basic%20Julia%20syntax.jl] and is subject to no license.
+
+x = 3
+
+y = 2x
+
+typeof(y)
+
+f(x) = 2 + x
+
+
+f
+
+f(10)
+
+
+function g(x, y)
+ z = x + y
+ return z^2
+end
+
+g(1, 2)
+
+let s = 0
+ for i in 1:10
+ s += i # Equivalent to s = s + i
+ end
+ s
+end
+
+
+typeof(1:10)
+
+function mysum(n)
+ s = 0
+ for i in 1:n
+ s += i
+ end
+ return s
+end
+
+mysum(100)
+
+a = 3
+
+a < 5
+
+if a < 5
+ "small"
+else
+ "big"
+end
+
+v = [1, 2, 3]
+
+typeof(v)
+
+v[2]
+
+v[2] = 10
+
+v2 = [i^2 for i in 1:10]
+
+M = [1 2
+ 3 4]
+
+typeof(M)
+
+zeros(5, 5)
+
+zeros(Int, 4, 5)
+
+[i + j for i in 1:5, j in 1:6]
diff --git a/tests/syntax-tests/source/Julia/test.jl b/tests/syntax-tests/source/Julia/test.jl
new file mode 100644
index 00000000..9f6900c8
--- /dev/null
+++ b/tests/syntax-tests/source/Julia/test.jl
@@ -0,0 +1,73 @@
+# The `test.jl` file has been adapted from [https://github.com/mitmath/18S191/blob/master/lecture_notebooks/Basic%20Julia%20syntax.jl] and is subject to no license.
+
+x = 3
+
+y = 2x
+
+typeof(y)
+
+f(x) = 2 + x
+
+
+f
+
+f(10)
+
+
+function g(x, y)
+ z = x + y
+ return z^2
+end
+
+g(1, 2)
+
+let s = 0
+ for i in 1:10
+ s += i # Equivalent to s = s + i
+ end
+ s
+end
+
+
+typeof(1:10)
+
+function mysum(n)
+ s = 0
+ for i in 1:n
+ s += i
+ end
+ return s
+end
+
+mysum(100)
+
+a = 3
+
+a < 5
+
+if a < 5
+ "small"
+else
+ "big"
+end
+
+v = [1, 2, 3]
+
+typeof(v)
+
+v[2]
+
+v[2] = 10
+
+v2 = [i^2 for i in 1:10]
+
+M = [1 2
+ 3 4]
+
+typeof(M)
+
+zeros(5, 5)
+
+zeros(Int, 4, 5)
+
+[i + j for i in 1:5, j in 1:6]