spade 0.0.8.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/.gitmodules +4 -4
- data/README.md +4 -0
- data/bin/spade +1 -1
- data/lib/spade.rb +0 -51
- data/lib/spade/cli.rb +10 -4
- data/lib/spade/version.rb +1 -1
- data/spade.gemspec +4 -21
- metadata +13 -482
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -40
- data/lib/index.js +0 -14
- data/lib/node/loader.js +0 -146
- data/lib/node/sandbox.js +0 -44
- data/lib/spade.js +0 -1130
- data/lib/spade/bundle.rb +0 -171
- data/lib/spade/cli/base.rb +0 -354
- data/lib/spade/cli/owner.rb +0 -45
- data/lib/spade/cli/project_generator.rb +0 -58
- data/lib/spade/compiler.rb +0 -34
- data/lib/spade/console.rb +0 -39
- data/lib/spade/context.rb +0 -116
- data/lib/spade/credentials.rb +0 -36
- data/lib/spade/dependency_installer.rb +0 -103
- data/lib/spade/environment.rb +0 -35
- data/lib/spade/exports.rb +0 -71
- data/lib/spade/installer.rb +0 -40
- data/lib/spade/loader.rb +0 -238
- data/lib/spade/local.rb +0 -46
- data/lib/spade/package.rb +0 -157
- data/lib/spade/reactor.rb +0 -159
- data/lib/spade/remote.rb +0 -99
- data/lib/spade/repository.rb +0 -18
- data/lib/spade/server.rb +0 -66
- data/lib/spade/shell.rb +0 -36
- data/lib/spade/templates/project/LICENSE +0 -19
- data/lib/spade/templates/project/README.md +0 -21
- data/lib/spade/templates/project/lib/main.js +0 -9
- data/lib/spade/templates/project/project.json +0 -31
- data/lib/spade/templates/project/tests/main-test.js +0 -8
- data/package.json +0 -27
- data/packages/coffee-script/.gitignore +0 -8
- data/packages/coffee-script/.npmignore +0 -11
- data/packages/coffee-script/Cakefile +0 -229
- data/packages/coffee-script/LICENSE +0 -22
- data/packages/coffee-script/README +0 -47
- data/packages/coffee-script/Rakefile +0 -78
- data/packages/coffee-script/bin/cake +0 -7
- data/packages/coffee-script/bin/coffee +0 -7
- data/packages/coffee-script/documentation/coffee/aliases.coffee +0 -11
- data/packages/coffee-script/documentation/coffee/array_comprehensions.coffee +0 -2
- data/packages/coffee-script/documentation/coffee/block_comment.coffee +0 -6
- data/packages/coffee-script/documentation/coffee/cake_tasks.coffee +0 -9
- data/packages/coffee-script/documentation/coffee/classes.coffee +0 -25
- data/packages/coffee-script/documentation/coffee/comparisons.coffee +0 -5
- data/packages/coffee-script/documentation/coffee/conditionals.coffee +0 -13
- data/packages/coffee-script/documentation/coffee/default_args.coffee +0 -8
- data/packages/coffee-script/documentation/coffee/do.coffee +0 -4
- data/packages/coffee-script/documentation/coffee/embedded.coffee +0 -5
- data/packages/coffee-script/documentation/coffee/existence.coffee +0 -10
- data/packages/coffee-script/documentation/coffee/expressions.coffee +0 -9
- data/packages/coffee-script/documentation/coffee/expressions_assignment.coffee +0 -3
- data/packages/coffee-script/documentation/coffee/expressions_comprehension.coffee +0 -3
- data/packages/coffee-script/documentation/coffee/expressions_try.coffee +0 -7
- data/packages/coffee-script/documentation/coffee/fat_arrow.coffee +0 -6
- data/packages/coffee-script/documentation/coffee/functions.coffee +0 -2
- data/packages/coffee-script/documentation/coffee/heredocs.coffee +0 -7
- data/packages/coffee-script/documentation/coffee/heregexes.coffee +0 -11
- data/packages/coffee-script/documentation/coffee/interpolation.coffee +0 -6
- data/packages/coffee-script/documentation/coffee/multiple_return_values.coffee +0 -7
- data/packages/coffee-script/documentation/coffee/object_comprehensions.coffee +0 -4
- data/packages/coffee-script/documentation/coffee/object_extraction.coffee +0 -13
- data/packages/coffee-script/documentation/coffee/objects_and_arrays.coffee +0 -19
- data/packages/coffee-script/documentation/coffee/objects_reserved.coffee +0 -5
- data/packages/coffee-script/documentation/coffee/overview.coffee +0 -28
- data/packages/coffee-script/documentation/coffee/parallel_assignment.coffee +0 -6
- data/packages/coffee-script/documentation/coffee/patterns_and_splats.coffee +0 -7
- data/packages/coffee-script/documentation/coffee/prototypes.coffee +0 -3
- data/packages/coffee-script/documentation/coffee/range_comprehensions.coffee +0 -2
- data/packages/coffee-script/documentation/coffee/scope.coffee +0 -5
- data/packages/coffee-script/documentation/coffee/slices.coffee +0 -7
- data/packages/coffee-script/documentation/coffee/soaks.coffee +0 -1
- data/packages/coffee-script/documentation/coffee/splats.coffee +0 -27
- data/packages/coffee-script/documentation/coffee/splices.coffee +0 -5
- data/packages/coffee-script/documentation/coffee/strings.coffee +0 -8
- data/packages/coffee-script/documentation/coffee/switch.coffee +0 -10
- data/packages/coffee-script/documentation/coffee/try.coffee +0 -8
- data/packages/coffee-script/documentation/coffee/while.coffee +0 -10
- data/packages/coffee-script/documentation/css/docs.css +0 -374
- data/packages/coffee-script/documentation/css/idle.css +0 -64
- data/packages/coffee-script/documentation/docs/browser.html +0 -25
- data/packages/coffee-script/documentation/docs/cake.html +0 -43
- data/packages/coffee-script/documentation/docs/coffee-script.html +0 -51
- data/packages/coffee-script/documentation/docs/command.html +0 -161
- data/packages/coffee-script/documentation/docs/docco.css +0 -186
- data/packages/coffee-script/documentation/docs/grammar.html +0 -399
- data/packages/coffee-script/documentation/docs/helpers.html +0 -31
- data/packages/coffee-script/documentation/docs/index.html +0 -3
- data/packages/coffee-script/documentation/docs/lexer.html +0 -490
- data/packages/coffee-script/documentation/docs/nodes.html +0 -1338
- data/packages/coffee-script/documentation/docs/optparse.html +0 -78
- data/packages/coffee-script/documentation/docs/repl.html +0 -24
- data/packages/coffee-script/documentation/docs/rewriter.html +0 -251
- data/packages/coffee-script/documentation/docs/scope.html +0 -54
- data/packages/coffee-script/documentation/docs/underscore.html +0 -295
- data/packages/coffee-script/documentation/images/background.png +0 -0
- data/packages/coffee-script/documentation/images/banding.png +0 -0
- data/packages/coffee-script/documentation/images/button_bg.png +0 -0
- data/packages/coffee-script/documentation/images/button_bg_dark.gif +0 -0
- data/packages/coffee-script/documentation/images/button_bg_green.gif +0 -0
- data/packages/coffee-script/documentation/images/favicon.ico +0 -0
- data/packages/coffee-script/documentation/images/logo.png +0 -0
- data/packages/coffee-script/documentation/images/screenshadow.png +0 -0
- data/packages/coffee-script/documentation/index.html.erb +0 -1607
- data/packages/coffee-script/documentation/js/aliases.js +0 -17
- data/packages/coffee-script/documentation/js/array_comprehensions.js +0 -6
- data/packages/coffee-script/documentation/js/block_comment.js +0 -4
- data/packages/coffee-script/documentation/js/cake_tasks.js +0 -10
- data/packages/coffee-script/documentation/js/classes.js +0 -44
- data/packages/coffee-script/documentation/js/comparisons.js +0 -3
- data/packages/coffee-script/documentation/js/conditionals.js +0 -12
- data/packages/coffee-script/documentation/js/default_args.js +0 -7
- data/packages/coffee-script/documentation/js/do.js +0 -10
- data/packages/coffee-script/documentation/js/embedded.js +0 -4
- data/packages/coffee-script/documentation/js/existence.js +0 -6
- data/packages/coffee-script/documentation/js/expressions.js +0 -15
- data/packages/coffee-script/documentation/js/expressions_assignment.js +0 -2
- data/packages/coffee-script/documentation/js/expressions_comprehension.js +0 -9
- data/packages/coffee-script/documentation/js/expressions_try.js +0 -7
- data/packages/coffee-script/documentation/js/fat_arrow.js +0 -9
- data/packages/coffee-script/documentation/js/functions.js +0 -7
- data/packages/coffee-script/documentation/js/heredocs.js +0 -2
- data/packages/coffee-script/documentation/js/heregexes.js +0 -2
- data/packages/coffee-script/documentation/js/interpolation.js +0 -4
- data/packages/coffee-script/documentation/js/multiple_return_values.js +0 -5
- data/packages/coffee-script/documentation/js/object_comprehensions.js +0 -15
- data/packages/coffee-script/documentation/js/object_extraction.js +0 -10
- data/packages/coffee-script/documentation/js/objects_and_arrays.js +0 -17
- data/packages/coffee-script/documentation/js/objects_reserved.js +0 -4
- data/packages/coffee-script/documentation/js/overview.js +0 -35
- data/packages/coffee-script/documentation/js/parallel_assignment.js +0 -4
- data/packages/coffee-script/documentation/js/patterns_and_splats.js +0 -4
- data/packages/coffee-script/documentation/js/prototypes.js +0 -3
- data/packages/coffee-script/documentation/js/range_comprehensions.js +0 -9
- data/packages/coffee-script/documentation/js/scope.js +0 -8
- data/packages/coffee-script/documentation/js/slices.js +0 -4
- data/packages/coffee-script/documentation/js/soaks.js +0 -2
- data/packages/coffee-script/documentation/js/splats.js +0 -15
- data/packages/coffee-script/documentation/js/splices.js +0 -3
- data/packages/coffee-script/documentation/js/strings.js +0 -2
- data/packages/coffee-script/documentation/js/switch.js +0 -23
- data/packages/coffee-script/documentation/js/try.js +0 -8
- data/packages/coffee-script/documentation/js/while.js +0 -18
- data/packages/coffee-script/documentation/vendor/jquery-1.4.2.js +0 -6240
- data/packages/coffee-script/examples/beautiful_code/binary_search.coffee +0 -16
- data/packages/coffee-script/examples/beautiful_code/quicksort_runtime.coffee +0 -13
- data/packages/coffee-script/examples/beautiful_code/regular_expression_matcher.coffee +0 -34
- data/packages/coffee-script/examples/blocks.coffee +0 -54
- data/packages/coffee-script/examples/code.coffee +0 -167
- data/packages/coffee-script/examples/computer_science/README +0 -4
- data/packages/coffee-script/examples/computer_science/binary_search.coffee +0 -25
- data/packages/coffee-script/examples/computer_science/bubble_sort.coffee +0 -11
- data/packages/coffee-script/examples/computer_science/linked_list.coffee +0 -108
- data/packages/coffee-script/examples/computer_science/luhn_algorithm.coffee +0 -36
- data/packages/coffee-script/examples/computer_science/merge_sort.coffee +0 -19
- data/packages/coffee-script/examples/computer_science/selection_sort.coffee +0 -23
- data/packages/coffee-script/examples/poignant.coffee +0 -181
- data/packages/coffee-script/examples/potion.coffee +0 -206
- data/packages/coffee-script/examples/underscore.coffee +0 -682
- data/packages/coffee-script/examples/web_server.coffee +0 -12
- data/packages/coffee-script/extras/EXTRAS +0 -7
- data/packages/coffee-script/extras/coffee-script.js +0 -8
- data/packages/coffee-script/extras/jsl.conf +0 -44
- data/packages/coffee-script/index.html +0 -2515
- data/packages/coffee-script/lib/browser.js +0 -52
- data/packages/coffee-script/lib/cake.js +0 -76
- data/packages/coffee-script/lib/coffee-script.js +0 -82
- data/packages/coffee-script/lib/command.js +0 -263
- data/packages/coffee-script/lib/grammar.js +0 -581
- data/packages/coffee-script/lib/helpers.js +0 -66
- data/packages/coffee-script/lib/index.js +0 -8
- data/packages/coffee-script/lib/lexer.js +0 -633
- data/packages/coffee-script/lib/nodes.js +0 -2165
- data/packages/coffee-script/lib/optparse.js +0 -111
- data/packages/coffee-script/lib/parser.js +0 -649
- data/packages/coffee-script/lib/repl.js +0 -42
- data/packages/coffee-script/lib/rewriter.js +0 -353
- data/packages/coffee-script/lib/scope.js +0 -120
- data/packages/coffee-script/lib/spade-format.js +0 -45
- data/packages/coffee-script/package.json +0 -26
- data/packages/coffee-script/src/browser.coffee +0 -43
- data/packages/coffee-script/src/cake.coffee +0 -69
- data/packages/coffee-script/src/coffee-script.coffee +0 -92
- data/packages/coffee-script/src/command.coffee +0 -214
- data/packages/coffee-script/src/grammar.coffee +0 -590
- data/packages/coffee-script/src/helpers.coffee +0 -56
- data/packages/coffee-script/src/index.coffee +0 -2
- data/packages/coffee-script/src/lexer.coffee +0 -653
- data/packages/coffee-script/src/nodes.coffee +0 -1754
- data/packages/coffee-script/src/optparse.coffee +0 -99
- data/packages/coffee-script/src/repl.coffee +0 -42
- data/packages/coffee-script/src/rewriter.coffee +0 -326
- data/packages/coffee-script/src/scope.coffee +0 -94
- data/packages/coffee-script/test/arguments.coffee +0 -127
- data/packages/coffee-script/test/assignment.coffee +0 -98
- data/packages/coffee-script/test/break.coffee +0 -18
- data/packages/coffee-script/test/comments.coffee +0 -201
- data/packages/coffee-script/test/conditionals.coffee +0 -181
- data/packages/coffee-script/test/exception_handling.coffee +0 -90
- data/packages/coffee-script/test/helpers.coffee +0 -96
- data/packages/coffee-script/test/importing.coffee +0 -18
- data/packages/coffee-script/test/operators.coffee +0 -225
- data/packages/coffee-script/test/ranges_slices_and_splices.coffee +0 -186
- data/packages/coffee-script/test/regular_expressions.coffee +0 -56
- data/packages/coffee-script/test/test.html +0 -123
- data/packages/coffee-script/test/test_chaining.coffee +0 -77
- data/packages/coffee-script/test/test_classes.coffee +0 -372
- data/packages/coffee-script/test/test_compilation.coffee +0 -26
- data/packages/coffee-script/test/test_comprehensions.coffee +0 -318
- data/packages/coffee-script/test/test_existence.coffee +0 -165
- data/packages/coffee-script/test/test_functions.coffee +0 -379
- data/packages/coffee-script/test/test_heredocs.coffee +0 -111
- data/packages/coffee-script/test/test_literals.coffee +0 -270
- data/packages/coffee-script/test/test_option_parser.coffee +0 -27
- data/packages/coffee-script/test/test_pattern_matching.coffee +0 -162
- data/packages/coffee-script/test/test_returns.coffee +0 -63
- data/packages/coffee-script/test/test_splats.coffee +0 -102
- data/packages/coffee-script/test/test_strings.coffee +0 -118
- data/packages/coffee-script/test/test_switch.coffee +0 -103
- data/packages/coffee-script/test/test_while.coffee +0 -71
- data/packages/ivory/LICENSE.txt +0 -1
- data/packages/ivory/README.md +0 -19
- data/packages/ivory/lib/buffer.js +0 -111
- data/packages/ivory/lib/events.js +0 -137
- data/packages/ivory/lib/fs.js +0 -266
- data/packages/ivory/lib/main.js +0 -13
- data/packages/ivory/lib/path.js +0 -158
- data/packages/ivory/lib/ruby/buffer.rb +0 -145
- data/packages/ivory/lib/ruby/constants.rb +0 -585
- data/packages/ivory/lib/ruby/events.rb +0 -32
- data/packages/ivory/lib/ruby/fs.rb +0 -245
- data/packages/ivory/lib/ruby/process.rb +0 -28
- data/packages/ivory/lib/stream.js +0 -115
- data/packages/ivory/lib/util.js +0 -414
- data/packages/ivory/package.json +0 -11
- data/packages/jquery/main.js +0 -7179
- data/packages/jquery/package.json +0 -10
- data/packages/json/lib/main.js +0 -14
- data/packages/json/package.json +0 -8
- data/packages/lproj/README.md +0 -77
- data/packages/lproj/examples/demo-app/en.lproj/localized.strings +0 -2
- data/packages/lproj/examples/demo-app/fr.lproj/localized.strings +0 -3
- data/packages/lproj/examples/demo-app/index.html +0 -8
- data/packages/lproj/examples/demo-app/lib/main.js +0 -7
- data/packages/lproj/examples/demo-app/package.json +0 -9
- data/packages/lproj/lib/main.js +0 -78
- data/packages/lproj/lib/strings-format.js +0 -6
- data/packages/lproj/package.json +0 -9
- data/packages/optparse/README.md +0 -161
- data/packages/optparse/TODO +0 -1
- data/packages/optparse/examples/browser-test.html +0 -75
- data/packages/optparse/examples/nodejs-test.js +0 -90
- data/packages/optparse/lib/optparse.js +0 -309
- data/packages/optparse/package.json +0 -13
- data/packages/optparse/seed.yml +0 -5
- data/packages/text/lib/main.js +0 -8
- data/packages/text/package.json +0 -9
- data/packages/web-file/README.md +0 -7
- data/packages/web-file/lib/errors.js +0 -32
- data/packages/web-file/lib/file-reader.js +0 -10
- data/packages/web-file/lib/file-system.js +0 -234
- data/packages/web-file/lib/file-writer.js +0 -10
- data/packages/web-file/lib/file.js +0 -9
- data/packages/web-file/lib/main.js +0 -34
- data/packages/web-file/lib/platform.js +0 -25
- data/packages/web-file/lib/ruby/file.rb +0 -252
- data/packages/web-file/lib/ruby/file_reader.rb +0 -69
- data/packages/web-file/lib/ruby/file_system.rb +0 -134
- data/packages/web-file/lib/ruby/file_writer.rb +0 -78
- data/packages/web-file/package.json +0 -12
- data/packages/web-typed-array/README.md +0 -7
- data/packages/web-typed-array/lib/array-buffer-view.js +0 -9
- data/packages/web-typed-array/lib/array-buffer.js +0 -7
- data/packages/web-typed-array/lib/main.js +0 -33
- data/packages/web-typed-array/lib/platform.js +0 -20
- data/packages/web-typed-array/lib/ruby/array_buffer.rb +0 -31
- data/packages/web-typed-array/lib/ruby/array_buffer_view.rb +0 -130
- data/packages/web-typed-array/lib/ruby/typed_array.rb +0 -133
- data/packages/web-typed-array/lib/typed-array.js +0 -26
- data/packages/web-typed-array/package.json +0 -9
- data/spec/cli/build_spec.rb +0 -59
- data/spec/cli/install_spec.rb +0 -120
- data/spec/cli/installed_spec.rb +0 -55
- data/spec/cli/list_spec.rb +0 -75
- data/spec/cli/login_spec.rb +0 -76
- data/spec/cli/new_spec.rb +0 -5
- data/spec/cli/owner_spec.rb +0 -115
- data/spec/cli/push_spec.rb +0 -74
- data/spec/cli/uninstall_spec.rb +0 -58
- data/spec/cli/unpack_spec.rb +0 -73
- data/spec/cli/unyank_spec.rb +0 -74
- data/spec/cli/update_spec.rb +0 -8
- data/spec/cli/yank_spec.rb +0 -74
- data/spec/credentials_spec.rb +0 -24
- data/spec/fixtures/coffee-1.0.1.pre.spd +0 -0
- data/spec/fixtures/core-test-0.4.3.spd +0 -0
- data/spec/fixtures/core-test/bin/cot +0 -3
- data/spec/fixtures/core-test/lib/main.js +0 -1
- data/spec/fixtures/core-test/resources/runner.css +0 -0
- data/spec/fixtures/core-test/tests/test.js +0 -1
- data/spec/fixtures/ivory-0.0.1.spd +0 -0
- data/spec/fixtures/jquery-1.4.3.spd +0 -0
- data/spec/fixtures/optparse-1.0.1.spd +0 -0
- data/spec/fixtures/package.json +0 -30
- data/spec/gauntlet_spec.rb +0 -27
- data/spec/javascript/async-test.js +0 -123
- data/spec/javascript/compiler/javascript.js +0 -13
- data/spec/javascript/compiler/ruby.js +0 -14
- data/spec/javascript/loader-test.js +0 -64
- data/spec/javascript/normalize-test.js +0 -73
- data/spec/javascript/packages-test.js +0 -44
- data/spec/javascript/relative-require-test.js +0 -72
- data/spec/javascript/require-test.js +0 -117
- data/spec/javascript/sandbox/compile.js +0 -37
- data/spec/javascript/sandbox/creation.js +0 -44
- data/spec/javascript/sandbox/format.js +0 -79
- data/spec/javascript/sandbox/misc.js +0 -57
- data/spec/javascript/sandbox/preprocessor.js +0 -81
- data/spec/javascript/sandbox/require.js +0 -48
- data/spec/javascript/sandbox/run-command.js +0 -21
- data/spec/javascript/spade/externs.js +0 -14
- data/spec/javascript/spade/load-factory.js +0 -15
- data/spec/javascript/spade/misc.js +0 -23
- data/spec/javascript/spade/ready.js +0 -12
- data/spec/javascript/spade/register.js +0 -13
- data/spec/javascript_spec.rb +0 -7
- data/spec/package_spec.rb +0 -267
- data/spec/spec_helper.rb +0 -30
- data/spec/support/cli.rb +0 -94
- data/spec/support/core_test.rb +0 -59
- data/spec/support/fake.rb +0 -44
- data/spec/support/fake_gem_server.rb +0 -66
- data/spec/support/fake_gemcutter.rb +0 -49
- data/spec/support/matchers.rb +0 -31
- data/spec/support/path.rb +0 -54
- data/test-spade.html +0 -8
@@ -1,26 +0,0 @@
|
|
1
|
-
# Ensure that carriage returns don't break compilation on Windows.
|
2
|
-
eq CoffeeScript.compile('one\r\ntwo', bare: on), 'one;\ntwo;'
|
3
|
-
|
4
|
-
# `globals: on` removes `var`s
|
5
|
-
eq CoffeeScript.compile('x = y', bare: on, globals: on), 'x = y;'
|
6
|
-
|
7
|
-
ok 'passed' is CoffeeScript.eval '"passed"', bare: on, fileName: 'test'
|
8
|
-
|
9
|
-
#750
|
10
|
-
try ok not CoffeeScript.nodes 'f(->'
|
11
|
-
catch e then eq e.message, 'unclosed CALL_START on line 1'
|
12
|
-
|
13
|
-
eq CoffeeScript.compile('for k of o then', bare: on, globals: on),
|
14
|
-
'for (k in o) {}'
|
15
|
-
|
16
|
-
# Compilations that should fail.
|
17
|
-
cantCompile = (code) ->
|
18
|
-
throws -> CoffeeScript.compile code
|
19
|
-
|
20
|
-
cantCompile 'a = (break)'
|
21
|
-
|
22
|
-
cantCompile 'a = (return 5 for item in list)'
|
23
|
-
|
24
|
-
cantCompile 'a = (return 5 while condition)'
|
25
|
-
|
26
|
-
cantCompile 'a = for x in y\n return 5'
|
@@ -1,318 +0,0 @@
|
|
1
|
-
# Basic array comprehensions.
|
2
|
-
nums = (n * n for n in [1, 2, 3] when n & 1)
|
3
|
-
results = (n * 2 for n in nums)
|
4
|
-
|
5
|
-
ok results.join(',') is '2,18'
|
6
|
-
|
7
|
-
|
8
|
-
# Basic object comprehensions.
|
9
|
-
obj = {one: 1, two: 2, three: 3}
|
10
|
-
names = (prop + '!' for prop of obj)
|
11
|
-
odds = (prop + '!' for prop, value of obj when value & 1)
|
12
|
-
|
13
|
-
ok names.join(' ') is "one! two! three!"
|
14
|
-
ok odds.join(' ') is "one! three!"
|
15
|
-
|
16
|
-
|
17
|
-
# Basic range comprehensions.
|
18
|
-
nums = (i * 3 for i in [1..3])
|
19
|
-
|
20
|
-
negs = (x for x in [-20..-5*2])
|
21
|
-
negs = negs[0..2]
|
22
|
-
|
23
|
-
result = nums.concat(negs).join(', ')
|
24
|
-
|
25
|
-
ok result is '3, 6, 9, -20, -19, -18'
|
26
|
-
|
27
|
-
|
28
|
-
# With range comprehensions, you can loop in steps.
|
29
|
-
results = (x for x in [0...15] by 5)
|
30
|
-
ok results.join(' ') is '0 5 10'
|
31
|
-
|
32
|
-
results = (x for x in [0..100] by 10)
|
33
|
-
ok results.join(' ') is '0 10 20 30 40 50 60 70 80 90 100'
|
34
|
-
|
35
|
-
|
36
|
-
# And can loop downwards, with a negative step.
|
37
|
-
results = (x for x in [5..1])
|
38
|
-
|
39
|
-
ok results.join(' ') is '5 4 3 2 1'
|
40
|
-
ok results.join(' ') is [(10-5)..(-2+3)].join(' ')
|
41
|
-
|
42
|
-
results = (x for x in [10..1])
|
43
|
-
ok results.join(' ') is [10..1].join(' ')
|
44
|
-
|
45
|
-
results = (x for x in [10...0] by -2)
|
46
|
-
ok results.join(' ') is [10, 8, 6, 4, 2].join(' ')
|
47
|
-
|
48
|
-
|
49
|
-
# Range comprehension gymnastics.
|
50
|
-
eq "#{i for i in [5..1]}", '5,4,3,2,1'
|
51
|
-
eq "#{i for i in [5..-5] by -5}", '5,0,-5'
|
52
|
-
|
53
|
-
a = 6
|
54
|
-
b = 0
|
55
|
-
c = -2
|
56
|
-
|
57
|
-
eq "#{i for i in [a..b]}", '6,5,4,3,2,1,0'
|
58
|
-
eq "#{i for i in [a..b] by c}", '6,4,2,0'
|
59
|
-
|
60
|
-
|
61
|
-
# Multiline array comprehension with filter.
|
62
|
-
evens = for num in [1, 2, 3, 4, 5, 6] when not (num & 1)
|
63
|
-
num *= -1
|
64
|
-
num -= 2
|
65
|
-
num * -1
|
66
|
-
eq evens + '', '4,6,8'
|
67
|
-
|
68
|
-
|
69
|
-
# The in operator still works, standalone.
|
70
|
-
ok 2 of evens
|
71
|
-
|
72
|
-
# all isn't reserved.
|
73
|
-
all = 1
|
74
|
-
|
75
|
-
|
76
|
-
# Ensure that the closure wrapper preserves local variables.
|
77
|
-
obj = {}
|
78
|
-
|
79
|
-
for method in ['one', 'two', 'three'] then do (method) ->
|
80
|
-
obj[method] = ->
|
81
|
-
"I'm " + method
|
82
|
-
|
83
|
-
ok obj.one() is "I'm one"
|
84
|
-
ok obj.two() is "I'm two"
|
85
|
-
ok obj.three() is "I'm three"
|
86
|
-
|
87
|
-
|
88
|
-
# Index values at the end of a loop.
|
89
|
-
i = 0
|
90
|
-
for i in [1..3]
|
91
|
-
-> 'func'
|
92
|
-
break if false
|
93
|
-
ok i is 4
|
94
|
-
|
95
|
-
|
96
|
-
# Ensure that local variables are closed over for range comprehensions.
|
97
|
-
funcs = for i in [1..3]
|
98
|
-
do (i) ->
|
99
|
-
-> -i
|
100
|
-
|
101
|
-
eq (func() for func in funcs).join(' '), '-1 -2 -3'
|
102
|
-
ok i is 4
|
103
|
-
|
104
|
-
|
105
|
-
# Even when referenced in the filter.
|
106
|
-
list = ['one', 'two', 'three']
|
107
|
-
|
108
|
-
methods = for num, i in list when num isnt 'two' and i isnt 1
|
109
|
-
do (num, i) ->
|
110
|
-
-> num + ' ' + i
|
111
|
-
|
112
|
-
ok methods.length is 2
|
113
|
-
ok methods[0]() is 'one 0'
|
114
|
-
ok methods[1]() is 'three 2'
|
115
|
-
|
116
|
-
|
117
|
-
# Even a convoluted one.
|
118
|
-
funcs = []
|
119
|
-
|
120
|
-
for i in [1..3]
|
121
|
-
do (i) ->
|
122
|
-
x = i * 2
|
123
|
-
((z)->
|
124
|
-
funcs.push -> z + ' ' + i
|
125
|
-
)(x)
|
126
|
-
|
127
|
-
ok (func() for func in funcs).join(', ') is '2 1, 4 2, 6 3'
|
128
|
-
|
129
|
-
funcs = []
|
130
|
-
|
131
|
-
results = for i in [1..3]
|
132
|
-
do (i) ->
|
133
|
-
z = (x * 3 for x in [1..i])
|
134
|
-
((a, b, c) -> [a, b, c].join(' ')).apply this, z
|
135
|
-
|
136
|
-
ok results.join(', ') is '3 , 3 6 , 3 6 9'
|
137
|
-
|
138
|
-
|
139
|
-
# Naked ranges are expanded into arrays.
|
140
|
-
array = [0..10]
|
141
|
-
ok(num % 2 is 0 for num in array by 2)
|
142
|
-
|
143
|
-
|
144
|
-
# Nested shared scopes.
|
145
|
-
foo = ->
|
146
|
-
for i in [0..7]
|
147
|
-
do (i) ->
|
148
|
-
for j in [0..7]
|
149
|
-
do (j) ->
|
150
|
-
-> i + j
|
151
|
-
|
152
|
-
eq foo()[3][4](), 7
|
153
|
-
|
154
|
-
|
155
|
-
# Scoped loop pattern matching.
|
156
|
-
a = [[0], [1]]
|
157
|
-
funcs = []
|
158
|
-
|
159
|
-
for [v] in a
|
160
|
-
do (v) ->
|
161
|
-
funcs.push -> v
|
162
|
-
|
163
|
-
eq funcs[0](), 0
|
164
|
-
eq funcs[1](), 1
|
165
|
-
|
166
|
-
|
167
|
-
# Nested comprehensions.
|
168
|
-
multiLiner =
|
169
|
-
for x in [3..5]
|
170
|
-
for y in [3..5]
|
171
|
-
[x, y]
|
172
|
-
|
173
|
-
singleLiner =
|
174
|
-
(([x, y] for y in [3..5]) for x in [3..5])
|
175
|
-
|
176
|
-
ok multiLiner.length is singleLiner.length
|
177
|
-
ok 5 is multiLiner[2][2][1]
|
178
|
-
ok 5 is singleLiner[2][2][1]
|
179
|
-
|
180
|
-
|
181
|
-
# Comprehensions within parentheses.
|
182
|
-
result = null
|
183
|
-
store = (obj) -> result = obj
|
184
|
-
store (x * 2 for x in [3, 2, 1])
|
185
|
-
|
186
|
-
ok result.join(' ') is '6 4 2'
|
187
|
-
|
188
|
-
|
189
|
-
# Closure-wrapped comprehensions that refer to the "arguments" object.
|
190
|
-
expr = ->
|
191
|
-
result = (item * item for item in arguments)
|
192
|
-
|
193
|
-
ok expr(2, 4, 8).join(' ') is '4 16 64'
|
194
|
-
|
195
|
-
|
196
|
-
# Fast object comprehensions over all properties, including prototypal ones.
|
197
|
-
class Cat
|
198
|
-
constructor: -> @name = 'Whiskers'
|
199
|
-
breed: 'tabby'
|
200
|
-
hair: 'cream'
|
201
|
-
|
202
|
-
whiskers = new Cat
|
203
|
-
own = (value for own key, value of whiskers)
|
204
|
-
all = (value for key, value of whiskers)
|
205
|
-
|
206
|
-
ok own.join(' ') is 'Whiskers'
|
207
|
-
ok all.sort().join(' ') is 'Whiskers cream tabby'
|
208
|
-
|
209
|
-
|
210
|
-
# Optimized range comprehensions.
|
211
|
-
exxes = ('x' for [0...10])
|
212
|
-
ok exxes.join(' ') is 'x x x x x x x x x x'
|
213
|
-
|
214
|
-
|
215
|
-
# Comprehensions safely redeclare parameters if they're not present in closest
|
216
|
-
# scope.
|
217
|
-
rule = (x) -> x
|
218
|
-
|
219
|
-
learn = ->
|
220
|
-
rule for rule in [1, 2, 3]
|
221
|
-
|
222
|
-
ok learn().join(' ') is '1 2 3'
|
223
|
-
|
224
|
-
ok rule(101) is 101
|
225
|
-
|
226
|
-
f = -> [-> ok no, 'should cache source']
|
227
|
-
ok yes for k of [f] = f()
|
228
|
-
|
229
|
-
|
230
|
-
# Lenient on pure statements not trying to reach out of the closure
|
231
|
-
val = for i in [1]
|
232
|
-
for j in [] then break
|
233
|
-
i
|
234
|
-
ok val[0] is i
|
235
|
-
|
236
|
-
|
237
|
-
# Comprehensions only wrap their last line in a closure, allowing other lines
|
238
|
-
# to have pure expressions in them.
|
239
|
-
func = -> for i in [1]
|
240
|
-
break if i is 2
|
241
|
-
j for j in [1]
|
242
|
-
|
243
|
-
ok func()[0][0] is 1
|
244
|
-
|
245
|
-
i = 6
|
246
|
-
odds = while i--
|
247
|
-
continue unless i & 1
|
248
|
-
i
|
249
|
-
|
250
|
-
ok odds.join(', ') is '5, 3, 1'
|
251
|
-
|
252
|
-
|
253
|
-
# Issue #897: Ensure that plucked function variables aren't leaked.
|
254
|
-
facets = {}
|
255
|
-
list = ['one', 'two']
|
256
|
-
|
257
|
-
(->
|
258
|
-
for entity in list
|
259
|
-
facets[entity] = -> entity
|
260
|
-
)()
|
261
|
-
|
262
|
-
eq typeof entity, 'undefined'
|
263
|
-
eq facets['two'](), 'two'
|
264
|
-
|
265
|
-
|
266
|
-
# Issue #905. Soaks as the for loop subject.
|
267
|
-
a = {b: {c: [1, 2, 3]}}
|
268
|
-
for d in a.b?.c
|
269
|
-
e = d
|
270
|
-
|
271
|
-
eq e, 3
|
272
|
-
|
273
|
-
|
274
|
-
# Issue #948. Capturing loop variables.
|
275
|
-
funcs = []
|
276
|
-
list = ->
|
277
|
-
[1, 2, 3]
|
278
|
-
|
279
|
-
for y in list()
|
280
|
-
do (y) ->
|
281
|
-
z = y
|
282
|
-
funcs.push -> "y is #{y} and z is #{z}"
|
283
|
-
|
284
|
-
eq funcs[1](), "y is 2 and z is 2"
|
285
|
-
|
286
|
-
|
287
|
-
# Cancel the comprehension if there's a jump inside the loop.
|
288
|
-
result = try
|
289
|
-
for i in [0...10]
|
290
|
-
continue if i < 5
|
291
|
-
i
|
292
|
-
|
293
|
-
eq result, 10
|
294
|
-
|
295
|
-
|
296
|
-
# Comprehensions over break.
|
297
|
-
arrayEq (break for [1..10]), []
|
298
|
-
|
299
|
-
# Comprehensions over continue.
|
300
|
-
arrayEq (break for [1..10]), []
|
301
|
-
|
302
|
-
|
303
|
-
# Comprehensions over function literals.
|
304
|
-
a = 0
|
305
|
-
for f in [-> a = 1]
|
306
|
-
do (f) ->
|
307
|
-
do f
|
308
|
-
|
309
|
-
eq a, 1
|
310
|
-
|
311
|
-
|
312
|
-
# Comprehensions that mention arguments.
|
313
|
-
list = [arguments: 10]
|
314
|
-
args = for f in list
|
315
|
-
do (f) ->
|
316
|
-
f.arguments
|
317
|
-
|
318
|
-
eq args[0], 10
|
@@ -1,165 +0,0 @@
|
|
1
|
-
ok(if mySpecialVariable? then false else true)
|
2
|
-
|
3
|
-
mySpecialVariable = false
|
4
|
-
|
5
|
-
ok(if mySpecialVariable? then true else false)
|
6
|
-
|
7
|
-
|
8
|
-
# Existential assignment.
|
9
|
-
a = 5
|
10
|
-
a = null
|
11
|
-
a ?= 10
|
12
|
-
b ?= 10
|
13
|
-
|
14
|
-
ok a is 10 and b is 10
|
15
|
-
|
16
|
-
|
17
|
-
# The existential operator.
|
18
|
-
z = null
|
19
|
-
x = z ? "EX"
|
20
|
-
ok z is null and x is "EX"
|
21
|
-
|
22
|
-
i = 9
|
23
|
-
func = -> i += 1
|
24
|
-
result = func() ? 101
|
25
|
-
ok result is 10
|
26
|
-
|
27
|
-
# Only evaluate once.
|
28
|
-
counter = 0
|
29
|
-
getNextNode = ->
|
30
|
-
throw "up" if counter
|
31
|
-
counter++
|
32
|
-
|
33
|
-
ok(if getNextNode()? then true else false)
|
34
|
-
|
35
|
-
|
36
|
-
# Existence chains, soaking up undefined properties:
|
37
|
-
obj =
|
38
|
-
prop: "hello"
|
39
|
-
|
40
|
-
eq obj?.prop, "hello"
|
41
|
-
eq obj?['prop'], "hello"
|
42
|
-
eq obj.prop?.length, 5
|
43
|
-
eq obj?.prop?['length'], 5
|
44
|
-
eq obj?.prop?.non?.existent?.property, undefined
|
45
|
-
|
46
|
-
|
47
|
-
# Soaks and caches method calls as well.
|
48
|
-
arr = ["--", "----"]
|
49
|
-
|
50
|
-
eq arr.pop()?.length, 4
|
51
|
-
eq arr.pop()?.length, 2
|
52
|
-
eq arr.pop()?.length, undefined
|
53
|
-
eq arr.pop()?.length?.non?.existent()?.property, undefined
|
54
|
-
|
55
|
-
|
56
|
-
# Soaks method calls safely.
|
57
|
-
value = null
|
58
|
-
eq value?.toString().toLowerCase(), undefined
|
59
|
-
|
60
|
-
value = 10
|
61
|
-
eq value?.toString().toLowerCase(), '10'
|
62
|
-
|
63
|
-
eq 0.nothing?.property() or 101, 101
|
64
|
-
|
65
|
-
counter = 0
|
66
|
-
func = ->
|
67
|
-
counter += 1
|
68
|
-
'prop'
|
69
|
-
obj =
|
70
|
-
prop: -> this
|
71
|
-
value: 25
|
72
|
-
|
73
|
-
ok obj[func()]()[func()]()[func()]()?.value is 25
|
74
|
-
ok counter is 3
|
75
|
-
|
76
|
-
|
77
|
-
ident = (obj) -> obj
|
78
|
-
eq ident(non?.existent().method()), undefined, 'soaks inner values'
|
79
|
-
|
80
|
-
|
81
|
-
# Soaks constructor invocations.
|
82
|
-
a = 0
|
83
|
-
class Foo
|
84
|
-
constructor: -> a += 1
|
85
|
-
bar: "bat"
|
86
|
-
|
87
|
-
ok (new Foo())?.bar is 'bat'
|
88
|
-
ok a is 1
|
89
|
-
|
90
|
-
|
91
|
-
ok not value?.property?, 'safely checks existence on soaks'
|
92
|
-
|
93
|
-
|
94
|
-
eq nothing?.value, undefined, 'safely calls values off of non-existent variables'
|
95
|
-
eq !nothing?.value and 1, 1, 'corresponding operators work as expected'
|
96
|
-
|
97
|
-
|
98
|
-
# Assign to the result of an exsitential operation with a minus.
|
99
|
-
x = null ? - 1
|
100
|
-
ok x is - 1
|
101
|
-
|
102
|
-
|
103
|
-
# Things that compile to ternaries should force parentheses, like operators do.
|
104
|
-
duration = if options?.animated then 150 else 0
|
105
|
-
ok duration is 0
|
106
|
-
|
107
|
-
|
108
|
-
# Function soaks.
|
109
|
-
plus1 = (x) -> x + 1
|
110
|
-
count = 0
|
111
|
-
obj = {
|
112
|
-
counter: -> count += 1; this
|
113
|
-
returnThis: -> this
|
114
|
-
}
|
115
|
-
|
116
|
-
eq plus1?(41), 42
|
117
|
-
eq (plus1? 41), 42
|
118
|
-
eq plus2?(41), undefined
|
119
|
-
eq (plus2? 41), undefined
|
120
|
-
eq obj.returnThis?(), obj
|
121
|
-
eq obj.returnSelf?(), undefined
|
122
|
-
eq obj.returnThis?().flag = on, on
|
123
|
-
eq obj.returnSelf?().flag = on, undefined
|
124
|
-
eq obj.counter().counter().returnThis?(), obj
|
125
|
-
eq count, 2
|
126
|
-
|
127
|
-
maybe_close = (f, arg) -> if typeof f is 'function' then () -> f(arg) else -1
|
128
|
-
|
129
|
-
eq maybe_close(plus1, 41)?(), 42
|
130
|
-
eq (maybe_close plus1, 41)?(), 42
|
131
|
-
eq (maybe_close 'string', 41)?(), undefined
|
132
|
-
|
133
|
-
eq 2?(3), undefined
|
134
|
-
eq new Number?(42) | 0, 42
|
135
|
-
eq new Bumper?(42) | 0, 0
|
136
|
-
|
137
|
-
|
138
|
-
#726
|
139
|
-
eq calendar?[Date()], undefined
|
140
|
-
|
141
|
-
|
142
|
-
#733
|
143
|
-
a = b: {c: null}
|
144
|
-
eq a.b?.c?(), undefined
|
145
|
-
|
146
|
-
a.b?.c or= (it) -> it
|
147
|
-
eq a.b?.c?(1), 1
|
148
|
-
eq a.b?.c?([2, 3]...), 2
|
149
|
-
|
150
|
-
|
151
|
-
#756
|
152
|
-
a = null
|
153
|
-
ok isNaN a?.b.c + 1
|
154
|
-
eq undefined, a?.b.c += 1
|
155
|
-
eq undefined, ++a?.b.c
|
156
|
-
eq undefined, delete a?.b.c
|
157
|
-
|
158
|
-
a = b: {c: 0}
|
159
|
-
eq 1, a?.b.c + 1
|
160
|
-
eq 1, a?.b.c += 1
|
161
|
-
eq 2, ++a?.b.c
|
162
|
-
eq yes, delete a?.b.c
|
163
|
-
|
164
|
-
|
165
|
-
eq (1 or 0)?, true, 'postfix `?` should unwrap correctly'
|