Warning, /frameworks/syntax-highlighting/autotests/input/highlight.pony is written in an unsupported language. File is not indexed.
0001 // Test file for Pony syntax highlighting, released under MIT License 0002 0003 primitive Red fun apply(): U32 => 0xFFFF0000 0004 0005 primitive Colours 0006 fun black(): U32 => 0xFF000000 0007 fun red(): U32 => 0xFFFF0000 0008 0009 primitive Black 0010 primitive Blue 0011 0012 type Colour is (Black | Blue ) 0013 0014 primitive ColourList 0015 fun tag apply(): Array[Colour] => 0016 [Black; Blue] 0017 0018 for colour in ColourList().values() do 0019 end 0020 0021 type EGLEvent is (U8, F32, F32) 0022 (var code, var x, var y) = @getEvent[EGLEvent]() 0023 0024 primitive _XDisplayHandle 0025 primitive _EGLDisplayHandle 0026 0027 let x_dpy = @XOpenDisplay[Pointer[_XDisplayHandle]](U32(0)) 0028 if x_dpy.is_null() then 0029 env.out.print("XOpenDisplay failed") 0030 end 0031 0032 let e_dpy = @eglGetDisplay[Pointer[_EGLDisplayHandle]](x_dpy) 0033 if e_dpy.is_null() then 0034 env.out.print("eglGetDisplay failed") 0035 end 0036 0037 primitive _EGLConfigHandle 0038 let a = Array[U16](8) 0039 a.push(0x3040) 0040 a.push(0b01011) 0041 let config = Pointer[_EGLConfigHandle] 0042 if @eglChooseConfig[U32](e_dpy, a, config, U32(1), Pointer[U32]) == 0 then 0043 env.out.print("eglChooseConfig failed") 0044 end 0045 0046 0047 actor Main 0048 new create(env: Env) => 0049 // The no of arguments 0050 env.out.print(env.args.size().string()) 0051 for value in env.args.values() do 0052 env.out.print(value) 0053 end 0054 // Access the arguments the first one will always be the the appication name 0055 try env.out.print(env.args(0)?) end 0056 0057 actor Main 0058 new create(env: Env) => 0059 var options = Options(env) 0060 0061 options 0062 .add("output", "o", StringArgument) 0063 0064 env.out.print(options.has_argument()) 0065 0066 for option in options do 0067 match option 0068 | ("output", var arg: String) => _outputFileName = arg.string() 0069 | let err: ParseError => 0070 err.report(env.out) 0071 env.out.print( 0072 """ 0073 pony-embed [OPTIONS] 0074 --output name string output filename. 0075 """ 0076 ) 0077 end 0078 end 0079 0080 use "ponytest" 0081 0082 actor Main is TestList 0083 new create(env: Env) => PonyTest(env, this) 0084 new make() => None 0085 0086 fun tag tests(test: PonyTest) => 0087 test(_TestAddition) 0088 0089 class iso _TestAddition is UnitTest 0090 """ 0091 Adding 2 numbers 0092 """ 0093 fun name(): String => "u32/add" 0094 0095 fun apply(h: TestHelper): TestResult => 0096 h.expect_eq[U32](2 + 2, 4) 0097 0098 fun tag log(msg: String, verbose: Bool = false) 0099 be fail() => 0100 be assert_failed(msg: String) => 0101 fun tag assert_true(actual: Bool, msg: String = "") ? 0102 fun tag expect_true(actual: Bool, msg: String = ""): Bool 0103 fun tag expect_eq[A: (Equatable[A] #read & Stringable)] 0104 (expect: A, actual: A, msg: String = ""): Bool 0105 fun tag expect_eq[A: (Equatable[A] #unknown & Stringable)] 0106 (expect: A, actual: A, msg: String = ""): Bool 0107 0108 fun add(other: A): A 0109 fun sub(other: A): A 0110 fun mul(other: A): A 0111 fun div(other: A): A 0112 fun mod(other: A): A 0113 fun eq(other: A): Bool 0114 fun ne(other: A): Bool 0115 fun lt(other: A): Bool 0116 fun le(other: A): Bool 0117 fun ge(other: A): Bool 0118 fun gt(other: A): Bool 0119 fun shl(other: A): A 0120 fun shr(other: A): A 0121 fun op_and(other:A): A 0122 fun op_or(other: A): A 0123 fun op_xor(othr: A): A 0124 0125 class Test 0126 fun alpha() => 0127 """ 0128 """ 0129 0130 let dice: Array[U32] = [1; 2; 3 0131 4 0132 5 0133 6 0134 ] 0135 0136 actor Main 0137 fun foo(n:U32): {ref(U32): U32} => 0138 var s: Array[U32] = Array[U32].init(n, 1) 0139 {ref(i:U32)(s): U32 => 0140 try 0141 s(0) = s(0) + i 0142 s(0) 0143 else 0144 0 0145 end 0146 } 0147 0148 new create(env:Env) => 0149 var f = foo(5) 0150 env.out.print(f(10).string()) 0151 env.out.print(f(20).string()) 0152 0153 /* nested /* commentary */ */ 0154 // single comment 0155 0156 class A 0157 class _A 0158 x' 0159 x'' 0160 x'.string() 0161 '\uaaaa' 0162 '\Ubbbbbb' 0163 '\xcc' 0164 '\'' 0165 '\n' 0166 "\uaaaaa" 0167 "\Ubbbbbbb" 0168 "\xccc" 0169 "\"" 0170 "\n" 0171 34.4 0172 34.4e43 0173 43e4 0174 0x3040 0175 0xaF 0176 0b01 0177 3_43_4 0178 0x0_4 0179 0180 fun create(): U32 => 0 0181 fun iso create(): U32 => 0 0182 fun \\ abc \\ iso create(): U32 => 0 0183 class \\ packet, blah \\ iso Xyz 0184 if \\ likely \\ a then 0185 end 0186 0187 a.endnormal 0188 0189 print();print() 0190 0191 /* syntactically false: */ 0192 0193 class _aA 0194 class _a 0195 class a 0196 0b2332 0197 0b 0198 0x 0199 0xgf 0200 0f00 0201 3. 0202 .3 0203 3.e3 0204 3_ 0205 3__43_4 0206 '' 0207 '\u' 0208 '\ua' 0209 '\uaaa' 0210 '\uaaaaa' 0211 '\uyyyy' 0212 "\u" 0213 "\ua" 0214 "\uaaa" 0215 "\uyyyy" 0216 a'a 0217 0218 class badType 0219 print();