Wiki

root/cobra/trunk/Tests/100-basics/130-for-enumerable.cobra

Revision 2636, 0.8 KB (checked in by Charles.Esterbrook, 7 weeks ago)

JVM back-end progress.
credit:hopscc

  • Property svn:eol-style set to native
Line 
1namespace Test
2
3    class Test
4        shared
5            var fakeCommandLineArgs as List<of String> = ['130-for-enumerable' ]
6
7        def main
8            is shared
9
10            count as int = 0
11
12            for arg as String in .fakeCommandLineArgs
13                # Console.WriteLine(arg)
14                count += 1
15
16            assert count>0
17
18            for arg in .fakeCommandLineArgs
19                count += 1
20
21            CobraCore.noOp(arg)
22            Test().more
23
24        def more
25            s = 'aoeu'
26            # reuse a local
27            for s in .fakeCommandLineArgs
28                assert s  # .warning. always
29
30            .foo('aoeu')
31            .bar
32
33        def foo(s as String)
34            assert s == 'aoeu'
35            # reuse an arg:
36            for s in .fakeCommandLineArgs
37                assert s  # .warning. always
38
39        var _b as String = 'aoeu'
40
41        def bar
42            assert _b == 'aoeu'
43            # reuse a class var:
44            for _b in .fakeCommandLineArgs
45                assert _b  # .warning. always
Note: See TracBrowser for help on using the browser.