on master help sign in
Add elm syntax regression test
66c7acaMatthias Devlamynck
tests/syntax-tests/highlighted/Elm/test.elmnew file+137
@@ -0,0 +1,137 @@
1+-- elm install elm-explorations/linear-algebra
2+-- elm install elm-explorations/webgl
3+
4+
5+import Browser
6+import Browser.Events as E
7+import Html exposing (Html)
8+import Html.Attributes exposing (width, height, style)
9+import Math.Matrix4 as Mat4 exposing (Mat4)
10+import Math.Vector3 as Vec3 exposing (Vec3, vec3)
11+import WebGL
12+
13+
14+
15+-- MAIN
16+
17+
18+main =
19+ Browser.element
20+ { init = init
21+ , view = view
22+ , update = update
23+ , subscriptions = subscriptions
24+ }
25+
26+
27+
28+-- MODEL
29+
30+
31+type alias Model =
32+ Float
33+
34+
35+init : () -> (Model, Cmd Msg)
36+init () =
37+ ( 0, Cmd.none )
38+
39+
40+
41+-- UPDATE
42+
43+
44+type Msg
45+ = TimeDelta Float
46+
47+
48+update : Msg -> Model -> (Model, Cmd Msg)
49+update msg currentTime =
50+ case msg of
51+ TimeDelta delta ->
52+ ( delta + currentTime, Cmd.none )
53+
54+
55+
56+-- SUBSCRIPTIONS
57+
58+
59+subscriptions : Model -> Sub Msg
60+subscriptions _ =
61+ E.onAnimationFrameDelta TimeDelta
62+
63+
64+
65+-- VIEW
66+
67+
68+view : Model -> Html msg
69+view t =
70+ WebGL.toHtml
71+ [ width 400, height 400, style "display" "block"
72+ ]
73+ [ WebGL.entity vertexShader fragmentShader mesh { perspective = perspective (t / 1000) }
74+ ]
75+
76+
77+perspective : Float -> Mat4
78+perspective t =
79+ Mat4.mul
80+ (Mat4.makePerspective 45 1 0.01 100)
81+ (Mat4.makeLookAt (vec3 (4 * cos t) 0 (4 * sin t)) (vec3 0 0 0) (vec3 0 1 0))
82+
83+
84+
85+-- MESH
86+
87+
88+type alias Vertex =
89+ { position : Vec3
90+ , color : Vec3
91+ }
92+
93+
94+mesh : WebGL.Mesh Vertex
95+mesh =
96+ WebGL.triangles
97+ [ ( Vertex (vec3 0 0 0) (vec3 1 0 0)
98+ , Vertex (vec3 1 1 0) (vec3 0 1 0)
99+ , Vertex (vec3 1 -1 0) (vec3 0 0 1)
100+ )
101+ ]
102+
103+
104+
105+-- SHADERS
106+
107+
108+type alias Uniforms =
109+ { perspective : Mat4
110+ }
111+
112+
113+vertexShader : WebGL.Shader Vertex Uniforms { vcolor : Vec3 }
114+vertexShader =
115+ [glsl|
116+ attribute vec3 position;
117+ attribute vec3 color;
118+ uniform mat4 perspective;
119+ varying vec3 vcolor;
120+
121+ void main () {
122+ gl_Position = perspective * vec4(position, 1.0);
123+ vcolor = color;
124+ }
125+ |]
126+
127+
128+fragmentShader : WebGL.Shader {} Uniforms { vcolor : Vec3 }
129+fragmentShader =
130+ [glsl|
131+ precision mediump float;
132+ varying vec3 vcolor;
133+
134+ void main () {
135+ gl_FragColor = vec4(vcolor, 1.0);
136+ }
137+ |]
tests/syntax-tests/source/Elm/LICENSE.mdnew file+32
@@ -0,0 +1,32 @@
1+The `test.elm` file has been added from [https://elm-lang.org/examples/triangle] under the following license:
2+
3+Copyright (c) 2012-present Evan Czaplicki
4+
5+All rights reserved.
6+
7+Redistribution and use in source and binary forms, with or without
8+modification, are permitted provided that the following conditions are met:
9+
10+ * Redistributions of source code must retain the above copyright
11+ notice, this list of conditions and the following disclaimer.
12+
13+ * Redistributions in binary form must reproduce the above
14+ copyright notice, this list of conditions and the following
15+ disclaimer in the documentation and/or other materials provided
16+ with the distribution.
17+
18+ * Neither the name of Evan Czaplicki nor the names of other
19+ contributors may be used to endorse or promote products derived
20+ from this software without specific prior written permission.
21+
22+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
tests/syntax-tests/source/Elm/test.elmnew file+137
@@ -0,0 +1,137 @@
1+-- elm install elm-explorations/linear-algebra
2+-- elm install elm-explorations/webgl
3+
4+
5+import Browser
6+import Browser.Events as E
7+import Html exposing (Html)
8+import Html.Attributes exposing (width, height, style)
9+import Math.Matrix4 as Mat4 exposing (Mat4)
10+import Math.Vector3 as Vec3 exposing (Vec3, vec3)
11+import WebGL
12+
13+
14+
15+-- MAIN
16+
17+
18+main =
19+ Browser.element
20+ { init = init
21+ , view = view
22+ , update = update
23+ , subscriptions = subscriptions
24+ }
25+
26+
27+
28+-- MODEL
29+
30+
31+type alias Model =
32+ Float
33+
34+
35+init : () -> (Model, Cmd Msg)
36+init () =
37+ ( 0, Cmd.none )
38+
39+
40+
41+-- UPDATE
42+
43+
44+type Msg
45+ = TimeDelta Float
46+
47+
48+update : Msg -> Model -> (Model, Cmd Msg)
49+update msg currentTime =
50+ case msg of
51+ TimeDelta delta ->
52+ ( delta + currentTime, Cmd.none )
53+
54+
55+
56+-- SUBSCRIPTIONS
57+
58+
59+subscriptions : Model -> Sub Msg
60+subscriptions _ =
61+ E.onAnimationFrameDelta TimeDelta
62+
63+
64+
65+-- VIEW
66+
67+
68+view : Model -> Html msg
69+view t =
70+ WebGL.toHtml
71+ [ width 400, height 400, style "display" "block"
72+ ]
73+ [ WebGL.entity vertexShader fragmentShader mesh { perspective = perspective (t / 1000) }
74+ ]
75+
76+
77+perspective : Float -> Mat4
78+perspective t =
79+ Mat4.mul
80+ (Mat4.makePerspective 45 1 0.01 100)
81+ (Mat4.makeLookAt (vec3 (4 * cos t) 0 (4 * sin t)) (vec3 0 0 0) (vec3 0 1 0))
82+
83+
84+
85+-- MESH
86+
87+
88+type alias Vertex =
89+ { position : Vec3
90+ , color : Vec3
91+ }
92+
93+
94+mesh : WebGL.Mesh Vertex
95+mesh =
96+ WebGL.triangles
97+ [ ( Vertex (vec3 0 0 0) (vec3 1 0 0)
98+ , Vertex (vec3 1 1 0) (vec3 0 1 0)
99+ , Vertex (vec3 1 -1 0) (vec3 0 0 1)
100+ )
101+ ]
102+
103+
104+
105+-- SHADERS
106+
107+
108+type alias Uniforms =
109+ { perspective : Mat4
110+ }
111+
112+
113+vertexShader : WebGL.Shader Vertex Uniforms { vcolor : Vec3 }
114+vertexShader =
115+ [glsl|
116+ attribute vec3 position;
117+ attribute vec3 color;
118+ uniform mat4 perspective;
119+ varying vec3 vcolor;
120+
121+ void main () {
122+ gl_Position = perspective * vec4(position, 1.0);
123+ vcolor = color;
124+ }
125+ |]
126+
127+
128+fragmentShader : WebGL.Shader {} Uniforms { vcolor : Vec3 }
129+fragmentShader =
130+ [glsl|
131+ precision mediump float;
132+ varying vec3 vcolor;
133+
134+ void main () {
135+ gl_FragColor = vec4(vcolor, 1.0);
136+ }
137+ |]