Merge branch 'master' of git://github.com/pivotal/jasmine
This commit is contained in:
commit
5e8b52debf
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1 @@
|
||||
.idea/
|
||||
.idea/inspectionProfiles/
|
6
.idea/inspectionProfiles/Project_Default.xml
generated
6
.idea/inspectionProfiles/Project_Default.xml
generated
@ -1,6 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="Project Default" />
|
||||
<option name="myLocal" value="false" />
|
||||
</profile>
|
||||
</component>
|
8
.idea/inspectionProfiles/profiles_settings.xml
generated
8
.idea/inspectionProfiles/profiles_settings.xml
generated
@ -1,8 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="PROJECT_PROFILE" value="Project Default" />
|
||||
<option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
|
||||
<scopes />
|
||||
<list size="0" />
|
||||
</settings>
|
||||
</component>
|
90
Rakefile
90
Rakefile
@ -10,16 +10,86 @@ namespace :test do
|
||||
end
|
||||
|
||||
desc 'Builds lib/jasmine from source'
|
||||
task :build do
|
||||
|
||||
# these files must be better
|
||||
sources = ["src/base.js", "src/util.js", "src/Env.js", "src/ActionCollection.js", "src/Reporter.js"]
|
||||
|
||||
sources += Dir.glob('src/*.js').reject{|f| sources.include?(f)}
|
||||
|
||||
jasmine = File.new('lib/jasmine.js', 'w')
|
||||
sources.each do |source_filename|
|
||||
jasmine.puts(File.read(source_filename))
|
||||
namespace :build do
|
||||
task :jasmine => 'build:doc' do
|
||||
require 'json'
|
||||
sources = jasmine_sources
|
||||
version = version_hash
|
||||
old_jasmine_files = Dir.glob('lib/jasmine*.js')
|
||||
old_jasmine_files.each do |file|
|
||||
File.delete(file)
|
||||
end
|
||||
jasmine = File.new("lib/#{jasmine_filename version}", 'w')
|
||||
jasmine.puts(File.read(sources.shift))
|
||||
jasmine.puts %{
|
||||
jasmine.version_= {
|
||||
"major": #{version['major']},
|
||||
"minor": #{version['minor']},
|
||||
"build": #{version['build']},
|
||||
"revision": #{Time.now.to_i}
|
||||
};
|
||||
}
|
||||
sources.each do |source_filename|
|
||||
jasmine.puts(File.read(source_filename))
|
||||
end
|
||||
end
|
||||
|
||||
desc "Build jasmine documentation"
|
||||
task :doc do
|
||||
require 'rubygems'
|
||||
#sudo gem install ragaskar-jsdoc_helper
|
||||
require 'jsdoc_helper'
|
||||
|
||||
|
||||
JsdocHelper::Rake::Task.new(:lambda_jsdoc)
|
||||
Rake::Task[:lambda_jsdoc].invoke
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def jasmine_sources
|
||||
sources = ["src/base.js", "src/util.js", "src/Env.js", "src/Reporter.js", "src/Block.js"]
|
||||
|
||||
sources += Dir.glob('src/*.js').reject{|f| f == 'src/base.js' || sources.include?(f)}.sort
|
||||
end
|
||||
|
||||
def jasmine_filename(version)
|
||||
"jasmine-#{version['major']}.#{version['minor']}.#{version['build']}.js"
|
||||
end
|
||||
|
||||
def version_hash
|
||||
JSON.parse(File.new("src/version.json").read);
|
||||
end
|
||||
|
||||
namespace :test do
|
||||
desc "Run continuous integration tests"
|
||||
task :ci => 'build:jasmine' do
|
||||
require "spec"
|
||||
require 'spec/rake/spectask'
|
||||
Spec::Rake::SpecTask.new(:lambda_ci) do |t|
|
||||
t.spec_opts = ["--color", "--format", "specdoc"]
|
||||
t.spec_files = ["spec/jasmine_spec.rb"]
|
||||
end
|
||||
Rake::Task[:lambda_ci].invoke
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc "Run jasmine tests via server"
|
||||
task :jasmine_server do
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), "contrib/ruby/jasmine_spec_builder"))
|
||||
|
||||
includes = jasmine_sources + ['lib/TrivialReporter.js']
|
||||
spec_files = Dir.glob("spec/**/*.js")
|
||||
|
||||
dir_mappings = {
|
||||
"/spec" => "spec",
|
||||
"/lib" => "lib",
|
||||
"/src" => 'src'
|
||||
}
|
||||
|
||||
puts "your tests are here:"
|
||||
puts " http://localhost:8888/run.html"
|
||||
|
||||
Jasmine::SimpleServer.start(8888, includes + spec_files, dir_mappings)
|
||||
end
|
@ -1,5 +1,6 @@
|
||||
require 'socket'
|
||||
require 'erb'
|
||||
require 'json'
|
||||
|
||||
module Jasmine
|
||||
# this seemingly-over-complex method is necessary to get an open port on at least some of our Macs
|
||||
@ -73,16 +74,31 @@ module Jasmine
|
||||
end
|
||||
end
|
||||
|
||||
class Redirect
|
||||
def initialize(url)
|
||||
@url = url
|
||||
end
|
||||
|
||||
def call(env)
|
||||
[
|
||||
302,
|
||||
{ 'Location' => @url },
|
||||
[]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
class SimpleServer
|
||||
def self.start(port, spec_files_or_proc, mappings)
|
||||
require 'thin'
|
||||
|
||||
config = {
|
||||
'/' => Jasmine::Redirect.new('/run.html'),
|
||||
'/run.html' => Jasmine::RunAdapter.new(spec_files_or_proc)
|
||||
}
|
||||
mappings.each do |from, to|
|
||||
config[from] = Rack::File.new(to)
|
||||
end
|
||||
end
|
||||
|
||||
app = Rack::URLMap.new(config)
|
||||
|
||||
@ -128,7 +144,7 @@ module Jasmine
|
||||
def eval_js(script)
|
||||
escaped_script = "'" + script.gsub(/(['\\])/) { '\\' + $1 } + "'"
|
||||
|
||||
result = @driver.get_eval("window.eval(#{escaped_script})")
|
||||
result = @driver.get_eval("eval(#{escaped_script}, window)")
|
||||
JSON.parse("[#{result}]")[0]
|
||||
end
|
||||
end
|
||||
|
@ -114,13 +114,15 @@ module Jasmine
|
||||
puts message["text"]
|
||||
puts "\n"
|
||||
else
|
||||
STDERR << message["message"]
|
||||
STDERR << "\n"
|
||||
unless message["message"] =~ /^Passed.$/
|
||||
STDERR << message["message"]
|
||||
STDERR << "\n"
|
||||
|
||||
out << message["message"]
|
||||
out << "\n"
|
||||
out << message["message"]
|
||||
out << "\n"
|
||||
end
|
||||
|
||||
unless message["passed"]
|
||||
unless message["passed_"]
|
||||
stack_trace = message["trace"]["stack"].gsub(/<br \/>/, "\n").gsub(/<\/?b>/, " ")
|
||||
STDERR << stack_trace.gsub(/\(.*\)@http:\/\/localhost:[0-9]+\/specs\//, "/spec/")
|
||||
STDERR << "\n"
|
||||
@ -129,7 +131,7 @@ module Jasmine
|
||||
|
||||
end
|
||||
fail out unless spec_results['result'] == 'passed'
|
||||
puts out
|
||||
puts out unless out.empty?
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -3,12 +3,10 @@
|
||||
<head>
|
||||
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type"/>
|
||||
<title>Jasmine suite</title>
|
||||
<script src="/jasmine/lib/jasmine.js"></script>
|
||||
<script src="/jasmine/lib/json2.js"></script><!-- todo: don't load JSON in the test runner! [20090710 xw] -->
|
||||
<script src="/jasmine/lib/TrivialReporter.js"></script>
|
||||
<script src="/specs/javascripts/screw-jasmine-compat.js"></script>
|
||||
<script type="text/javascript"></script>
|
||||
<link href="/jasmine/lib/jasmine.css" rel="stylesheet"/>
|
||||
<link rel="stylesheet" href="lib/jasmine.css" type="text/css" media="screen" />
|
||||
<% spec_files.each do |spec_file| %>
|
||||
<script src="<%= spec_file %>" type="text/javascript"></script>
|
||||
<% end %>
|
||||
<script type="text/javascript">
|
||||
var jsApiReporter;
|
||||
(function() {
|
||||
@ -31,9 +29,7 @@
|
||||
})();
|
||||
</script>
|
||||
|
||||
<% spec_files.each do |spec_file| %>
|
||||
<script src="<%= spec_file %>" type="text/javascript"></script>
|
||||
<% end %>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="jasmine_content"></div>
|
||||
|
@ -1,6 +1,6 @@
|
||||
require 'spec'
|
||||
require 'open-uri'
|
||||
require File.dirname(__FILE__) + '/jasmine_runner'
|
||||
require File.dirname(__FILE__) + '/../jasmine_runner'
|
||||
|
||||
describe Jasmine::SimpleServer do
|
||||
before do
|
@ -188,16 +188,16 @@ ul.inheritsList
|
||||
|
||||
<li><a href="symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
<li><a href="symbols/jasmine.Block.html">jasmine.Block</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
@ -219,7 +219,31 @@ ul.inheritsList
|
||||
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/src/lib_jasmine.js.html">lib/jasmine.js</a></h2>
|
||||
<h2><a href="symbols/src/lib_jasmine-0.9.0.js.html">lib/jasmine-0.9.0.js</a></h2>
|
||||
|
||||
<dl>
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/src/lib_json2.js.html">lib/json2.js</a></h2>
|
||||
|
||||
<dl>
|
||||
|
||||
|
||||
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/src/lib_TrivialReporter.js.html">lib/TrivialReporter.js</a></h2>
|
||||
|
||||
<dl>
|
||||
|
||||
@ -234,7 +258,7 @@ ul.inheritsList
|
||||
</div>
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blankt">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -2,7 +2,7 @@
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8"" />
|
||||
|
||||
<title>JsDoc Reference - Index</title>
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
@ -188,16 +188,16 @@ ul.inheritsList
|
||||
|
||||
<li><a href="symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
<li><a href="symbols/jasmine.Block.html">jasmine.Block</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
@ -231,7 +231,7 @@ ul.inheritsList
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></h2>
|
||||
<h2><a href="symbols/jasmine.Block.html">jasmine.Block</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
@ -242,6 +242,12 @@ ul.inheritsList
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></h2>
|
||||
|
||||
@ -254,12 +260,6 @@ ul.inheritsList
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></h2>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div>
|
||||
<h2><a href="symbols/jasmine.Reporter.html">jasmine.Reporter</a></h2>
|
||||
|
||||
@ -300,7 +300,7 @@ ul.inheritsList
|
||||
</div>
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blankt">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -193,16 +193,16 @@ ul.inheritsList
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
<li><a href="../symbols/jasmine.Block.html">jasmine.Block</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
@ -389,7 +389,7 @@ ul.inheritsList
|
||||
Used for restoring any state that is hijacked during spec execution.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
@ -430,7 +430,7 @@ Used for restoring any state that is hijacked during spec execution.
|
||||
Used for spec setup, including validating assumptions.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
@ -473,7 +473,7 @@ are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be
|
||||
of setup in some tests.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
@ -527,7 +527,7 @@ It is passed an Object that is the actual value and should chain to one of the m
|
||||
jasmine.Matchers functions.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
@ -568,7 +568,7 @@ jasmine.Matchers functions.
|
||||
// TODO: pending tests
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
@ -619,7 +619,7 @@ jasmine.Matchers functions.
|
||||
Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
@ -658,7 +658,7 @@ jasmine.Matchers functions.
|
||||
Function that installs a spy on an existing object's method name. Used within a Spec to create a spy.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
@ -725,7 +725,7 @@ spyOn(foo, 'not'); // actual foo.not will not be called, execution stops</pre>
|
||||
Waits for a timeout before moving to the next runs()-defined block.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
@ -764,7 +764,7 @@ spyOn(foo, 'not'); // actual foo.not will not be called, execution stops</pre>
|
||||
Waits for the latchFunction to return true before proceeding to the next runs()-defined block.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
@ -815,7 +815,7 @@ spyOn(foo, 'not'); // actual foo.not will not be called, execution stops</pre>
|
||||
Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
@ -862,7 +862,7 @@ spyOn(foo, 'not'); // actual foo.not will not be called, execution stops</pre>
|
||||
A convenience method that allows existing specs to be disabled temporarily during development.
|
||||
|
||||
<br />
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
|
||||
</div>
|
||||
@ -908,7 +908,7 @@ A convenience method that allows existing specs to be disabled temporarily durin
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:18 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<title>JsDoc Reference - jasmine.QueuedFunction</title>
|
||||
<title>JsDoc Reference - jasmine.Block</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
@ -193,16 +193,16 @@ ul.inheritsList
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
<li><a href="../symbols/jasmine.Block.html">jasmine.Block</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
@ -224,7 +224,7 @@ ul.inheritsList
|
||||
<!-- ============================== class title ============================ -->
|
||||
<h1 class="classTitle">
|
||||
|
||||
Class jasmine.QueuedFunction
|
||||
Class jasmine.Block
|
||||
</h1>
|
||||
|
||||
<!-- ============================== class summary ========================== -->
|
||||
@ -234,13 +234,13 @@ ul.inheritsList
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
<!-- ============================== constructor summary ==================== -->
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.QueuedFunction.">
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.Block.">
|
||||
<caption>Class Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
@ -253,9 +253,9 @@ ul.inheritsList
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.QueuedFunction.html#constructor">jasmine.QueuedFunction</a></b>(env, func, timeout, latchFunction, spec)
|
||||
<b><a href="../symbols/jasmine.Block.html">jasmine.Block</a></b>(env, func, spec)
|
||||
</div>
|
||||
<div class="description">QueuedFunction is how ActionCollections' actions are implemented</div>
|
||||
<div class="description">Blocks are functions with executable code that make up a spec.</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -278,11 +278,11 @@ ul.inheritsList
|
||||
</div>
|
||||
|
||||
<div class="fixedFont">
|
||||
<b>jasmine.QueuedFunction</b>(env, func, timeout, latchFunction, spec)
|
||||
<b>jasmine.Block</b>(env, func, spec)
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
QueuedFunction is how ActionCollections' actions are implemented
|
||||
Blocks are functions with executable code that make up a spec.
|
||||
|
||||
</div>
|
||||
|
||||
@ -305,18 +305,6 @@ ul.inheritsList
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Number}</span> <b>timeout</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{Function}</span> <b>latchFunction</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{<a href="../symbols/jasmine.Spec.html">jasmine.Spec</a>}</span> <b>spec</b>
|
||||
|
||||
@ -351,7 +339,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -193,16 +193,16 @@ ul.inheritsList
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
<li><a href="../symbols/jasmine.Block.html">jasmine.Block</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
@ -234,7 +234,7 @@ ul.inheritsList
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
@ -253,7 +253,7 @@ ul.inheritsList
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Env.html#constructor">jasmine.Env</a></b>()
|
||||
<b><a href="../symbols/jasmine.Env.html">jasmine.Env</a></b>()
|
||||
</div>
|
||||
<div class="description">Environment for Jasmine</div>
|
||||
</td>
|
||||
@ -384,7 +384,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="JsDoc Toolkit" />
|
||||
|
||||
<title>JsDoc Reference - jasmine.ActionCollection</title>
|
||||
<title>JsDoc Reference - jasmine.JsApiReporter</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* default.css */
|
||||
@ -193,16 +193,16 @@ ul.inheritsList
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
<li><a href="../symbols/jasmine.Block.html">jasmine.Block</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
@ -224,7 +224,7 @@ ul.inheritsList
|
||||
<!-- ============================== class title ============================ -->
|
||||
<h1 class="classTitle">
|
||||
|
||||
Class jasmine.ActionCollection
|
||||
Class jasmine.JsApiReporter
|
||||
</h1>
|
||||
|
||||
<!-- ============================== class summary ========================== -->
|
||||
@ -234,13 +234,13 @@ ul.inheritsList
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
<!-- ============================== constructor summary ==================== -->
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.ActionCollection.">
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class jasmine.JsApiReporter.">
|
||||
<caption>Class Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
@ -253,11 +253,9 @@ ul.inheritsList
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.ActionCollection.html#constructor">jasmine.ActionCollection</a></b>(env)
|
||||
<b><a href="../symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></b>()
|
||||
</div>
|
||||
<div class="description">base for Runner & Suite: allows for a queue of functions to get executed, allowing for
|
||||
any one action to complete, including asynchronous calls, before going to the next
|
||||
action.</div>
|
||||
<div class="description">JavaScript API reporter.</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -269,60 +267,6 @@ ul.inheritsList
|
||||
|
||||
<!-- ============================== methods summary ======================== -->
|
||||
|
||||
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the methods documented in the class jasmine.ActionCollection.">
|
||||
<caption>Method Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Method Attributes</th>
|
||||
<th scope="col">Method Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.ActionCollection.html#execute">execute</a></b>()
|
||||
</div>
|
||||
<div class="description">Starts executing the queue of functions/actions.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.ActionCollection.html#finish">finish</a></b>()
|
||||
</div>
|
||||
<div class="description">Marks the collection as done & calls the finish callback, if there is one</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.ActionCollection.html#getCurrentAction">getCurrentAction</a></b>()
|
||||
</div>
|
||||
<div class="description">Gets the current action.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont"><b><a href="../symbols/jasmine.ActionCollection.html#next">next</a></b>()
|
||||
</div>
|
||||
<div class="description">Executes the next queued function/action.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== events summary ======================== -->
|
||||
|
||||
|
||||
@ -334,13 +278,11 @@ ul.inheritsList
|
||||
</div>
|
||||
|
||||
<div class="fixedFont">
|
||||
<b>jasmine.ActionCollection</b>(env)
|
||||
<b>jasmine.JsApiReporter</b>()
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
base for Runner & Suite: allows for a queue of functions to get executed, allowing for
|
||||
any one action to complete, including asynchronous calls, before going to the next
|
||||
action.
|
||||
JavaScript API reporter.
|
||||
|
||||
</div>
|
||||
|
||||
@ -348,17 +290,6 @@ ul.inheritsList
|
||||
|
||||
|
||||
|
||||
<dl class="detailList">
|
||||
<dt class="heading">Parameters:</dt>
|
||||
|
||||
<dt>
|
||||
<span class="light fixedFont">{<a href="../symbols/jasmine.Env.html">jasmine.Env</a>}</span> <b>env</b>
|
||||
|
||||
</dt>
|
||||
<dd></dd>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -374,111 +305,6 @@ ul.inheritsList
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
|
||||
<div class="sectionTitle">
|
||||
Method Detail
|
||||
</div>
|
||||
|
||||
<a name="execute"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>execute</b>()
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Starts executing the queue of functions/actions.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="finish"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>finish</b>()
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Marks the collection as done & calls the finish callback, if there is one
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="getCurrentAction"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>getCurrentAction</b>()
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Gets the current action.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<a name="next"> </a>
|
||||
<div class="fixedFont">
|
||||
|
||||
|
||||
<b>next</b>()
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Executes the next queued function/action. If there are no more in the queue, calls #finish.
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== event details ========================= -->
|
||||
|
||||
@ -490,7 +316,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:18 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -193,16 +193,16 @@ ul.inheritsList
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
<li><a href="../symbols/jasmine.Block.html">jasmine.Block</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
@ -234,7 +234,7 @@ ul.inheritsList
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
@ -253,7 +253,7 @@ ul.inheritsList
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.MultiReporter.html#constructor">jasmine.MultiReporter</a></b>()
|
||||
<b><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></b>()
|
||||
</div>
|
||||
<div class="description"></div>
|
||||
</td>
|
||||
@ -316,7 +316,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -193,16 +193,16 @@ ul.inheritsList
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
<li><a href="../symbols/jasmine.Block.html">jasmine.Block</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
@ -234,7 +234,7 @@ ul.inheritsList
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
@ -253,7 +253,7 @@ ul.inheritsList
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.NestedResults.html#constructor">jasmine.NestedResults</a></b>()
|
||||
<b><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></b>()
|
||||
</div>
|
||||
<div class="description">Holds results for a set of Jasmine spec.</div>
|
||||
</td>
|
||||
@ -700,7 +700,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -193,16 +193,16 @@ ul.inheritsList
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
<li><a href="../symbols/jasmine.Block.html">jasmine.Block</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
@ -234,7 +234,7 @@ ul.inheritsList
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
@ -253,7 +253,7 @@ ul.inheritsList
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Reporter.html#constructor">jasmine.Reporter</a></b>()
|
||||
<b><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></b>()
|
||||
</div>
|
||||
<div class="description">No-op base class for Jasmine reporters.</div>
|
||||
</td>
|
||||
@ -316,7 +316,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -193,16 +193,16 @@ ul.inheritsList
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
<li><a href="../symbols/jasmine.Block.html">jasmine.Block</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
@ -234,7 +234,7 @@ ul.inheritsList
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
@ -253,7 +253,7 @@ ul.inheritsList
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Runner.html#constructor">jasmine.Runner</a></b>(env)
|
||||
<b><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></b>(env)
|
||||
</div>
|
||||
<div class="description">Runner</div>
|
||||
</td>
|
||||
@ -327,7 +327,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -193,16 +193,16 @@ ul.inheritsList
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
<li><a href="../symbols/jasmine.Block.html">jasmine.Block</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
@ -234,7 +234,7 @@ ul.inheritsList
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
@ -253,7 +253,7 @@ ul.inheritsList
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Spec.html#constructor">jasmine.Spec</a></b>(env, suite, description)
|
||||
<b><a href="../symbols/jasmine.Spec.html">jasmine.Spec</a></b>(env, suite, description)
|
||||
</div>
|
||||
<div class="description">Internal representation of a Jasmine specification, or test.</div>
|
||||
</td>
|
||||
@ -339,7 +339,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -193,16 +193,16 @@ ul.inheritsList
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
<li><a href="../symbols/jasmine.Block.html">jasmine.Block</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
@ -234,7 +234,7 @@ ul.inheritsList
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
@ -253,7 +253,7 @@ ul.inheritsList
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Spy.html#constructor">jasmine.Spy</a></b>(name)
|
||||
<b><a href="../symbols/jasmine.Spy.html">jasmine.Spy</a></b>(name)
|
||||
</div>
|
||||
<div class="description">Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks.</div>
|
||||
</td>
|
||||
@ -845,7 +845,7 @@ expect(foo.bar.callCount).toEqual(0);</pre>
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -193,16 +193,16 @@ ul.inheritsList
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
<li><a href="../symbols/jasmine.Block.html">jasmine.Block</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
@ -234,7 +234,7 @@ ul.inheritsList
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
@ -253,7 +253,7 @@ ul.inheritsList
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.Suite.html#constructor">jasmine.Suite</a></b>(env, description, specDefinitions, parentSuite)
|
||||
<b><a href="../symbols/jasmine.Suite.html">jasmine.Suite</a></b>(env, description, specDefinitions, parentSuite)
|
||||
</div>
|
||||
<div class="description">Internal representation of a Jasmine suite.</div>
|
||||
</td>
|
||||
@ -345,7 +345,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -193,16 +193,16 @@ ul.inheritsList
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
<li><a href="../symbols/jasmine.Block.html">jasmine.Block</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
@ -234,7 +234,7 @@ ul.inheritsList
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
@ -253,7 +253,7 @@ ul.inheritsList
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.html#constructor">jasmine</a></b>
|
||||
<b><a href="../symbols/jasmine.html">jasmine</a></b>
|
||||
</div>
|
||||
<div class="description">Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.</div>
|
||||
</td>
|
||||
@ -678,7 +678,7 @@ Jasmine environment.
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:18 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -193,16 +193,16 @@ ul.inheritsList
|
||||
|
||||
<li><a href="../symbols/jasmine.html">jasmine</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.ActionCollection.html">jasmine.ActionCollection</a></li>
|
||||
<li><a href="../symbols/jasmine.Block.html">jasmine.Block</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Env.html">jasmine.Env</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.JsApiReporter.html">jasmine.JsApiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.MultiReporter.html">jasmine.MultiReporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.NestedResults.html">jasmine.NestedResults</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.QueuedFunction.html">jasmine.QueuedFunction</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Reporter.html">jasmine.Reporter</a></li>
|
||||
|
||||
<li><a href="../symbols/jasmine.Runner.html">jasmine.Runner</a></li>
|
||||
@ -234,7 +234,7 @@ ul.inheritsList
|
||||
|
||||
|
||||
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine.js.html">jasmine.js</a>.
|
||||
<br /><i>Defined in: </i> <a href="../symbols/src/lib_jasmine-0.9.0.js.html">jasmine-0.9.0.js</a>.
|
||||
|
||||
</p>
|
||||
|
||||
@ -253,7 +253,7 @@ ul.inheritsList
|
||||
<td class="attributes"> </td>
|
||||
<td class="nameDescription" >
|
||||
<div class="fixedFont">
|
||||
<b><a href="../symbols/jasmine.util.html#constructor">jasmine.util</a></b>
|
||||
<b><a href="../symbols/jasmine.util.html">jasmine.util</a></b>
|
||||
</div>
|
||||
<div class="description"></div>
|
||||
</td>
|
||||
@ -316,7 +316,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.3.0 on Thu Jul 09 2009 21:42:19 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
128
doc/symbols/src/lib_TrivialReporter.js.html
Normal file
128
doc/symbols/src/lib_TrivialReporter.js.html
Normal file
@ -0,0 +1,128 @@
|
||||
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
|
||||
.KEYW {color: #933;}
|
||||
.COMM {color: #bbb; font-style: italic;}
|
||||
.NUMB {color: #393;}
|
||||
.STRN {color: #393;}
|
||||
.REGX {color: #339;}
|
||||
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
|
||||
</style></head><body><pre><span class='line'> 1</span> <span class="NAME">jasmine.TrivialReporter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">doc</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 2</span> </span><span class="WHIT"> </span><span class="NAME">this.document</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">doc</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">document</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 3</span> </span><span class="WHIT"> </span><span class="NAME">this.suiteDivs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 4</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 5</span>
|
||||
<span class='line'> 6</span> </span><span class="NAME">jasmine.TrivialReporter.prototype.createDom</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">attrs</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">childrenVarArgs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 7</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">el</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 8</span>
|
||||
<span class='line'> 9</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">arguments.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 10</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">child</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 11</span>
|
||||
<span class='line'> 12</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">child</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 13</span> </span><span class="WHIT"> </span><span class="NAME">el.appendChild</span><span class="PUNC">(</span><span class="NAME">document.createTextNode</span><span class="PUNC">(</span><span class="NAME">child</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 14</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 15</span> </span><span class="WHIT"> </span><span class="NAME">el.appendChild</span><span class="PUNC">(</span><span class="NAME">child</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 16</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 17</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 18</span>
|
||||
<span class='line'> 19</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">attr</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">attrs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 20</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">attr</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'className'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 21</span> </span><span class="WHIT"> </span><span class="NAME">el.setAttribute</span><span class="PUNC">(</span><span class="STRN">'class'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">attrs</span><span class="PUNC">[</span><span class="NAME">attr</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 22</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 23</span> </span><span class="WHIT"> </span><span class="NAME">el</span><span class="PUNC">[</span><span class="NAME">attr</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">attrs</span><span class="PUNC">[</span><span class="NAME">attr</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 24</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 25</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 26</span>
|
||||
<span class='line'> 27</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">el</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 28</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 29</span>
|
||||
<span class='line'> 30</span> </span><span class="NAME">jasmine.TrivialReporter.prototype.reportRunnerStarting</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">runner</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 31</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">suites</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">runner.suites</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 32</span>
|
||||
<span class='line'> 33</span> </span><span class="WHIT"> </span><span class="NAME">this.runnerDiv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.createDom</span><span class="PUNC">(</span><span class="STRN">'div'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">className</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'runner running'</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Running..."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 34</span> </span><span class="WHIT"> </span><span class="NAME">this.document.body.appendChild</span><span class="PUNC">(</span><span class="NAME">this.runnerDiv</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 35</span>
|
||||
<span class='line'> 36</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">suites.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 37</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">suite</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">suites</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 38</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">suiteDiv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.createDom</span><span class="PUNC">(</span><span class="STRN">'div'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">className</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'suite'</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 39</span> </span><span class="WHIT"> </span><span class="NAME">this.createDom</span><span class="PUNC">(</span><span class="STRN">'a'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">className</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'runSpec'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">href</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'?spec='</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">suite.getFullName</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"run"</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 40</span> </span><span class="WHIT"> </span><span class="NAME">suite.description</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 41</span> </span><span class="WHIT"> </span><span class="NAME">this.suiteDivs</span><span class="PUNC">[</span><span class="NAME">suite.getFullName</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">suiteDiv</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 42</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">parentDiv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.document.body</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 43</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">suite.parentSuite</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 44</span> </span><span class="WHIT"> </span><span class="NAME">parentDiv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.suiteDivs</span><span class="PUNC">[</span><span class="NAME">suite.parentSuite.getFullName</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 45</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 46</span> </span><span class="WHIT"> </span><span class="NAME">parentDiv.appendChild</span><span class="PUNC">(</span><span class="NAME">suiteDiv</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 47</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 48</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 49</span>
|
||||
<span class='line'> 50</span> </span><span class="NAME">jasmine.TrivialReporter.prototype.reportRunnerResults</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">runner</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 51</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">results</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">runner.getResults</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 52</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">className</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">results.failedCount</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"runner failed"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"runner passed"</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 53</span> </span><span class="WHIT"> </span><span class="NAME">this.runnerDiv.setAttribute</span><span class="PUNC">(</span><span class="STRN">"class"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">className</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 54</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">message</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">results.failedCount</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" failure"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">results.failedCount</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">""</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"s"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 55</span> </span><span class="WHIT"> </span><span class="NAME">this.runnerDiv.replaceChild</span><span class="PUNC">(</span><span class="NAME">this.document.createTextNode</span><span class="PUNC">(</span><span class="NAME">message</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.runnerDiv.firstChild</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 56</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 57</span>
|
||||
<span class='line'> 58</span> </span><span class="NAME">jasmine.TrivialReporter.prototype.reportSuiteResults</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">suite</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 59</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">results</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">suite.getResults</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 60</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">status</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">results.passed</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'passed'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'failed'</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 61</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">results.totalCount</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// todo: change this to check results.skipped</span><span class="WHIT">
|
||||
<span class='line'> 62</span> </span><span class="WHIT"> </span><span class="NAME">status</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'skipped'</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 63</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 64</span> </span><span class="WHIT"> </span><span class="NAME">this.suiteDivs</span><span class="PUNC">[</span><span class="NAME">suite.getFullName</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">className</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">" "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">status</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 65</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 66</span>
|
||||
<span class='line'> 67</span> </span><span class="NAME">jasmine.TrivialReporter.prototype.reportSpecResults</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">spec</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">results</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">spec.getResults</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 69</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">status</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">results.passed</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'passed'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'failed'</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 70</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">results.skipped</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="NAME">status</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'skipped'</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 72</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 73</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">specDiv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.createDom</span><span class="PUNC">(</span><span class="STRN">'div'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">className</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'spec '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">status</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="NAME">this.createDom</span><span class="PUNC">(</span><span class="STRN">'a'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">className</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'runSpec'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">href</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'?spec='</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">encodeURIComponent</span><span class="PUNC">(</span><span class="NAME">spec.getFullName</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"run"</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'> 75</span> </span><span class="WHIT"> </span><span class="NAME">spec.getFullName</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 76</span>
|
||||
<span class='line'> 77</span>
|
||||
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">resultItems</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">results.getItems</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">resultItems.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">resultItems</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 81</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">result.passed</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">result.passed</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 82</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">resultMessageDiv</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.createDom</span><span class="PUNC">(</span><span class="STRN">'div'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">className</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'resultMessage fail'</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 83</span> </span><span class="WHIT"> </span><span class="NAME">resultMessageDiv.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">result.message</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// todo: lame; mend</span><span class="WHIT">
|
||||
<span class='line'> 84</span> </span><span class="WHIT"> </span><span class="NAME">specDiv.appendChild</span><span class="PUNC">(</span><span class="NAME">resultMessageDiv</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="NAME">specDiv.appendChild</span><span class="PUNC">(</span><span class="NAME">this.createDom</span><span class="PUNC">(</span><span class="STRN">'div'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">className</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'stackTrace'</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">result.trace.stack</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 86</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 87</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'> 88</span>
|
||||
<span class='line'> 89</span> </span><span class="WHIT"> </span><span class="NAME">this.suiteDivs</span><span class="PUNC">[</span><span class="NAME">spec.suite.getFullName</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">appendChild</span><span class="PUNC">(</span><span class="NAME">specDiv</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 90</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 91</span>
|
||||
<span class='line'> 92</span> </span><span class="NAME">jasmine.TrivialReporter.prototype.log</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 93</span> </span><span class="WHIT"> </span><span class="NAME">console.log.apply</span><span class="PUNC">(</span><span class="NAME">console</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 94</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 95</span>
|
||||
<span class='line'> 96</span> </span><span class="NAME">jasmine.TrivialReporter.prototype.getLocation</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'> 97</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.document.location</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 98</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'> 99</span>
|
||||
<span class='line'>100</span> </span><span class="NAME">jasmine.TrivialReporter.prototype.specFilter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">spec</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>101</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">paramMap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>102</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.getLocation</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">search.substring</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">split</span><span class="PUNC">(</span><span class="STRN">'&'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>103</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">params.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>104</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">params</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">split</span><span class="PUNC">(</span><span class="STRN">'='</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>105</span> </span><span class="WHIT"> </span><span class="NAME">paramMap</span><span class="PUNC">[</span><span class="NAME">decodeURIComponent</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">decodeURIComponent</span><span class="PUNC">(</span><span class="NAME">p</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>106</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>107</span>
|
||||
<span class='line'>108</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">paramMap</span><span class="PUNC">[</span><span class="STRN">"spec"</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>109</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">spec.getFullName</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">indexOf</span><span class="PUNC">(</span><span class="NAME">paramMap</span><span class="PUNC">[</span><span class="STRN">"spec"</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>110</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>111</span>
|
||||
<span class='line'>112</span> </span><span class="COMM">//protect against console.log incidents</span><span class="WHIT">
|
||||
<span class='line'>113</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="STRN">"console"</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="STRN">"firebug"</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">console</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>114</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">names</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">"log"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"debug"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"info"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"warn"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"error"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"assert"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"dir"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"dirxml"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"group"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"groupEnd"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"time"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"timeEnd"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"count"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"trace"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"profile"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"profileEnd"</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>115</span> </span><span class="WHIT"> </span><span class="NAME">window.console</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>116</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">names.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">++</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>117</span> </span><span class="WHIT"> </span><span class="NAME">window.console</span><span class="PUNC">[</span><span class="NAME">names</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>118</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>119</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>120</span> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>121</span> </span></pre></body></html>
|
File diff suppressed because it is too large
Load Diff
486
doc/symbols/src/lib_json2.js.html
Normal file
486
doc/symbols/src/lib_json2.js.html
Normal file
@ -0,0 +1,486 @@
|
||||
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
|
||||
.KEYW {color: #933;}
|
||||
.COMM {color: #bbb; font-style: italic;}
|
||||
.NUMB {color: #393;}
|
||||
.STRN {color: #393;}
|
||||
.REGX {color: #339;}
|
||||
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
|
||||
</style></head><body><pre><span class='line'> 1</span> <span class="COMM">/*
|
||||
<span class='line'> 2</span> http://www.JSON.org/json2.js
|
||||
<span class='line'> 3</span> 2008-11-19
|
||||
<span class='line'> 4</span>
|
||||
<span class='line'> 5</span> Public Domain.
|
||||
<span class='line'> 6</span>
|
||||
<span class='line'> 7</span> NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
||||
<span class='line'> 8</span>
|
||||
<span class='line'> 9</span> See http://www.JSON.org/js.html
|
||||
<span class='line'> 10</span>
|
||||
<span class='line'> 11</span> This file creates a global JSON object containing two methods: stringify
|
||||
<span class='line'> 12</span> and parse.
|
||||
<span class='line'> 13</span>
|
||||
<span class='line'> 14</span> JSON.stringify(value, replacer, space)
|
||||
<span class='line'> 15</span> value any JavaScript value, usually an object or array.
|
||||
<span class='line'> 16</span>
|
||||
<span class='line'> 17</span> replacer an optional parameter that determines how object
|
||||
<span class='line'> 18</span> values are stringified for objects. It can be a
|
||||
<span class='line'> 19</span> function or an array of strings.
|
||||
<span class='line'> 20</span>
|
||||
<span class='line'> 21</span> space an optional parameter that specifies the indentation
|
||||
<span class='line'> 22</span> of nested structures. If it is omitted, the text will
|
||||
<span class='line'> 23</span> be packed without extra whitespace. If it is a number,
|
||||
<span class='line'> 24</span> it will specify the number of spaces to indent at each
|
||||
<span class='line'> 25</span> level. If it is a string (such as '\t' or ' '),
|
||||
<span class='line'> 26</span> it contains the characters used to indent at each level.
|
||||
<span class='line'> 27</span>
|
||||
<span class='line'> 28</span> This method produces a JSON text from a JavaScript value.
|
||||
<span class='line'> 29</span>
|
||||
<span class='line'> 30</span> When an object value is found, if the object contains a toJSON
|
||||
<span class='line'> 31</span> method, its toJSON method will be called and the result will be
|
||||
<span class='line'> 32</span> stringified. A toJSON method does not serialize: it returns the
|
||||
<span class='line'> 33</span> value represented by the name/value pair that should be serialized,
|
||||
<span class='line'> 34</span> or undefined if nothing should be serialized. The toJSON method
|
||||
<span class='line'> 35</span> will be passed the key associated with the value, and this will be
|
||||
<span class='line'> 36</span> bound to the object holding the key.
|
||||
<span class='line'> 37</span>
|
||||
<span class='line'> 38</span> For example, this would serialize Dates as ISO strings.
|
||||
<span class='line'> 39</span>
|
||||
<span class='line'> 40</span> Date.prototype.toJSON = function (key) {
|
||||
<span class='line'> 41</span> function f(n) {
|
||||
<span class='line'> 42</span> // Format integers to have at least two digits.
|
||||
<span class='line'> 43</span> return n < 10 ? '0' + n : n;
|
||||
<span class='line'> 44</span> }
|
||||
<span class='line'> 45</span>
|
||||
<span class='line'> 46</span> return this.getUTCFullYear() + '-' +
|
||||
<span class='line'> 47</span> f(this.getUTCMonth() + 1) + '-' +
|
||||
<span class='line'> 48</span> f(this.getUTCDate()) + 'T' +
|
||||
<span class='line'> 49</span> f(this.getUTCHours()) + ':' +
|
||||
<span class='line'> 50</span> f(this.getUTCMinutes()) + ':' +
|
||||
<span class='line'> 51</span> f(this.getUTCSeconds()) + 'Z';
|
||||
<span class='line'> 52</span> };
|
||||
<span class='line'> 53</span>
|
||||
<span class='line'> 54</span> You can provide an optional replacer method. It will be passed the
|
||||
<span class='line'> 55</span> key and value of each member, with this bound to the containing
|
||||
<span class='line'> 56</span> object. The value that is returned from your method will be
|
||||
<span class='line'> 57</span> serialized. If your method returns undefined, then the member will
|
||||
<span class='line'> 58</span> be excluded from the serialization.
|
||||
<span class='line'> 59</span>
|
||||
<span class='line'> 60</span> If the replacer parameter is an array of strings, then it will be
|
||||
<span class='line'> 61</span> used to select the members to be serialized. It filters the results
|
||||
<span class='line'> 62</span> such that only members with keys listed in the replacer array are
|
||||
<span class='line'> 63</span> stringified.
|
||||
<span class='line'> 64</span>
|
||||
<span class='line'> 65</span> Values that do not have JSON representations, such as undefined or
|
||||
<span class='line'> 66</span> functions, will not be serialized. Such values in objects will be
|
||||
<span class='line'> 67</span> dropped; in arrays they will be replaced with null. You can use
|
||||
<span class='line'> 68</span> a replacer function to replace those with JSON values.
|
||||
<span class='line'> 69</span> JSON.stringify(undefined) returns undefined.
|
||||
<span class='line'> 70</span>
|
||||
<span class='line'> 71</span> The optional space parameter produces a stringification of the
|
||||
<span class='line'> 72</span> value that is filled with line breaks and indentation to make it
|
||||
<span class='line'> 73</span> easier to read.
|
||||
<span class='line'> 74</span>
|
||||
<span class='line'> 75</span> If the space parameter is a non-empty string, then that string will
|
||||
<span class='line'> 76</span> be used for indentation. If the space parameter is a number, then
|
||||
<span class='line'> 77</span> the indentation will be that many spaces.
|
||||
<span class='line'> 78</span>
|
||||
<span class='line'> 79</span> Example:
|
||||
<span class='line'> 80</span>
|
||||
<span class='line'> 81</span> text = JSON.stringify(['e', {pluribus: 'unum'}]);
|
||||
<span class='line'> 82</span> // text is '["e",{"pluribus":"unum"}]'
|
||||
<span class='line'> 83</span>
|
||||
<span class='line'> 84</span>
|
||||
<span class='line'> 85</span> text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
|
||||
<span class='line'> 86</span> // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
|
||||
<span class='line'> 87</span>
|
||||
<span class='line'> 88</span> text = JSON.stringify([new Date()], function (key, value) {
|
||||
<span class='line'> 89</span> return this[key] instanceof Date ?
|
||||
<span class='line'> 90</span> 'Date(' + this[key] + ')' : value;
|
||||
<span class='line'> 91</span> });
|
||||
<span class='line'> 92</span> // text is '["Date(---current time---)"]'
|
||||
<span class='line'> 93</span>
|
||||
<span class='line'> 94</span>
|
||||
<span class='line'> 95</span> JSON.parse(text, reviver)
|
||||
<span class='line'> 96</span> This method parses a JSON text to produce an object or array.
|
||||
<span class='line'> 97</span> It can throw a SyntaxError exception.
|
||||
<span class='line'> 98</span>
|
||||
<span class='line'> 99</span> The optional reviver parameter is a function that can filter and
|
||||
<span class='line'>100</span> transform the results. It receives each of the keys and values,
|
||||
<span class='line'>101</span> and its return value is used instead of the original value.
|
||||
<span class='line'>102</span> If it returns what it received, then the structure is not modified.
|
||||
<span class='line'>103</span> If it returns undefined then the member is deleted.
|
||||
<span class='line'>104</span>
|
||||
<span class='line'>105</span> Example:
|
||||
<span class='line'>106</span>
|
||||
<span class='line'>107</span> // Parse the text. Values that look like ISO date strings will
|
||||
<span class='line'>108</span> // be converted to Date objects.
|
||||
<span class='line'>109</span>
|
||||
<span class='line'>110</span> myData = JSON.parse(text, function (key, value) {
|
||||
<span class='line'>111</span> var a;
|
||||
<span class='line'>112</span> if (typeof value === 'string') {
|
||||
<span class='line'>113</span> a =
|
||||
<span class='line'>114</span> /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
|
||||
<span class='line'>115</span> if (a) {
|
||||
<span class='line'>116</span> return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
|
||||
<span class='line'>117</span> +a[5], +a[6]));
|
||||
<span class='line'>118</span> }
|
||||
<span class='line'>119</span> }
|
||||
<span class='line'>120</span> return value;
|
||||
<span class='line'>121</span> });
|
||||
<span class='line'>122</span>
|
||||
<span class='line'>123</span> myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
|
||||
<span class='line'>124</span> var d;
|
||||
<span class='line'>125</span> if (typeof value === 'string' &&
|
||||
<span class='line'>126</span> value.slice(0, 5) === 'Date(' &&
|
||||
<span class='line'>127</span> value.slice(-1) === ')') {
|
||||
<span class='line'>128</span> d = new Date(value.slice(5, -1));
|
||||
<span class='line'>129</span> if (d) {
|
||||
<span class='line'>130</span> return d;
|
||||
<span class='line'>131</span> }
|
||||
<span class='line'>132</span> }
|
||||
<span class='line'>133</span> return value;
|
||||
<span class='line'>134</span> });
|
||||
<span class='line'>135</span>
|
||||
<span class='line'>136</span>
|
||||
<span class='line'>137</span> This is a reference implementation. You are free to copy, modify, or
|
||||
<span class='line'>138</span> redistribute.
|
||||
<span class='line'>139</span>
|
||||
<span class='line'>140</span> This code should be minified before deployment.
|
||||
<span class='line'>141</span> See http://javascript.crockford.com/jsmin.html
|
||||
<span class='line'>142</span>
|
||||
<span class='line'>143</span> USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
|
||||
<span class='line'>144</span> NOT CONTROL.
|
||||
<span class='line'>145</span> */</span><span class="WHIT">
|
||||
<span class='line'>146</span>
|
||||
<span class='line'>147</span> </span><span class="COMM">/*jslint evil: true */</span><span class="WHIT">
|
||||
<span class='line'>148</span>
|
||||
<span class='line'>149</span> </span><span class="COMM">/*global JSON */</span><span class="WHIT">
|
||||
<span class='line'>150</span>
|
||||
<span class='line'>151</span> </span><span class="COMM">/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
|
||||
<span class='line'>152</span> call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
|
||||
<span class='line'>153</span> getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
|
||||
<span class='line'>154</span> lastIndex, length, parse, prototype, push, replace, slice, stringify,
|
||||
<span class='line'>155</span> test, toJSON, toString, valueOf
|
||||
<span class='line'>156</span> */</span><span class="WHIT">
|
||||
<span class='line'>157</span>
|
||||
<span class='line'>158</span> </span><span class="COMM">// Create a JSON object only if one does not already exist. We create the</span><span class="WHIT">
|
||||
<span class='line'>159</span> </span><span class="COMM">// methods in a closure to avoid creating global variables.</span><span class="WHIT">
|
||||
<span class='line'>160</span>
|
||||
<span class='line'>161</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.JSON</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>162</span> </span><span class="WHIT"> </span><span class="NAME">JSON</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>163</span> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>164</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>165</span>
|
||||
<span class='line'>166</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>167</span> </span><span class="WHIT"> </span><span class="COMM">// Format integers to have at least two digits.</span><span class="WHIT">
|
||||
<span class='line'>168</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'0'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>169</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>170</span>
|
||||
<span class='line'>171</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Date.prototype.toJSON</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>172</span>
|
||||
<span class='line'>173</span> </span><span class="WHIT"> </span><span class="NAME">Date.prototype.toJSON</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>174</span>
|
||||
<span class='line'>175</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.getUTCFullYear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
|
||||
<span class='line'>176</span> </span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">(</span><span class="NAME">this.getUTCMonth</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
|
||||
<span class='line'>177</span> </span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">(</span><span class="NAME">this.getUTCDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'T'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
|
||||
<span class='line'>178</span> </span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">(</span><span class="NAME">this.getUTCHours</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">':'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
|
||||
<span class='line'>179</span> </span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">(</span><span class="NAME">this.getUTCMinutes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">':'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
|
||||
<span class='line'>180</span> </span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">(</span><span class="NAME">this.getUTCSeconds</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'Z'</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>181</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>182</span>
|
||||
<span class='line'>183</span> </span><span class="WHIT"> </span><span class="NAME">String.prototype.toJSON</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">
|
||||
<span class='line'>184</span> </span><span class="WHIT"> </span><span class="NAME">Number.prototype.toJSON</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">
|
||||
<span class='line'>185</span> </span><span class="WHIT"> </span><span class="NAME">Boolean.prototype.toJSON</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>186</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.valueOf</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>187</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>188</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>189</span>
|
||||
<span class='line'>190</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">cx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>191</span> </span><span class="WHIT"> </span><span class="NAME">escapable</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>192</span> </span><span class="WHIT"> </span><span class="NAME">gap</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>193</span> </span><span class="WHIT"> </span><span class="NAME">indent</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>194</span> </span><span class="WHIT"> </span><span class="NAME">meta</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// table of character substitutions</span><span class="WHIT">
|
||||
<span class='line'>195</span> </span><span class="WHIT"> </span><span class="STRN">'\b'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'\\b'</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>196</span> </span><span class="WHIT"> </span><span class="STRN">'\t'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'\\t'</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>197</span> </span><span class="WHIT"> </span><span class="STRN">'\n'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'\\n'</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>198</span> </span><span class="WHIT"> </span><span class="STRN">'\f'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'\\f'</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>199</span> </span><span class="WHIT"> </span><span class="STRN">'\r'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'\\r'</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>200</span> </span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'\\"'</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>201</span> </span><span class="WHIT"> </span><span class="STRN">'\\'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'\\\\'</span><span class="WHIT">
|
||||
<span class='line'>202</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>203</span> </span><span class="WHIT"> </span><span class="NAME">rep</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>204</span>
|
||||
<span class='line'>205</span>
|
||||
<span class='line'>206</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">quote</span><span class="PUNC">(</span><span class="NAME">string</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>207</span>
|
||||
<span class='line'>208</span> </span><span class="COMM">// If the string contains no control characters, no quote characters, and no</span><span class="WHIT">
|
||||
<span class='line'>209</span> </span><span class="COMM">// backslash characters, then we can safely slap some quotes around it.</span><span class="WHIT">
|
||||
<span class='line'>210</span> </span><span class="COMM">// Otherwise we must also replace the offending characters with safe escape</span><span class="WHIT">
|
||||
<span class='line'>211</span> </span><span class="COMM">// sequences.</span><span class="WHIT">
|
||||
<span class='line'>212</span>
|
||||
<span class='line'>213</span> </span><span class="WHIT"> </span><span class="NAME">escapable.lastIndex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>214</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">escapable.test</span><span class="PUNC">(</span><span class="NAME">string</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT">
|
||||
<span class='line'>215</span> </span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">string.replace</span><span class="PUNC">(</span><span class="NAME">escapable</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>216</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">meta</span><span class="PUNC">[</span><span class="NAME">a</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>217</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT">
|
||||
<span class='line'>218</span> </span><span class="WHIT"> </span><span class="STRN">'\\u'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'0000'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">a.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">4</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>219</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT">
|
||||
<span class='line'>220</span> </span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">string</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>221</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>222</span>
|
||||
<span class='line'>223</span>
|
||||
<span class='line'>224</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">str</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">holder</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>225</span>
|
||||
<span class='line'>226</span> </span><span class="COMM">// Produce a string from holder[key].</span><span class="WHIT">
|
||||
<span class='line'>227</span>
|
||||
<span class='line'>228</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// The loop counter.</span><span class="WHIT">
|
||||
<span class='line'>229</span> </span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// The member key.</span><span class="WHIT">
|
||||
<span class='line'>230</span> </span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// The member value.</span><span class="WHIT">
|
||||
<span class='line'>231</span> </span><span class="WHIT"> </span><span class="NAME">length</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>232</span> </span><span class="WHIT"> </span><span class="NAME">mind</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">gap</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>233</span> </span><span class="WHIT"> </span><span class="NAME">partial</span><span class="PUNC">,</span><span class="WHIT">
|
||||
<span class='line'>234</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">holder</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>235</span>
|
||||
<span class='line'>236</span> </span><span class="COMM">// If the value has a toJSON method, call it to obtain a replacement value.</span><span class="WHIT">
|
||||
<span class='line'>237</span>
|
||||
<span class='line'>238</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
|
||||
<span class='line'>239</span> </span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value.toJSON</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>240</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value.toJSON</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>241</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>242</span>
|
||||
<span class='line'>243</span> </span><span class="COMM">// If we were called with a replacer function, then call the replacer to</span><span class="WHIT">
|
||||
<span class='line'>244</span> </span><span class="COMM">// obtain a replacement value.</span><span class="WHIT">
|
||||
<span class='line'>245</span>
|
||||
<span class='line'>246</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">rep</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>247</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">rep.call</span><span class="PUNC">(</span><span class="NAME">holder</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>248</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>249</span>
|
||||
<span class='line'>250</span> </span><span class="COMM">// What happens next depends on the value's type.</span><span class="WHIT">
|
||||
<span class='line'>251</span>
|
||||
<span class='line'>252</span> </span><span class="WHIT"> </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>253</span> </span><span class="WHIT"> </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">:</span><span class="WHIT">
|
||||
<span class='line'>254</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">quote</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>255</span>
|
||||
<span class='line'>256</span> </span><span class="WHIT"> </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">:</span><span class="WHIT">
|
||||
<span class='line'>257</span>
|
||||
<span class='line'>258</span> </span><span class="COMM">// JSON numbers must be finite. Encode non-finite numbers as null.</span><span class="WHIT">
|
||||
<span class='line'>259</span>
|
||||
<span class='line'>260</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">isFinite</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'null'</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>261</span>
|
||||
<span class='line'>262</span> </span><span class="WHIT"> </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'boolean'</span><span class="PUNC">:</span><span class="WHIT">
|
||||
<span class='line'>263</span> </span><span class="WHIT"> </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'null'</span><span class="PUNC">:</span><span class="WHIT">
|
||||
<span class='line'>264</span>
|
||||
<span class='line'>265</span> </span><span class="COMM">// If the value is a boolean or null, convert it to a string. Note:</span><span class="WHIT">
|
||||
<span class='line'>266</span> </span><span class="COMM">// typeof null does not produce 'null'. The case is included here in</span><span class="WHIT">
|
||||
<span class='line'>267</span> </span><span class="COMM">// the remote chance that this gets fixed someday.</span><span class="WHIT">
|
||||
<span class='line'>268</span>
|
||||
<span class='line'>269</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>270</span>
|
||||
<span class='line'>271</span> </span><span class="COMM">// If the type is 'object', we might be dealing with an object or an array or</span><span class="WHIT">
|
||||
<span class='line'>272</span> </span><span class="COMM">// null.</span><span class="WHIT">
|
||||
<span class='line'>273</span>
|
||||
<span class='line'>274</span> </span><span class="WHIT"> </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">:</span><span class="WHIT">
|
||||
<span class='line'>275</span>
|
||||
<span class='line'>276</span> </span><span class="COMM">// Due to a specification blunder in ECMAScript, typeof null is 'object',</span><span class="WHIT">
|
||||
<span class='line'>277</span> </span><span class="COMM">// so watch out for that case.</span><span class="WHIT">
|
||||
<span class='line'>278</span>
|
||||
<span class='line'>279</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>280</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">'null'</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>281</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>282</span>
|
||||
<span class='line'>283</span> </span><span class="COMM">// Make an array to hold the partial results of stringifying this object value.</span><span class="WHIT">
|
||||
<span class='line'>284</span>
|
||||
<span class='line'>285</span> </span><span class="WHIT"> </span><span class="NAME">gap</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">indent</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>286</span> </span><span class="WHIT"> </span><span class="NAME">partial</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>287</span>
|
||||
<span class='line'>288</span> </span><span class="COMM">// Is the value an array?</span><span class="WHIT">
|
||||
<span class='line'>289</span>
|
||||
<span class='line'>290</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Object.prototype.toString.apply</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'[object Array]'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>291</span>
|
||||
<span class='line'>292</span> </span><span class="COMM">// The value is an array. Stringify every element. Use null as a placeholder</span><span class="WHIT">
|
||||
<span class='line'>293</span> </span><span class="COMM">// for non-JSON values.</span><span class="WHIT">
|
||||
<span class='line'>294</span>
|
||||
<span class='line'>295</span> </span><span class="WHIT"> </span><span class="NAME">length</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>296</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>297</span> </span><span class="WHIT"> </span><span class="NAME">partial</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">str</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">'null'</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>298</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>299</span>
|
||||
<span class='line'>300</span> </span><span class="COMM">// Join all of the elements together, separated with commas, and wrap them in</span><span class="WHIT">
|
||||
<span class='line'>301</span> </span><span class="COMM">// brackets.</span><span class="WHIT">
|
||||
<span class='line'>302</span>
|
||||
<span class='line'>303</span> </span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">partial.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'[]'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT">
|
||||
<span class='line'>304</span> </span><span class="WHIT"> </span><span class="NAME">gap</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'[\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">gap</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
|
||||
<span class='line'>305</span> </span><span class="WHIT"> </span><span class="NAME">partial.join</span><span class="PUNC">(</span><span class="STRN">',\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">gap</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
|
||||
<span class='line'>306</span> </span><span class="WHIT"> </span><span class="NAME">mind</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">']'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT">
|
||||
<span class='line'>307</span> </span><span class="WHIT"> </span><span class="STRN">'['</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">partial.join</span><span class="PUNC">(</span><span class="STRN">','</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">']'</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>308</span> </span><span class="WHIT"> </span><span class="NAME">gap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mind</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>309</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>310</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>311</span>
|
||||
<span class='line'>312</span> </span><span class="COMM">// If the replacer is an array, use it to select the members to be stringified.</span><span class="WHIT">
|
||||
<span class='line'>313</span>
|
||||
<span class='line'>314</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">rep</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">rep</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>315</span> </span><span class="WHIT"> </span><span class="NAME">length</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">rep.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>316</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>317</span> </span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">rep</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>318</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>319</span> </span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">str</span><span class="PUNC">(</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>320</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">v</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>321</span> </span><span class="WHIT"> </span><span class="NAME">partial.push</span><span class="PUNC">(</span><span class="NAME">quote</span><span class="PUNC">(</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">gap</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">': '</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">':'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>322</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>323</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>324</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>325</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>326</span>
|
||||
<span class='line'>327</span> </span><span class="COMM">// Otherwise, iterate through all of the keys in the object.</span><span class="WHIT">
|
||||
<span class='line'>328</span>
|
||||
<span class='line'>329</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">k</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>330</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Object.hasOwnProperty.call</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>331</span> </span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">str</span><span class="PUNC">(</span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>332</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">v</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>333</span> </span><span class="WHIT"> </span><span class="NAME">partial.push</span><span class="PUNC">(</span><span class="NAME">quote</span><span class="PUNC">(</span><span class="NAME">k</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">gap</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">': '</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">':'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>334</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>335</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>336</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>337</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>338</span>
|
||||
<span class='line'>339</span> </span><span class="COMM">// Join all of the member texts together, separated with commas,</span><span class="WHIT">
|
||||
<span class='line'>340</span> </span><span class="COMM">// and wrap them in braces.</span><span class="WHIT">
|
||||
<span class='line'>341</span>
|
||||
<span class='line'>342</span> </span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">partial.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'{}'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT">
|
||||
<span class='line'>343</span> </span><span class="WHIT"> </span><span class="NAME">gap</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'{\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">gap</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">partial.join</span><span class="PUNC">(</span><span class="STRN">',\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">gap</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
|
||||
<span class='line'>344</span> </span><span class="WHIT"> </span><span class="NAME">mind</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'}'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'{'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">partial.join</span><span class="PUNC">(</span><span class="STRN">','</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'}'</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>345</span> </span><span class="WHIT"> </span><span class="NAME">gap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mind</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>346</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>347</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>348</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>349</span>
|
||||
<span class='line'>350</span> </span><span class="COMM">// If the JSON object does not yet have a stringify method, give it one.</span><span class="WHIT">
|
||||
<span class='line'>351</span>
|
||||
<span class='line'>352</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">JSON.stringify</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>353</span> </span><span class="WHIT"> </span><span class="NAME">JSON.stringify</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">replacer</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">space</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>354</span>
|
||||
<span class='line'>355</span> </span><span class="COMM">// The stringify method takes a value and an optional replacer, and an optional</span><span class="WHIT">
|
||||
<span class='line'>356</span> </span><span class="COMM">// space parameter, and returns a JSON text. The replacer can be a function</span><span class="WHIT">
|
||||
<span class='line'>357</span> </span><span class="COMM">// that can replace values, or an array of strings that will select the keys.</span><span class="WHIT">
|
||||
<span class='line'>358</span> </span><span class="COMM">// A default replacer method can be provided. Use of the space parameter can</span><span class="WHIT">
|
||||
<span class='line'>359</span> </span><span class="COMM">// produce text that is more easily readable.</span><span class="WHIT">
|
||||
<span class='line'>360</span>
|
||||
<span class='line'>361</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>362</span> </span><span class="WHIT"> </span><span class="NAME">gap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>363</span> </span><span class="WHIT"> </span><span class="NAME">indent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>364</span>
|
||||
<span class='line'>365</span> </span><span class="COMM">// If the space parameter is a number, make an indent string containing that</span><span class="WHIT">
|
||||
<span class='line'>366</span> </span><span class="COMM">// many spaces.</span><span class="WHIT">
|
||||
<span class='line'>367</span>
|
||||
<span class='line'>368</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">space</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>369</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">space</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>370</span> </span><span class="WHIT"> </span><span class="NAME">indent</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>371</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>372</span>
|
||||
<span class='line'>373</span> </span><span class="COMM">// If the space parameter is a string, it will be used as the indent string.</span><span class="WHIT">
|
||||
<span class='line'>374</span>
|
||||
<span class='line'>375</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">space</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>376</span> </span><span class="WHIT"> </span><span class="NAME">indent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">space</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>377</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>378</span>
|
||||
<span class='line'>379</span> </span><span class="COMM">// If there is a replacer, it must be a function or an array.</span><span class="WHIT">
|
||||
<span class='line'>380</span> </span><span class="COMM">// Otherwise, throw an error.</span><span class="WHIT">
|
||||
<span class='line'>381</span>
|
||||
<span class='line'>382</span> </span><span class="WHIT"> </span><span class="NAME">rep</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">replacer</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>383</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">replacer</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">replacer</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
|
||||
<span class='line'>384</span> </span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">replacer</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
|
||||
<span class='line'>385</span> </span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">replacer.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>386</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">'JSON.stringify'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>387</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>388</span>
|
||||
<span class='line'>389</span> </span><span class="COMM">// Make a fake root object containing our value under the key of ''.</span><span class="WHIT">
|
||||
<span class='line'>390</span> </span><span class="COMM">// Return the result of stringifying the value.</span><span class="WHIT">
|
||||
<span class='line'>391</span>
|
||||
<span class='line'>392</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">str</span><span class="PUNC">(</span><span class="STRN">''</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="STRN">''</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>393</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>394</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>395</span>
|
||||
<span class='line'>396</span>
|
||||
<span class='line'>397</span> </span><span class="COMM">// If the JSON object does not yet have a parse method, give it one.</span><span class="WHIT">
|
||||
<span class='line'>398</span>
|
||||
<span class='line'>399</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">JSON.parse</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>400</span> </span><span class="WHIT"> </span><span class="NAME">JSON.parse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">reviver</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>401</span>
|
||||
<span class='line'>402</span> </span><span class="COMM">// The parse method takes a text and an optional reviver function, and returns</span><span class="WHIT">
|
||||
<span class='line'>403</span> </span><span class="COMM">// a JavaScript value if the text is a valid JSON text.</span><span class="WHIT">
|
||||
<span class='line'>404</span>
|
||||
<span class='line'>405</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>406</span>
|
||||
<span class='line'>407</span> </span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">walk</span><span class="PUNC">(</span><span class="NAME">holder</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>408</span>
|
||||
<span class='line'>409</span> </span><span class="COMM">// The walk method is used to recursively walk the resulting structure so</span><span class="WHIT">
|
||||
<span class='line'>410</span> </span><span class="COMM">// that modifications can be made.</span><span class="WHIT">
|
||||
<span class='line'>411</span>
|
||||
<span class='line'>412</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">holder</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>413</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>414</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">k</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>415</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Object.hasOwnProperty.call</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>416</span> </span><span class="WHIT"> </span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">walk</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">k</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>417</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">v</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>418</span> </span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">v</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>419</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>420</span> </span><span class="WHIT"> </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>421</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>422</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>423</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>424</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>425</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">reviver.call</span><span class="PUNC">(</span><span class="NAME">holder</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>426</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>427</span>
|
||||
<span class='line'>428</span>
|
||||
<span class='line'>429</span> </span><span class="COMM">// Parsing happens in four stages. In the first stage, we replace certain</span><span class="WHIT">
|
||||
<span class='line'>430</span> </span><span class="COMM">// Unicode characters with escape sequences. JavaScript handles many characters</span><span class="WHIT">
|
||||
<span class='line'>431</span> </span><span class="COMM">// incorrectly, either silently deleting them, or treating them as line endings.</span><span class="WHIT">
|
||||
<span class='line'>432</span>
|
||||
<span class='line'>433</span> </span><span class="WHIT"> </span><span class="NAME">cx.lastIndex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>434</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">cx.test</span><span class="PUNC">(</span><span class="NAME">text</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>435</span> </span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">text.replace</span><span class="PUNC">(</span><span class="NAME">cx</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>436</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">'\\u'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
|
||||
<span class='line'>437</span> </span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'0000'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">a.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">4</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>438</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>439</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>440</span>
|
||||
<span class='line'>441</span> </span><span class="COMM">// In the second stage, we run the text against regular expressions that look</span><span class="WHIT">
|
||||
<span class='line'>442</span> </span><span class="COMM">// for non-JSON patterns. We are especially concerned with '()' and 'new'</span><span class="WHIT">
|
||||
<span class='line'>443</span> </span><span class="COMM">// because they can cause invocation, and '=' because it can cause mutation.</span><span class="WHIT">
|
||||
<span class='line'>444</span> </span><span class="COMM">// But just to be safe, we want to reject all unexpected forms.</span><span class="WHIT">
|
||||
<span class='line'>445</span>
|
||||
<span class='line'>446</span> </span><span class="COMM">// We split the second stage into 4 regexp operations in order to work around</span><span class="WHIT">
|
||||
<span class='line'>447</span> </span><span class="COMM">// crippling inefficiencies in IE's and Safari's regexp engines. First we</span><span class="WHIT">
|
||||
<span class='line'>448</span> </span><span class="COMM">// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we</span><span class="WHIT">
|
||||
<span class='line'>449</span> </span><span class="COMM">// replace all simple value tokens with ']' characters. Third, we delete all</span><span class="WHIT">
|
||||
<span class='line'>450</span> </span><span class="COMM">// open brackets that follow a colon or comma or that begin the text. Finally,</span><span class="WHIT">
|
||||
<span class='line'>451</span> </span><span class="COMM">// we look to see that the remaining characters are only whitespace or ']' or</span><span class="WHIT">
|
||||
<span class='line'>452</span> </span><span class="COMM">// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.</span><span class="WHIT">
|
||||
<span class='line'>453</span>
|
||||
<span class='line'>454</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="REGX">/^[\],:{}\s]*$/</span><span class="PUNC">.</span><span class="WHIT">
|
||||
<span class='line'>455</span> </span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">text.replace</span><span class="PUNC">(</span><span class="REGX">/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'@'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="WHIT">
|
||||
<span class='line'>456</span> </span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">']'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="WHIT">
|
||||
<span class='line'>457</span> </span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/(?:^|:|,)(?:\s*\[)+/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||
<span class='line'>458</span>
|
||||
<span class='line'>459</span> </span><span class="COMM">// In the third stage we use the eval function to compile the text into a</span><span class="WHIT">
|
||||
<span class='line'>460</span> </span><span class="COMM">// JavaScript structure. The '{' operator is subject to a syntactic ambiguity</span><span class="WHIT">
|
||||
<span class='line'>461</span> </span><span class="COMM">// in JavaScript: it can begin a block or an object literal. We wrap the text</span><span class="WHIT">
|
||||
<span class='line'>462</span> </span><span class="COMM">// in parens to eliminate the ambiguity.</span><span class="WHIT">
|
||||
<span class='line'>463</span>
|
||||
<span class='line'>464</span> </span><span class="WHIT"> </span><span class="NAME">j</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">eval</span><span class="PUNC">(</span><span class="STRN">'('</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">')'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>465</span>
|
||||
<span class='line'>466</span> </span><span class="COMM">// In the optional fourth stage, we recursively walk the new structure, passing</span><span class="WHIT">
|
||||
<span class='line'>467</span> </span><span class="COMM">// each name/value pair to a reviver function for possible transformation.</span><span class="WHIT">
|
||||
<span class='line'>468</span>
|
||||
<span class='line'>469</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">reviver</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT">
|
||||
<span class='line'>470</span> </span><span class="WHIT"> </span><span class="NAME">walk</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">''</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>471</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>472</span>
|
||||
<span class='line'>473</span> </span><span class="COMM">// If the text is not JSON parseable, then a SyntaxError is thrown.</span><span class="WHIT">
|
||||
<span class='line'>474</span>
|
||||
<span class='line'>475</span> </span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">SyntaxError</span><span class="PUNC">(</span><span class="STRN">'JSON.parse'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>476</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>477</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||
<span class='line'>478</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||
<span class='line'>479</span> </span></pre></body></html>
|
26
examples/html/example_suite.html
Normal file
26
examples/html/example_suite.html
Normal file
@ -0,0 +1,26 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Test Runner</title>
|
||||
</head>
|
||||
<script type="text/javascript" src="../../lib/jasmine-0.9.0.js"></script>
|
||||
<script type="text/javascript" src="../../lib/TrivialReporter.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../lib/jasmine.css">
|
||||
|
||||
<script type="text/javascript">
|
||||
jasmine.include('example_suite.js', true);
|
||||
</script>
|
||||
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.reporter = new jasmine.TrivialReporter();
|
||||
jasmineEnv.execute();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
32
examples/ruby/Rakefile
Normal file
32
examples/ruby/Rakefile
Normal file
@ -0,0 +1,32 @@
|
||||
namespace :test do
|
||||
desc "Run continuous integration tests"
|
||||
require "spec"
|
||||
require 'spec/rake/spectask'
|
||||
|
||||
Spec::Rake::SpecTask.new(:ci) do |t|
|
||||
t.spec_opts = ["--color", "--format", "specdoc"]
|
||||
t.spec_files = ["spec/jasmine_spec.rb"]
|
||||
end
|
||||
end
|
||||
|
||||
desc "Run specs via server"
|
||||
task :jasmine_server do
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), "../../contrib/ruby/jasmine_spec_builder"))
|
||||
|
||||
JASMINE_LIB = File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
|
||||
dir_mappings = {
|
||||
"/spec" => 'spec',
|
||||
"/lib" => JASMINE_LIB
|
||||
}
|
||||
|
||||
includes = ['lib/' + File.basename(Dir.glob("#{JASMINE_LIB}/jasmine*.js").first),
|
||||
'lib/json2.js',
|
||||
'lib/TrivialReporter.js']
|
||||
|
||||
spec_files = Dir.glob("spec/**/*[Ss]pec.js")
|
||||
|
||||
puts "your tests are here:"
|
||||
puts " http://localhost:8888/run.html"
|
||||
|
||||
Jasmine::SimpleServer.start(8888, includes + spec_files, dir_mappings)
|
||||
end
|
11
examples/ruby/spec/example/example_spec.js
Normal file
11
examples/ruby/spec/example/example_spec.js
Normal file
@ -0,0 +1,11 @@
|
||||
describe('ExampleSuite', function () {
|
||||
it('should have a passing test', function() {
|
||||
expect(true).toEqual(true);
|
||||
});
|
||||
|
||||
describe('Nested Describe', function () {
|
||||
it('should also have a passing test', function () {
|
||||
expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
30
examples/ruby/spec/jasmine_spec.rb
Normal file
30
examples/ruby/spec/jasmine_spec.rb
Normal file
@ -0,0 +1,30 @@
|
||||
require 'rubygems'
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), "../../../contrib/ruby/jasmine_spec_builder"))
|
||||
require "selenium_rc"
|
||||
|
||||
|
||||
JASMINE_LIB = File.expand_path(File.join(File.dirname(__FILE__), '../../../lib'))
|
||||
dir_mappings = {
|
||||
"/spec" => 'spec',
|
||||
"/lib" => JASMINE_LIB
|
||||
}
|
||||
|
||||
includes = ['lib/' + File.basename(Dir.glob("#{JASMINE_LIB}/jasmine*.js").first),
|
||||
'lib/json2.js',
|
||||
'lib/TrivialReporter.js']
|
||||
|
||||
spec_files = Dir.glob("spec/**/*[Ss]pec.js")
|
||||
jasmine_runner = Jasmine::Runner.new(SeleniumRC::Server.new.jar_path, includes + spec_files, dir_mappings)
|
||||
spec_builder = Jasmine::SpecBuilder.new(spec_files, jasmine_runner)
|
||||
|
||||
should_stop = false
|
||||
|
||||
Spec::Runner.configure do |config|
|
||||
config.after(:suite) do
|
||||
spec_builder.stop if should_stop
|
||||
end
|
||||
end
|
||||
|
||||
spec_builder.start
|
||||
should_stop = true
|
||||
spec_builder.declare_suites
|
@ -28,7 +28,7 @@ jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarA
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
var suites = runner.getAllSuites();
|
||||
var suites = runner.suites();
|
||||
|
||||
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
||||
this.createDom('a', { className: 'runSpec', href: '?' }, "run all"),
|
||||
@ -76,10 +76,11 @@ jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
this.createDom('a', { className: 'runSpec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
||||
spec.getFullName());
|
||||
|
||||
|
||||
var resultItems = results.getItems();
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
if (!result.passed) {
|
||||
if (result.passed && !result.passed()) {
|
||||
var resultMessageDiv = this.createDom('div', {className: 'resultMessage fail'});
|
||||
resultMessageDiv.innerHTML = result.message; // todo: lame; mend
|
||||
specDiv.appendChild(resultMessageDiv);
|
||||
|
@ -1,50 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Test Runner</title>
|
||||
</head>
|
||||
<script type="text/javascript" src="json2.js"></script>
|
||||
<script type="text/javascript" src="jasmine.js"></script>
|
||||
<script type="text/javascript" src="TrivialReporter.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
jasmine.include('example_suite.js', true);
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
.spec {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.passed {
|
||||
background-color: lightgreen;
|
||||
}
|
||||
|
||||
.failed {
|
||||
background-color: pink;
|
||||
}
|
||||
|
||||
.resultMessage {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.stackTrace {
|
||||
white-space: pre;
|
||||
font-size: .8em;
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.reporter = new jasmine.TrivialReporter();
|
||||
jasmineEnv.execute();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -84,4 +84,9 @@ p {
|
||||
.runSpec {
|
||||
margin-left: 5px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
#jasmine_content {
|
||||
position:fixed;
|
||||
left: 100%;
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Tests</title>
|
||||
|
||||
<script type="text/javascript" src="lib/json2.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="../src/base.js"></script>
|
||||
<script type="text/javascript" src="../src/util.js"></script>
|
||||
<script type="text/javascript" src="../src/Env.js"></script>
|
||||
<script type="text/javascript" src="../src/ActionCollection.js"></script>
|
||||
<script type="text/javascript" src="../src/Matchers.js"></script>
|
||||
<script type="text/javascript" src="../src/NestedResults.js"></script>
|
||||
<script type="text/javascript" src="../src/PrettyPrinter.js"></script>
|
||||
<script type="text/javascript" src="../src/QueuedFunction.js"></script>
|
||||
<script type="text/javascript" src="../src/Reporters.js"></script>
|
||||
<script type="text/javascript" src="../src/Runner.js"></script>
|
||||
<script type="text/javascript" src="../src/Spec.js"></script>
|
||||
<script type="text/javascript" src="../src/Suite.js"></script>
|
||||
<script type="text/javascript" src="../src/mock-timeout.js"></script>
|
||||
|
||||
<script type="text/javascript" src="bootstrap.js"></script>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="../lib/jasmine.css"/>
|
||||
</head>
|
||||
<body onLoad="runTests();">
|
||||
<h1>
|
||||
Running all Jasmine Test Suites
|
||||
</h1>
|
||||
<div id="icon_wrapper">
|
||||
<span id="icons"></span>
|
||||
<img id="spinner" src="../images/spinner.gif" alt="" />
|
||||
</div>
|
||||
<div id="report">
|
||||
<div id="results_summary" style="display:none;">
|
||||
<h2>Summary</h2>
|
||||
</div>
|
||||
<div id="fails" style="display:none;">
|
||||
<h2 id="fails_header">Failure Messages</h2>
|
||||
<div id="fail_messages"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:none" id="json_reporter_results"></div>
|
||||
<div style="display:none" id="json_reporter_results_incremental"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
146
spec/bootstrap.js
vendored
146
spec/bootstrap.js
vendored
@ -1,146 +0,0 @@
|
||||
var createElement = function(tag, attrs) {
|
||||
var element = document.createElement(tag);
|
||||
for (var attr in attrs) {
|
||||
element[attr] = attrs[attr];
|
||||
}
|
||||
return element;
|
||||
};
|
||||
|
||||
// Bootstrap Test Reporter function
|
||||
var Reporter = function () {
|
||||
this.total = 0;
|
||||
this.passes = 0;
|
||||
this.fails = 0;
|
||||
this.start = new Date();
|
||||
};
|
||||
|
||||
Reporter.prototype.toJSON = function(object) {
|
||||
return JSON.stringify(object);
|
||||
};
|
||||
|
||||
Reporter.prototype.test = function (result, message) {
|
||||
this.total++;
|
||||
|
||||
if (result) {
|
||||
this.passes++;
|
||||
iconElement = document.getElementById('icons');
|
||||
iconElement.appendChild(createElement('img', {src: '../images/go-16.png'}));
|
||||
}
|
||||
else {
|
||||
this.fails++;
|
||||
var fails_report = document.getElementById('fails');
|
||||
fails_report.style.display = "";
|
||||
|
||||
var iconElement = document.getElementById('icons');
|
||||
iconElement.appendChild(createElement('img', {src: '../images/fail-16.png'}));
|
||||
|
||||
var failMessages = document.getElementById('fail_messages');
|
||||
var newFail = createElement('p', {'class': 'fail'});
|
||||
newFail.innerHTML = message;
|
||||
failMessages.appendChild(newFail);
|
||||
}
|
||||
};
|
||||
|
||||
Reporter.prototype.summary = function () {
|
||||
var el = createElement('p', {'class': ((this.fails > 0) ? 'failInSummary' : '') });
|
||||
el.innerHTML = this.total + ' expectations, ' + this.passes + ' passing, ' + this.fails + ' failed in ' + (new Date().getTime() - this.start.getTime()) + "ms.";
|
||||
|
||||
var summaryElement = document.getElementById('results_summary');
|
||||
summaryElement.appendChild(el);
|
||||
summaryElement.style.display = "";
|
||||
};
|
||||
|
||||
|
||||
var reporter = new Reporter();
|
||||
|
||||
function runSuite(filename) {
|
||||
console.log(filename);
|
||||
var suite = jasmine.include(filename);
|
||||
suite.execute();
|
||||
emitSuiteResults(filename, suite);
|
||||
}
|
||||
|
||||
function emitSpecResults(testName, spec) {
|
||||
var results = spec.results.getItems();
|
||||
reporter.test(results.length > 0, testName + ": should have results, got " + results.length);
|
||||
|
||||
for (var i = 0; i < results.length; i++) {
|
||||
reporter.test(results[i].passed === true, testName + ':' + spec.getFullName() + ": expectation number " + i + " failed: " + results[i].message);
|
||||
}
|
||||
}
|
||||
|
||||
function emitSuiteResults(testName, suite) {
|
||||
for (var j = 0; j < suite.specs.length; j++) {
|
||||
var specOrSuite = suite.specs[j];
|
||||
|
||||
if (specOrSuite instanceof jasmine.Suite) {
|
||||
emitSuiteResults(testName, specOrSuite);
|
||||
} else {
|
||||
emitSpecResults(testName, specOrSuite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var testExplodes = function () {
|
||||
var suite = describe('exploding', function () {
|
||||
it('should throw an exception when this.explodes is called inside a spec', function() {
|
||||
var exceptionMessage = false;
|
||||
|
||||
try {
|
||||
this.explodes();
|
||||
}
|
||||
catch (e) {
|
||||
exceptionMessage = e;
|
||||
}
|
||||
expect(exceptionMessage).toEqual('explodes function should not have been called');
|
||||
});
|
||||
|
||||
});
|
||||
suite.execute();
|
||||
|
||||
emitSuiteResults('testExplodes', suite);
|
||||
};
|
||||
|
||||
function newJasmineEnv() {
|
||||
return new jasmine.Env();
|
||||
}
|
||||
|
||||
var testRunner = function() {
|
||||
};
|
||||
|
||||
var testRunnerFinishCallback = function () {
|
||||
var env = newJasmineEnv();
|
||||
var foo = 0;
|
||||
|
||||
env.currentRunner.finish();
|
||||
|
||||
reporter.test((env.currentRunner.finished === true),
|
||||
"Runner finished flag was not set.");
|
||||
|
||||
env.currentRunner.finishCallback = function () {
|
||||
foo++;
|
||||
};
|
||||
|
||||
env.currentRunner.finish();
|
||||
|
||||
reporter.test((env.currentRunner.finished === true),
|
||||
"Runner finished flag was not set.");
|
||||
reporter.test((foo === 1),
|
||||
"Runner finish callback was not called");
|
||||
};
|
||||
|
||||
var runTests = function () {
|
||||
document.getElementById('spinner').style.display = "";
|
||||
|
||||
runSuite('suites/PrettyPrintTest.js');
|
||||
runSuite('suites/MatchersTest.js');
|
||||
runSuite('suites/SpecRunningTest.js');
|
||||
runSuite('suites/NestedResultsTest.js');
|
||||
runSuite('suites/ReporterTest.js');
|
||||
runSuite('suites/RunnerTest.js');
|
||||
runSuite('suites/SpyTest.js');
|
||||
runSuite('suites/ExceptionsTest.js');
|
||||
|
||||
reporter.summary();
|
||||
document.getElementById('spinner').style.display = "none";
|
||||
};
|
32
spec/jasmine_spec.rb
Normal file
32
spec/jasmine_spec.rb
Normal file
@ -0,0 +1,32 @@
|
||||
require 'rubygems'
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), "../contrib/ruby/jasmine_spec_builder"))
|
||||
require "selenium_rc"
|
||||
|
||||
dir_mappings = {
|
||||
"/spec" => 'spec',
|
||||
"/lib" => 'lib',
|
||||
"/src" => 'src'
|
||||
}
|
||||
|
||||
def jasmine_sources
|
||||
sources = ["src/base.js", "src/util.js", "src/Env.js", "src/Reporter.js", "src/Block.js"]
|
||||
|
||||
sources += Dir.glob('src/*.js').reject{|f| f == 'src/base.js' || sources.include?(f)}.sort
|
||||
end
|
||||
|
||||
includes = jasmine_sources + ['lib/json2.js', 'lib/TrivialReporter.js']
|
||||
spec_files = Dir.glob("spec/**/*[Ss]pec.js")
|
||||
jasmine_runner = Jasmine::Runner.new(SeleniumRC::Server.new.jar_path, includes + spec_files, dir_mappings)
|
||||
spec_builder = Jasmine::SpecBuilder.new(spec_files, jasmine_runner)
|
||||
|
||||
should_stop = false
|
||||
|
||||
Spec::Runner.configure do |config|
|
||||
config.after(:suite) do
|
||||
spec_builder.stop if should_stop
|
||||
end
|
||||
end
|
||||
|
||||
spec_builder.start
|
||||
should_stop = true
|
||||
spec_builder.declare_suites
|
@ -3,45 +3,45 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Test Runner</title>
|
||||
|
||||
<script type="text/javascript" src="../src/base.js"></script>
|
||||
<script type="text/javascript" src="../src/util.js"></script>
|
||||
<script type="text/javascript" src="../src/Env.js"></script>
|
||||
<script type="text/javascript" src="../src/Reporter.js"></script>
|
||||
<script type="text/javascript" src="../src/Matchers.js"></script>
|
||||
<script type="text/javascript" src="../src/MultiReporter.js"></script>
|
||||
<script type="text/javascript" src="../src/NestedResults.js"></script>
|
||||
<script type="text/javascript" src="../src/PrettyPrinter.js"></script>
|
||||
<script type="text/javascript" src="../src/Block.js"></script>
|
||||
<script type="text/javascript" src="../src/WaitsBlock.js"></script>
|
||||
<script type="text/javascript" src="../src/WaitsForBlock.js"></script>
|
||||
<script type="text/javascript" src="../src/Reporters.js"></script>
|
||||
<script type="text/javascript" src="../src/Runner.js"></script>
|
||||
<script type="text/javascript" src="../src/Spec.js"></script>
|
||||
<script type="text/javascript" src="../src/Queue.js"></script>
|
||||
<script type="text/javascript" src="../src/Suite.js"></script>
|
||||
<script type="text/javascript" src="../src/mock-timeout.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../lib/TrivialReporter.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
jasmine.include('suites/EnvSpec.js', true);
|
||||
jasmine.include('suites/ExceptionsSpec.js', true);
|
||||
jasmine.include('suites/MatchersSpec.js', true);
|
||||
jasmine.include('suites/MultiReporterSpec.js', true);
|
||||
jasmine.include('suites/NestedResultsSpec.js', true);
|
||||
jasmine.include('suites/PrettyPrintSpec.js', true);
|
||||
jasmine.include('suites/ReporterSpec.js', true);
|
||||
jasmine.include('suites/RunnerSpec.js', true);
|
||||
jasmine.include('suites/SpecRunningSpec.js', true);
|
||||
jasmine.include('suites/SpySpec.js', true);
|
||||
jasmine.include('suites/SuiteSpec.js', true);
|
||||
jasmine.include('suites/TrivialReporterSpec.js', true);
|
||||
</script>
|
||||
|
||||
<link href="../lib/jasmine.css" rel="stylesheet"/>
|
||||
</head>
|
||||
<script type="text/javascript" src="lib/json2.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../src/base.js"></script>
|
||||
<script type="text/javascript" src="../src/util.js"></script>
|
||||
<script type="text/javascript" src="../src/Env.js"></script>
|
||||
<script type="text/javascript" src="../src/ActionCollection.js"></script>
|
||||
<script type="text/javascript" src="../src/Reporter.js"></script>
|
||||
<script type="text/javascript" src="../src/Matchers.js"></script>
|
||||
<script type="text/javascript" src="../src/MultiReporter.js"></script>
|
||||
<script type="text/javascript" src="../src/NestedResults.js"></script>
|
||||
<script type="text/javascript" src="../src/PrettyPrinter.js"></script>
|
||||
<script type="text/javascript" src="../src/QueuedFunction.js"></script>
|
||||
<script type="text/javascript" src="../src/Reporters.js"></script>
|
||||
<script type="text/javascript" src="../src/Runner.js"></script>
|
||||
<script type="text/javascript" src="../src/Spec.js"></script>
|
||||
<script type="text/javascript" src="../src/Suite.js"></script>
|
||||
<script type="text/javascript" src="../src/mock-timeout.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../lib/TrivialReporter.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
jasmine.include('suites/ExceptionsTest.js', true);
|
||||
jasmine.include('suites/EnvTest.js', true);
|
||||
jasmine.include('suites/JsonReporterTest.js', true);
|
||||
jasmine.include('suites/MatchersTest.js', true);
|
||||
jasmine.include('suites/MultiReporterTest.js', true);
|
||||
jasmine.include('suites/NestedResultsTest.js', true);
|
||||
jasmine.include('suites/PrettyPrintTest.js', true);
|
||||
jasmine.include('suites/ReporterTest.js', true);
|
||||
jasmine.include('suites/RunnerTest.js', true);
|
||||
jasmine.include('suites/SpecRunningTest.js', true);
|
||||
jasmine.include('suites/SpyTest.js', true);
|
||||
jasmine.include('suites/TrivialReporterTest.js', true);
|
||||
</script>
|
||||
|
||||
|
||||
<link href="../lib/jasmine.css" rel="stylesheet"/>
|
||||
|
||||
<body>
|
||||
|
||||
@ -49,8 +49,14 @@
|
||||
|
||||
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.addReporter(new jasmine.TrivialReporter());
|
||||
jasmineEnv.execute();
|
||||
var trivialReporter = new jasmine.TrivialReporter();
|
||||
jasmineEnv.addReporter(trivialReporter);
|
||||
jasmineEnv.specFilter = function(spec) {
|
||||
return trivialReporter.specFilter(spec);
|
||||
};
|
||||
window.onload = function() {
|
||||
jasmineEnv.execute();
|
||||
};
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
58
spec/suites/EnvSpec.js
Normal file
58
spec/suites/EnvSpec.js
Normal file
@ -0,0 +1,58 @@
|
||||
describe("jasmine.Env", function() {
|
||||
describe("reporting", function() {
|
||||
var env;
|
||||
var fakeReporter;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
fakeReporter = jasmine.createSpyObj("fakeReporter", ["log"]);
|
||||
});
|
||||
|
||||
describe('version', function () {
|
||||
var oldVersion;
|
||||
|
||||
beforeEach(function () {
|
||||
oldVersion = jasmine.version_;
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
jasmine.version_ = oldVersion;
|
||||
});
|
||||
|
||||
it('should raise an error if version is not set', function () {
|
||||
jasmine.version_ = null;
|
||||
var exception;
|
||||
try {
|
||||
env.version();
|
||||
}
|
||||
catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
expect(exception.message).toEqual('Version not set');
|
||||
|
||||
});
|
||||
|
||||
it("version should return the current version as an int", function() {
|
||||
jasmine.version_ = {
|
||||
"major": 1,
|
||||
"minor": 9,
|
||||
"build": 7,
|
||||
"revision": 8
|
||||
};
|
||||
expect(env.version()).toEqual({
|
||||
"major": 1,
|
||||
"minor": 9,
|
||||
"build": 7,
|
||||
"revision": 8
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
it("should allow reporters to be registered", function() {
|
||||
env.addReporter(fakeReporter);
|
||||
env.reporter.log("message");
|
||||
expect(fakeReporter.log).wasCalledWith("message");
|
||||
});
|
||||
});
|
||||
});
|
@ -1,17 +0,0 @@
|
||||
describe("jasmine.Env", function() {
|
||||
describe("reporting", function() {
|
||||
var env;
|
||||
var fakeReporter;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
fakeReporter = jasmine.createSpyObj("fakeReporter", ["log"]);
|
||||
});
|
||||
|
||||
it("should allow reporters to be registered", function() {
|
||||
env.addReporter(fakeReporter);
|
||||
env.reporter.log("message");
|
||||
expect(fakeReporter.log).wasCalledWith("message");
|
||||
});
|
||||
});
|
||||
});
|
@ -74,25 +74,33 @@ describe('Exceptions:', function() {
|
||||
|
||||
var runner = env.currentRunner;
|
||||
suite.execute();
|
||||
fakeTimer.tick(300); //TODO: setting this to a large number causes failures, but shouldn't
|
||||
fakeTimer.tick(2500);
|
||||
|
||||
var resultsForSpec0 = suite.specs[0].getResults();
|
||||
var resultsForSpec1 = suite.specs[1].getResults();
|
||||
var resultsForSpec2 = suite.specs[2].getResults();
|
||||
var resultsForSpec3 = suite.specs[3].getResults();
|
||||
|
||||
expect(suite.getResults().totalCount).toEqual(6);
|
||||
expect(resultsForSpec0.getItems()[0].passed).toEqual(false);
|
||||
expect(resultsForSpec0.getItems()[0].message).toMatch(/fake error 1/);
|
||||
var suiteResults = suite.getResults();
|
||||
var specResults = suiteResults.getItems();
|
||||
|
||||
expect(resultsForSpec1.getItems()[0].passed).toEqual(false),
|
||||
expect(resultsForSpec1.getItems()[0].message).toMatch(/fake error 2/),
|
||||
expect(resultsForSpec1.getItems()[1].passed).toEqual(true);
|
||||
expect(suiteResults.passed()).toEqual(false);
|
||||
|
||||
expect(resultsForSpec2.getItems()[0].passed).toEqual(true);
|
||||
expect(specResults.length).toEqual(5);
|
||||
expect(specResults[0].passed()).toMatch(false);
|
||||
var blockResults = specResults[0].getItems();
|
||||
expect(blockResults[0].passed()).toEqual(false);
|
||||
expect(blockResults[0].message).toMatch(/fake error 1/);
|
||||
|
||||
expect(specResults[1].passed()).toEqual(false);
|
||||
var blockResults = specResults[1].getItems();
|
||||
expect(blockResults[0].passed()).toEqual(false);
|
||||
expect(blockResults[0].message).toMatch(/fake error 2/),
|
||||
expect(blockResults[1].passed()).toEqual(true);
|
||||
|
||||
expect(specResults[2].passed()).toEqual(true);
|
||||
|
||||
expect(specResults[3].passed()).toEqual(false);
|
||||
blockResults = specResults[3].getItems();
|
||||
expect(blockResults[0].message).toMatch(/fake error 3/);
|
||||
|
||||
expect(specResults[4].passed()).toEqual(true);
|
||||
|
||||
expect(resultsForSpec3.getItems()[0].passed).toEqual(false);
|
||||
expect(resultsForSpec3.getItems()[0].message).toMatch(/fake error 3/);
|
||||
});
|
||||
|
||||
});
|
@ -222,7 +222,7 @@ describe("jasmine.Matchers", function() {
|
||||
|
||||
expected = match(TestClass.someFunction);
|
||||
expect(expected.wasCalledWith('c', 'b', 'a')).toEqual(false);
|
||||
expect(expected.getResults().getItems()[0].passed).toEqual(false);
|
||||
expect(expected.getResults().getItems()[0].passed()).toEqual(false);
|
||||
|
||||
TestClass.someFunction.reset();
|
||||
TestClass.someFunction('a', 'b', 'c');
|
||||
@ -245,9 +245,9 @@ describe("jasmine.Matchers", function() {
|
||||
|
||||
expect(results.getItems().length).toEqual(2);
|
||||
|
||||
expect(results.getItems()[0].passed).toEqual(true);
|
||||
expect(results.getItems()[0].passed()).toEqual(true);
|
||||
|
||||
expect(results.getItems()[1].passed).toEqual(false);
|
||||
expect(results.getItems()[1].passed()).toEqual(false);
|
||||
|
||||
results = new jasmine.NestedResults();
|
||||
expected = new jasmine.Matchers(env, false, results);
|
||||
@ -297,17 +297,17 @@ describe("jasmine.Matchers", function() {
|
||||
expected = new jasmine.Matchers(env, [1, 2, 3], results);
|
||||
results.getItems().length = 0;
|
||||
expected.toEqual([1, 2, 3]);
|
||||
expect(results.getItems()[0].passed).toEqual(true);
|
||||
expect(results.getItems()[0].passed()).toEqual(true);
|
||||
|
||||
expected = new jasmine.Matchers(env, [1, 2, 3], results);
|
||||
results.getItems().length = 0;
|
||||
expected.toEqual([{}, {}, {}]);
|
||||
expect(results.getItems()[0].passed).toEqual(false);
|
||||
expect(results.getItems()[0].passed()).toEqual(false);
|
||||
|
||||
expected = new jasmine.Matchers(env, [{}, {}, {}], results);
|
||||
results.getItems().length = 0;
|
||||
expected.toEqual([1, 2, 3]);
|
||||
expect(results.getItems()[0].passed).toEqual(false);
|
||||
expect(results.getItems()[0].passed()).toEqual(false);
|
||||
});
|
||||
|
||||
});
|
@ -3,14 +3,14 @@ describe('jasmine.NestedResults', function() {
|
||||
// Leaf case
|
||||
var results = new jasmine.NestedResults();
|
||||
|
||||
results.addResult({passed: true, message: 'Passed.'});
|
||||
results.addResult(new jasmine.ExpectationResult(true,'Passed.'));
|
||||
|
||||
expect(results.getItems().length).toEqual(1);
|
||||
expect(results.totalCount).toEqual(1);
|
||||
expect(results.passedCount).toEqual(1);
|
||||
expect(results.failedCount).toEqual(0);
|
||||
|
||||
results.addResult({passed: false, message: 'FAIL.'});
|
||||
results.addResult(new jasmine.ExpectationResult(false, 'FAIL.'));
|
||||
|
||||
expect(results.getItems().length).toEqual(2);
|
||||
expect(results.totalCount).toEqual(2);
|
||||
@ -21,12 +21,12 @@ describe('jasmine.NestedResults', function() {
|
||||
it('should roll up counts for nested results', function() {
|
||||
// Branch case
|
||||
var leafResultsOne = new jasmine.NestedResults();
|
||||
leafResultsOne.addResult({passed: true, message: ''});
|
||||
leafResultsOne.addResult({passed: false, message: ''});
|
||||
leafResultsOne.addResult(new jasmine.ExpectationResult( true, ''));
|
||||
leafResultsOne.addResult(new jasmine.ExpectationResult( false, ''));
|
||||
|
||||
var leafResultsTwo = new jasmine.NestedResults();
|
||||
leafResultsTwo.addResult({passed: true, message: ''});
|
||||
leafResultsTwo.addResult({passed: false, message: ''});
|
||||
leafResultsTwo.addResult(new jasmine.ExpectationResult( true, ''));
|
||||
leafResultsTwo.addResult(new jasmine.ExpectationResult( false, ''));
|
||||
|
||||
var branchResults = new jasmine.NestedResults();
|
||||
branchResults.addResult(leafResultsOne);
|
@ -1,11 +1,19 @@
|
||||
describe('jasmine.Reporter', function() {
|
||||
var env;
|
||||
|
||||
var fakeTimer;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
|
||||
fakeTimer = new jasmine.FakeTimer();
|
||||
env.setTimeout = fakeTimer.setTimeout;
|
||||
env.clearTimeout = fakeTimer.clearTimeout;
|
||||
env.setInterval = fakeTimer.setInterval;
|
||||
env.clearInterval = fakeTimer.clearInterval;
|
||||
});
|
||||
|
||||
it('should ', function() {
|
||||
it('should get called from the test runner', function() {
|
||||
env.describe('Suite for JSON Reporter with Callbacks', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
@ -49,6 +57,7 @@ describe('jasmine.Reporter', function() {
|
||||
|
||||
var runner = env.currentRunner;
|
||||
runner.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
expect(foo).toEqual(3); // 'foo was expected to be 3, was ' + foo);
|
||||
expect(bar).toEqual(2); // 'bar was expected to be 2, was ' + bar);
|
164
spec/suites/RunnerSpec.js
Normal file
164
spec/suites/RunnerSpec.js
Normal file
@ -0,0 +1,164 @@
|
||||
describe('RunnerTest', function() {
|
||||
var fakeTimer;
|
||||
var env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
|
||||
fakeTimer = new jasmine.FakeTimer();
|
||||
env.setTimeout = fakeTimer.setTimeout;
|
||||
env.clearTimeout = fakeTimer.clearTimeout;
|
||||
env.setInterval = fakeTimer.setInterval;
|
||||
env.clearInterval = fakeTimer.clearInterval;
|
||||
});
|
||||
|
||||
it('should run child suites and specs and generate results when execute is called', function() {
|
||||
env.describe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
var runnerResults = env.currentRunner.getResults();
|
||||
expect(runnerResults.totalCount).toEqual(2);
|
||||
expect(runnerResults.passedCount).toEqual(1);
|
||||
expect(runnerResults.failedCount).toEqual(1);
|
||||
});
|
||||
|
||||
|
||||
it('should ignore suites that have been x\'d', function() {
|
||||
env.xdescribe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
var runnerResults = env.currentRunner.getResults();
|
||||
expect(runnerResults.totalCount).toEqual(1);
|
||||
expect(runnerResults.passedCount).toEqual(0);
|
||||
expect(runnerResults.failedCount).toEqual(1);
|
||||
});
|
||||
|
||||
it('should roll up results from all specs', function() {
|
||||
env.describe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
var results = env.currentRunner.getResults();
|
||||
expect(results.totalCount).toEqual(2);
|
||||
expect(results.passedCount).toEqual(1);
|
||||
expect(results.failedCount).toEqual(1);
|
||||
});
|
||||
|
||||
describe('reporting', function () {
|
||||
var fakeReporter;
|
||||
beforeEach(function () {
|
||||
fakeReporter = jasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting", "reportRunnerResults"]);
|
||||
env.addReporter(fakeReporter);
|
||||
});
|
||||
|
||||
it('should report runner results when the runner has completed running', function() {
|
||||
env.describe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be another test', function() {
|
||||
this.waits(200);
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner.execute();
|
||||
expect(fakeReporter.reportRunnerResults).wasNotCalled();
|
||||
fakeTimer.tick(200);
|
||||
//This blows up the JSApiReporter.
|
||||
//expect(fakeReporter.reportRunnerResults).wasCalledWith(env.currentRunner);
|
||||
expect(fakeReporter.reportRunnerResults).wasCalled();
|
||||
expect(fakeReporter.reportRunnerResults.mostRecentCall.args[0].getResults()).toEqual(env.currentRunner.getResults());
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
it("should report when the tests start running", function() {
|
||||
var fakeReporter = jasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting"]);
|
||||
env.addReporter(fakeReporter);
|
||||
|
||||
|
||||
var runner = new jasmine.Runner(env);
|
||||
runner.arbitraryVariable = 'foo';
|
||||
spyOn(runner.queue, 'start');
|
||||
expect(fakeReporter.reportRunnerStarting).wasNotCalled();
|
||||
runner.execute();
|
||||
expect(fakeReporter.reportRunnerStarting).wasCalled();
|
||||
var reportedRunner = fakeReporter.reportRunnerStarting.mostRecentCall.args[0];
|
||||
expect(reportedRunner.arbitraryVariable).toEqual('foo');
|
||||
expect(runner.queue.start).wasCalled();
|
||||
|
||||
});
|
||||
|
||||
it("should return a flat array of all suites, including nested suites", function() {
|
||||
var suite1, suite2;
|
||||
suite1 = env.describe("spec 1", function() {
|
||||
suite2 = env.describe("nested spec", function() {});
|
||||
});
|
||||
|
||||
document.runner = env.currentRunner;
|
||||
|
||||
var suites = env.currentRunner.suites();
|
||||
var suiteDescriptions = [];
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
suiteDescriptions.push(suites[i].getFullName());
|
||||
}
|
||||
expect(suiteDescriptions).toEqual([suite1.getFullName(), suite2.getFullName()]);
|
||||
});
|
||||
|
||||
});
|
@ -1,139 +0,0 @@
|
||||
describe('RunnerTest', function() {
|
||||
var env;
|
||||
beforeEach(function () {
|
||||
env = new jasmine.Env();
|
||||
});
|
||||
|
||||
it('should be able to add a suite', function() {
|
||||
env.describe('one suite description', function () {
|
||||
env.it('should be a test');
|
||||
});
|
||||
expect(env.currentRunner.suites.length).toEqual(1); // "Runner expected one suite, got " + env.currentRunner.suites.length);
|
||||
});
|
||||
|
||||
it('should be able to push multiple suites', function() {
|
||||
env.describe('one suite description', function () {
|
||||
env.it('should be a test');
|
||||
});
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be a test');
|
||||
});
|
||||
expect(env.currentRunner.suites.length).toEqual(2); //"Runner expected two suites, but got " + env.currentRunner.suites.length);
|
||||
});
|
||||
|
||||
it('should run child suites and specs and generate results when execute is called', function() {
|
||||
env.describe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner.execute();
|
||||
|
||||
expect(env.currentRunner.suites.length).toEqual(2); // "Runner expected two suites, got " + env.currentRunner.suites.length);
|
||||
expect(env.currentRunner.suites[0].specs[0].results.getItems()[0].passed).toEqual(true); //"Runner should have run specs in first suite");
|
||||
expect(env.currentRunner.suites[1].specs[0].results.getItems()[0].passed).toEqual(false); //"Runner should have run specs in second suite");
|
||||
});
|
||||
|
||||
it('should ignore suites that have been x\'d', function() {
|
||||
env.xdescribe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner.execute();
|
||||
|
||||
expect(env.currentRunner.suites.length).toEqual(1); // "Runner expected 1 suite, got " + env.currentRunner.suites.length);
|
||||
expect(env.currentRunner.suites[0].specs[0].results.getItems()[0].passed).toEqual(false); // "Runner should have run specs in first suite");
|
||||
expect(env.currentRunner.suites[1]).toEqual(undefined); // "Second suite should be undefined, but was " + reporter.toJSON(env.currentRunner.suites[1]));
|
||||
});
|
||||
|
||||
it('should roll up results from all specs', function() {
|
||||
var env = new jasmine.Env();
|
||||
env.describe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('another suite description', function () {
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.currentRunner.execute();
|
||||
|
||||
var results = env.currentRunner.getResults();
|
||||
expect(results.totalCount).toEqual(2);
|
||||
expect(results.passedCount).toEqual(1);
|
||||
expect(results.failedCount).toEqual(1);
|
||||
});
|
||||
|
||||
it('should set the finished flag when #finished is called', function(){
|
||||
env.currentRunner.finish();
|
||||
|
||||
expect(env.currentRunner.finished).toEqual(true);
|
||||
});
|
||||
|
||||
it('should call the finish callback when the runner is finished', function() {
|
||||
var foo = 0;
|
||||
|
||||
env.currentRunner.finishCallback = function() {
|
||||
foo++;
|
||||
};
|
||||
|
||||
env.currentRunner.finish();
|
||||
|
||||
expect(env.currentRunner.finished).toEqual(true);
|
||||
expect(foo).toEqual(1);
|
||||
});
|
||||
|
||||
it("should report when the tests start running", function() {
|
||||
var fakeReporter = jasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting"]);
|
||||
env.addReporter(fakeReporter);
|
||||
|
||||
var runner = new jasmine.Runner(env);
|
||||
runner.execute();
|
||||
expect(fakeReporter.reportRunnerStarting).wasCalledWith(env.currentRunner);
|
||||
});
|
||||
|
||||
it("should return a flat array of all suites, including nested suites", function() {
|
||||
var suite1, suite2;
|
||||
suite1 = env.describe("spec 1", function() {
|
||||
suite2 = env.describe("nested spec", function() {});
|
||||
});
|
||||
|
||||
console.log("runner:", env.currentRunner);
|
||||
document.runner = env.currentRunner;
|
||||
|
||||
var suites = env.currentRunner.getAllSuites();
|
||||
expect(suites).toEqual([suite1, suite2]);
|
||||
});
|
||||
|
||||
});
|
@ -38,6 +38,7 @@ describe("jasmine spec running", function () {
|
||||
|
||||
|
||||
it("should build up some objects with results we can inspect", function() {
|
||||
|
||||
var specWithNoBody, specWithExpectation, specWithFailingExpectations, specWithMultipleExpectations;
|
||||
|
||||
var suite = env.describe('default current suite', function() {
|
||||
@ -63,21 +64,22 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
expect(specWithNoBody.description).toEqual('new spec');
|
||||
|
||||
expect(specWithExpectation.results.getItems().length).toEqual(1); // "Results aren't there after a spec was executed"
|
||||
expect(specWithExpectation.results.getItems()[0].passed).toEqual(true); // "Results has a result, but it's true"
|
||||
expect(specWithExpectation.results.getItems()[0].passed()).toEqual(true); // "Results has a result, but it's true"
|
||||
expect(specWithExpectation.results.description).toEqual('spec with an expectation'); // "Spec's results did not get the spec's description"
|
||||
|
||||
expect(specWithFailingExpectations.results.getItems()[0].passed).toEqual(false); // "Expectation that failed, passed"
|
||||
expect(specWithFailingExpectations.results.getItems()[0].passed()).toEqual(false); // "Expectation that failed, passed"
|
||||
|
||||
expect(specWithMultipleExpectations.results.getItems().length).toEqual(2); // "Spec doesn't support multiple expectations"
|
||||
});
|
||||
|
||||
it("should work without a runs block", function() {
|
||||
var another_spec;
|
||||
var currentSuite = env.describe('default current suite', function() {
|
||||
env.describe('default current suite', function() {
|
||||
another_spec = env.it('spec with an expectation', function () {
|
||||
var foo = 'bar';
|
||||
this.expect(foo).toEqual('bar');
|
||||
@ -89,37 +91,45 @@ describe("jasmine spec running", function () {
|
||||
another_spec.done = true;
|
||||
|
||||
expect(another_spec.results.getItems().length).toEqual(2);
|
||||
expect(another_spec.results.getItems()[0].passed).toEqual(true); // "In a spec without a run block, expected first expectation result to be true but was false"
|
||||
expect(another_spec.results.getItems()[1].passed).toEqual(false); // "In a spec without a run block, expected second expectation result to be false but was true";
|
||||
expect(another_spec.results.getItems()[0].passed()).toEqual(true); // "In a spec without a run block, expected first expectation result to be true but was false"
|
||||
expect(another_spec.results.getItems()[1].passed()).toEqual(false); // "In a spec without a run block, expected second expectation result to be false but was true";
|
||||
expect(another_spec.results.description).toEqual('spec with an expectation'); // "In a spec without a run block, results did not include the spec's description";
|
||||
});
|
||||
|
||||
it('should queue waits and runs that it encounters while executing specs', function() {
|
||||
var specWithRunsAndWaits;
|
||||
var foo = 0;
|
||||
env.describe('test async spec', function() {
|
||||
specWithRunsAndWaits = env.it('spec w/ queued statments', function () {
|
||||
this.runs(function () {
|
||||
foo++;
|
||||
});
|
||||
this.waits(500);
|
||||
this.runs(function () {
|
||||
foo++;
|
||||
});
|
||||
this.waits(500);
|
||||
this.runs(function () {
|
||||
foo++;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(foo).toEqual(0);
|
||||
specWithRunsAndWaits.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
expect(foo).toEqual(1);
|
||||
fakeTimer.tick(500);
|
||||
expect(foo).toEqual(2);
|
||||
fakeTimer.tick(500);
|
||||
expect(foo).toEqual(3);
|
||||
});
|
||||
|
||||
it("should run asynchronous tests", function () {
|
||||
var foo = 0;
|
||||
|
||||
//set a bogus suite for the spec to attach to
|
||||
// jasmine.getEnv().currentSuite = {specs: []};
|
||||
|
||||
var a_spec;
|
||||
env.describe('test async spec', function() {
|
||||
a_spec = env.it('simple queue test', function () {
|
||||
this.runs(function () {
|
||||
foo++;
|
||||
});
|
||||
this.runs(function () {
|
||||
this.expect(foo).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(a_spec.queue.length).toEqual(1,
|
||||
'Expected spec queue length to be 1, was ' + a_spec.queue.length);
|
||||
|
||||
a_spec.execute();
|
||||
expect(a_spec.queue.length).toEqual(3,
|
||||
'Expected spec queue length to be 3, was ' + a_spec.queue.length);
|
||||
|
||||
foo = 0;
|
||||
env.describe('test async spec', function() {
|
||||
a_spec = env.it('spec w/ queued statments', function () {
|
||||
this.runs(function () {
|
||||
@ -132,9 +142,10 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
|
||||
a_spec.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
expect(a_spec.results.getItems().length).toEqual(1); // 'No call to waits(): Spec queue did not run all functions';
|
||||
expect(a_spec.results.getItems()[0].passed).toEqual(true); // 'No call to waits(): Queued expectation failed';
|
||||
expect(a_spec.results.getItems()[0].passed()).toEqual(true); // 'No call to waits(): Queued expectation failed';
|
||||
|
||||
foo = 0;
|
||||
env.describe('test async spec', function() {
|
||||
@ -152,6 +163,8 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
|
||||
a_spec.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
expect(a_spec.results.getItems().length).toEqual(0);
|
||||
|
||||
fakeTimer.tick(500);
|
||||
@ -160,7 +173,7 @@ describe("jasmine spec running", function () {
|
||||
fakeTimer.tick(500);
|
||||
expect(a_spec.results.getItems().length).toEqual(1); // 'Calling waits(): Spec queue did not run all functions';
|
||||
|
||||
expect(a_spec.results.getItems()[0].passed).toEqual(true); // 'Calling waits(): Queued expectation failed';
|
||||
expect(a_spec.results.getItems()[0].passed()).toEqual(true); // 'Calling waits(): Queued expectation failed';
|
||||
|
||||
var bar = 0;
|
||||
var another_spec;
|
||||
@ -185,16 +198,13 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
});
|
||||
|
||||
expect(another_spec.queue.length).toEqual(1); // 'Calling 2 waits(): Expected queue length to be 1, got ' + another_spec.queue.length;
|
||||
|
||||
another_spec.execute();
|
||||
|
||||
fakeTimer.tick(1000);
|
||||
expect(another_spec.queue.length).toEqual(4); // 'Calling 2 waits(): Expected queue length to be 4, got ' + another_spec.queue.length;
|
||||
|
||||
expect(another_spec.results.getItems().length).toEqual(1); // 'Calling 2 waits(): Spec queue did not run all functions';
|
||||
|
||||
expect(another_spec.results.getItems()[0].passed).toEqual(true); // 'Calling 2 waits(): Queued expectation failed';
|
||||
expect(another_spec.results.getItems().length).toEqual(1);
|
||||
expect(another_spec.results.getItems()[0].passed()).toEqual(true);
|
||||
|
||||
var baz = 0;
|
||||
var yet_another_spec;
|
||||
@ -214,11 +224,13 @@ describe("jasmine spec running", function () {
|
||||
|
||||
|
||||
yet_another_spec.execute();
|
||||
fakeTimer.tick(250);
|
||||
//tick twice so that second runs gets eval'd first: mockClock bug?
|
||||
fakeTimer.tick(100);
|
||||
fakeTimer.tick(150);
|
||||
|
||||
expect(yet_another_spec.queue.length).toEqual(3); // 'Calling 2 waits(): Expected queue length to be 3, got ' + another_spec.queue.length);
|
||||
expect(yet_another_spec.results.getItems().length).toEqual(1); // 'Calling 2 waits(): Spec queue did not run all functions');
|
||||
expect(yet_another_spec.results.getItems()[0].passed).toEqual(false); // 'Calling 2 waits(): Queued expectation failed');
|
||||
|
||||
expect(yet_another_spec.results.getItems().length).toEqual(1);
|
||||
expect(yet_another_spec.results.getItems()[0].passed()).toEqual(false);
|
||||
});
|
||||
|
||||
it("testAsyncSpecsWithMockSuite", function () {
|
||||
@ -246,9 +258,8 @@ describe("jasmine spec running", function () {
|
||||
|
||||
another_spec.execute();
|
||||
fakeTimer.tick(2000);
|
||||
expect(another_spec.queue.length).toEqual(4); // 'Calling 2 waits(): Expected queue length to be 4, got ' + another_spec.queue.length);
|
||||
expect(another_spec.results.getItems().length).toEqual(1); // 'Calling 2 waits(): Spec queue did not run all functions');
|
||||
expect(another_spec.results.getItems()[0].passed).toEqual(true); // 'Calling 2 waits(): Queued expectation failed');
|
||||
expect(another_spec.results.getItems().length).toEqual(1);
|
||||
expect(another_spec.results.getItems()[0].passed()).toEqual(true);
|
||||
});
|
||||
|
||||
it("testWaitsFor", function() {
|
||||
@ -302,7 +313,7 @@ describe("jasmine spec running", function () {
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
|
||||
it("testWaitsForFailsIfTimeout", function() {
|
||||
it("waitsFor fails and skips the rest of the spec if timeout is reached and the latch function is still false", function() {
|
||||
var runsBlockExecuted = false;
|
||||
|
||||
var spec;
|
||||
@ -312,7 +323,7 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
|
||||
this.waitsFor(500, function() {
|
||||
return false; // force a timeout
|
||||
return false;
|
||||
});
|
||||
|
||||
this.runs(function() {
|
||||
@ -322,15 +333,15 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
|
||||
spec.execute();
|
||||
expect(runsBlockExecuted).toEqual(false, 'should not have executed runs block yet');
|
||||
expect(runsBlockExecuted).toEqual(false);
|
||||
fakeTimer.tick(100);
|
||||
expect(runsBlockExecuted).toEqual(false, 'should not have executed runs block yet');
|
||||
expect(runsBlockExecuted).toEqual(false);
|
||||
fakeTimer.tick(400);
|
||||
expect(runsBlockExecuted).toEqual(false, 'should have timed out, so the second runs block should not have been called');
|
||||
expect(runsBlockExecuted).toEqual(false);
|
||||
var actual = spec.results.getItems()[0].message;
|
||||
var expected = 'timeout: timed out after 500 msec waiting for something to happen';
|
||||
expect(actual).toEqual(expected,
|
||||
'expected "' + expected + '" but found "' + actual + '"');
|
||||
'expected "' + expected + '" but found "' + actual + '"');
|
||||
});
|
||||
|
||||
it("testSpecAfter", function() {
|
||||
@ -351,38 +362,19 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
expect(log).toEqual("specafter2after1"); // "after function should be executed in reverse order after spec runs");
|
||||
fakeTimer.tick(0);
|
||||
|
||||
expect(log).toEqual("specafter2after1");
|
||||
});
|
||||
|
||||
describe('test suite declaration', function() {
|
||||
var suite;
|
||||
var dummyFunction = function() {};
|
||||
var dummyFunction = function() {
|
||||
};
|
||||
|
||||
it('should give the suite a description', function() {
|
||||
suite = env.describe('one suite description', dummyFunction);
|
||||
expect(suite.description).toEqual('one suite description'); // 'Suite did not get a description');
|
||||
});
|
||||
|
||||
it('should add tests to suites declared by the passed function', function() {
|
||||
suite = env.describe('one suite description', function () {
|
||||
env.it('should be a test');
|
||||
});
|
||||
|
||||
expect(suite.specs.length).toEqual(1); // 'Suite did not get a spec pushed');
|
||||
expect(suite.specs[0].queue.length).toEqual(0); // "Suite's Spec should not have queuedFunctions");
|
||||
});
|
||||
|
||||
it('should enqueue functions for multipart tests', function() {
|
||||
suite = env.describe('one suite description', function () {
|
||||
env.it('should be a test with queuedFunctions', function() {
|
||||
this.runs(function() {
|
||||
var foo = 0;
|
||||
foo++;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(suite.specs[0].queue.length).toEqual(1); // "Suite's spec did not get a function pushed");
|
||||
expect(suite.description).toEqual('one suite description');
|
||||
});
|
||||
|
||||
it('should enqueue functions for multipart tests and support waits, and run any ready runs() blocks', function() {
|
||||
@ -401,9 +393,9 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
});
|
||||
|
||||
expect(suite.specs[0].queue.length).toEqual(1); // "Suite's spec length should have been 1, was " + suite.specs[0].queue.length);
|
||||
suite.execute();
|
||||
expect(suite.specs[0].queue.length).toEqual(3); // "Suite's spec length should have been 3, was " + suite.specs[0].queue.length);
|
||||
fakeTimer.tick(0);
|
||||
|
||||
expect(foo).toEqual(1);
|
||||
expect(bar).toEqual(0);
|
||||
|
||||
@ -414,7 +406,6 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
|
||||
it("testBeforeAndAfterCallbacks", function () {
|
||||
|
||||
var suiteWithBefore = env.describe('one suite with a before', function () {
|
||||
|
||||
this.beforeEach(function () {
|
||||
@ -437,42 +428,370 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
|
||||
suiteWithBefore.execute();
|
||||
var suite = suiteWithBefore;
|
||||
expect(suite.beforeEachFunction); // "testBeforeAndAfterCallbacks: Suite's beforeEach was not defined");
|
||||
expect(suite.specs[0].results.getItems()[0].passed).toEqual(true); // "testBeforeAndAfterCallbacks: the first spec's foo should have been 2");
|
||||
expect(suite.specs[1].results.getItems()[0].passed).toEqual(true); // "testBeforeAndAfterCallbacks: the second spec's this.foo should have been 2");
|
||||
fakeTimer.tick(0);
|
||||
|
||||
var suite = suiteWithBefore;
|
||||
|
||||
expect(suite.getResults().getItems()[0].passed()).toEqual(true); // "testBeforeAndAfterCallbacks: the first spec's foo should have been 2");
|
||||
expect(suite.getResults().getItems()[1].passed()).toEqual(true); // "testBeforeAndAfterCallbacks: the second spec's this.foo should have been 2");
|
||||
|
||||
|
||||
var foo = 1;
|
||||
var suiteWithAfter = env.describe('one suite with an after_each', function () {
|
||||
|
||||
env.it('should be a spec with an after_each', function () {
|
||||
this.runs(function() {
|
||||
this.foo = 0;
|
||||
this.foo++;
|
||||
this.expect(this.foo).toEqual(1);
|
||||
});
|
||||
this.expect(foo).toEqual(1);
|
||||
foo++;
|
||||
this.expect(foo).toEqual(2);
|
||||
});
|
||||
|
||||
env.it('should be another spec with an after_each', function () {
|
||||
this.runs(function() {
|
||||
this.foo = 0;
|
||||
this.foo++;
|
||||
this.expect(this.foo).toEqual(1);
|
||||
});
|
||||
this.expect(foo).toEqual(0);
|
||||
foo++;
|
||||
this.expect(foo).toEqual(1);
|
||||
});
|
||||
|
||||
this.afterEach(function () {
|
||||
this.foo = 0;
|
||||
foo = 0;
|
||||
});
|
||||
});
|
||||
|
||||
suiteWithAfter.execute();
|
||||
var suite = suiteWithAfter;
|
||||
expect(suite.afterEachFunction); // "testBeforeAndAfterCallbacks: Suite's afterEach was not defined");
|
||||
expect(suite.specs[0].results.getItems()[0].passed).toEqual(true); // "testBeforeAndAfterCallbacks: afterEach failure: " + suite.results.getItems()[0].results[0].message);
|
||||
expect(suite.specs[0].foo).toEqual(0); // "testBeforeAndAfterCallbacks: afterEach failure: foo was not reset to 0");
|
||||
expect(suite.specs[1].results.getItems()[0].passed).toEqual(true); // "testBeforeAndAfterCallbacks: afterEach failure: " + suite.results.getItems()[0].results[0].message);
|
||||
expect(suite.specs[1].foo).toEqual(0); // "testBeforeAndAfterCallbacks: afterEach failure: foo was not reset to 0");
|
||||
fakeTimer.tick(0);
|
||||
|
||||
suite = suiteWithAfter;
|
||||
expect(suite.afterEach.length).toEqual(1);
|
||||
expect(suite.getResults().getItems()[0].passed()).toEqual(true);
|
||||
expect(suite.getResults().getItems()[1].passed()).toEqual(true);
|
||||
expect(foo).toEqual(0);
|
||||
|
||||
});
|
||||
|
||||
it('#waits should allow consecutive waits calls', function () {
|
||||
var foo = 0;
|
||||
var waitsSuite = env.describe('suite that waits', function () {
|
||||
env.it('should wait', function() {
|
||||
this.waits(500);
|
||||
this.waits(500);
|
||||
this.runs(function () {
|
||||
foo++;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
waitsSuite.execute();
|
||||
expect(foo).toEqual(0);
|
||||
fakeTimer.tick(500);
|
||||
expect(foo).toEqual(0);
|
||||
fakeTimer.tick(500);
|
||||
|
||||
expect(foo).toEqual(1);
|
||||
});
|
||||
|
||||
it('nested suites', function () {
|
||||
|
||||
var foo = 0;
|
||||
var bar = 0;
|
||||
var baz = 0;
|
||||
var quux = 0;
|
||||
var nested = env.describe('suite', function () {
|
||||
env.describe('nested', function () {
|
||||
env.it('should run nested suites', function () {
|
||||
foo++;
|
||||
});
|
||||
env.it('should run nested suites', function () {
|
||||
bar++;
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('nested 2', function () {
|
||||
env.it('should run suites following nested suites', function () {
|
||||
baz++;
|
||||
});
|
||||
});
|
||||
|
||||
env.it('should run tests following nested suites', function () {
|
||||
quux++;
|
||||
});
|
||||
});
|
||||
|
||||
expect(foo).toEqual(0);
|
||||
expect(bar).toEqual(0);
|
||||
expect(baz).toEqual(0);
|
||||
expect(quux).toEqual(0);
|
||||
nested.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
expect(foo).toEqual(1);
|
||||
expect(bar).toEqual(1);
|
||||
expect(baz).toEqual(1);
|
||||
expect(quux).toEqual(1);
|
||||
});
|
||||
|
||||
describe('#waitsFor should allow consecutive calls', function () {
|
||||
|
||||
var foo;
|
||||
beforeEach(function () {
|
||||
|
||||
foo = 0;
|
||||
});
|
||||
|
||||
it('exits immediately (does not stack) if the latchFunction times out', function () {
|
||||
var reachedFirstWaitsFor = false;
|
||||
var reachedSecondWaitsFor = false;
|
||||
var waitsSuite = env.describe('suite that waits', function () {
|
||||
env.it('should stack timeouts', function() {
|
||||
this.waitsFor(500, function () {
|
||||
reachedFirstWaitsFor = true;
|
||||
return false;
|
||||
});
|
||||
this.waitsFor(500, function () {
|
||||
reachedSecondWaitsFor = true;
|
||||
});
|
||||
this.runs(function () {
|
||||
foo++;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(reachedFirstWaitsFor).toEqual(false);
|
||||
waitsSuite.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
expect(reachedFirstWaitsFor).toEqual(true);
|
||||
expect(foo).toEqual(0);
|
||||
expect(reachedSecondWaitsFor).toEqual(false);
|
||||
fakeTimer.tick(500);
|
||||
expect(reachedSecondWaitsFor).toEqual(false);
|
||||
expect(foo).toEqual(0);
|
||||
fakeTimer.tick(500);
|
||||
expect(reachedSecondWaitsFor).toEqual(false);
|
||||
expect(foo).toEqual(0);
|
||||
});
|
||||
|
||||
it('stacks latchFunctions', function () {
|
||||
var firstWaitsResult = false;
|
||||
var secondWaitsResult = false;
|
||||
var waitsSuite = env.describe('suite that waits', function () {
|
||||
env.it('spec with waitsFors', function() {
|
||||
this.waitsFor(600, function () {
|
||||
fakeTimer.setTimeout(function () {
|
||||
firstWaitsResult = true;
|
||||
}, 300);
|
||||
return firstWaitsResult;
|
||||
});
|
||||
this.waitsFor(600, function () {
|
||||
fakeTimer.setTimeout(function () {
|
||||
secondWaitsResult = true;
|
||||
}, 300);
|
||||
return secondWaitsResult;
|
||||
});
|
||||
this.runs(function () {
|
||||
foo++;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(firstWaitsResult).toEqual(false);
|
||||
expect(secondWaitsResult).toEqual(false);
|
||||
waitsSuite.execute();
|
||||
|
||||
expect(firstWaitsResult).toEqual(false);
|
||||
expect(secondWaitsResult).toEqual(false);
|
||||
expect(foo).toEqual(0);
|
||||
|
||||
fakeTimer.tick(300);
|
||||
|
||||
expect(firstWaitsResult).toEqual(true);
|
||||
expect(secondWaitsResult).toEqual(false);
|
||||
expect(foo).toEqual(0);
|
||||
|
||||
fakeTimer.tick(300);
|
||||
|
||||
expect(firstWaitsResult).toEqual(true);
|
||||
expect(secondWaitsResult).toEqual(true);
|
||||
expect(foo).toEqual(1);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
it("#beforeEach should be able to eval runs and waits blocks", function () {
|
||||
var foo = 0;
|
||||
var bar = 0;
|
||||
var suiteWithBefore = env.describe('one suite with a before', function () {
|
||||
this.beforeEach(function () {
|
||||
this.runs(function () {
|
||||
foo++;
|
||||
});
|
||||
this.waits(500);
|
||||
this.runs(function () {
|
||||
foo++;
|
||||
});
|
||||
this.waits(500);
|
||||
});
|
||||
|
||||
env.it('should be a spec', function () {
|
||||
bar = 1;
|
||||
foo++;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
expect(foo).toEqual(0);
|
||||
expect(bar).toEqual(0);
|
||||
suiteWithBefore.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
expect(bar).toEqual(0);
|
||||
expect(foo).toEqual(1);
|
||||
fakeTimer.tick(500);
|
||||
|
||||
expect(bar).toEqual(0);
|
||||
expect(foo).toEqual(2);
|
||||
fakeTimer.tick(500);
|
||||
expect(bar).toEqual(1);
|
||||
expect(foo).toEqual(3);
|
||||
});
|
||||
|
||||
it("#afterEach should be able to eval runs and waits blocks", function () {
|
||||
var foo = 0;
|
||||
var firstSpecHasRun = false;
|
||||
var secondSpecHasRun = false;
|
||||
var suiteWithAfter = env.describe('one suite with a before', function () {
|
||||
this.afterEach(function () {
|
||||
this.waits(500);
|
||||
this.runs(function () {
|
||||
foo++;
|
||||
});
|
||||
this.waits(500);
|
||||
});
|
||||
|
||||
env.it('should be the first spec', function () {
|
||||
firstSpecHasRun = true;
|
||||
});
|
||||
|
||||
env.it('should be a spec', function () {
|
||||
secondSpecHasRun = true;
|
||||
foo++;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
expect(firstSpecHasRun).toEqual(false);
|
||||
expect(secondSpecHasRun).toEqual(false);
|
||||
expect(foo).toEqual(0);
|
||||
|
||||
suiteWithAfter.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
|
||||
expect(firstSpecHasRun).toEqual(true);
|
||||
expect(secondSpecHasRun).toEqual(false);
|
||||
expect(foo).toEqual(0);
|
||||
|
||||
fakeTimer.tick(500);
|
||||
|
||||
expect(foo).toEqual(1);
|
||||
expect(secondSpecHasRun).toEqual(false);
|
||||
fakeTimer.tick(500);
|
||||
|
||||
expect(foo).toEqual(2);
|
||||
expect(secondSpecHasRun).toEqual(true);
|
||||
|
||||
});
|
||||
|
||||
it("Spec#after should be able to eval runs and waits blocks", function () {
|
||||
var runsBeforeAfter = false;
|
||||
var firstSpecHasRun = false;
|
||||
var secondSpecHasRun = false;
|
||||
var afterHasRun = false;
|
||||
var suiteWithAfter = env.describe('one suite with a before', function () {
|
||||
|
||||
env.it('should be the first spec', function () {
|
||||
firstSpecHasRun = true;
|
||||
this.after(function () {
|
||||
this.waits(500);
|
||||
this.runs(function () {
|
||||
afterHasRun = true;
|
||||
});
|
||||
this.waits(500);
|
||||
}, true);
|
||||
this.waits(500);
|
||||
this.runs(function () {
|
||||
runsBeforeAfter = true;
|
||||
});
|
||||
});
|
||||
|
||||
env.it('should be a spec', function () {
|
||||
secondSpecHasRun = true;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
expect(firstSpecHasRun).toEqual(false);
|
||||
expect(runsBeforeAfter).toEqual(false);
|
||||
expect(afterHasRun).toEqual(false);
|
||||
expect(secondSpecHasRun).toEqual(false);
|
||||
|
||||
suiteWithAfter.execute();
|
||||
|
||||
expect(firstSpecHasRun).toEqual(true);
|
||||
expect(runsBeforeAfter).toEqual(false);
|
||||
expect(afterHasRun).toEqual(false);
|
||||
expect(secondSpecHasRun).toEqual(false);
|
||||
|
||||
fakeTimer.tick(500);
|
||||
|
||||
expect(firstSpecHasRun).toEqual(true);
|
||||
expect(runsBeforeAfter).toEqual(true);
|
||||
expect(afterHasRun).toEqual(false);
|
||||
expect(secondSpecHasRun).toEqual(false);
|
||||
|
||||
fakeTimer.tick(500);
|
||||
|
||||
expect(firstSpecHasRun).toEqual(true);
|
||||
expect(runsBeforeAfter).toEqual(true);
|
||||
expect(afterHasRun).toEqual(true);
|
||||
expect(secondSpecHasRun).toEqual(false);
|
||||
|
||||
fakeTimer.tick(500);
|
||||
|
||||
expect(firstSpecHasRun).toEqual(true);
|
||||
expect(runsBeforeAfter).toEqual(true);
|
||||
expect(afterHasRun).toEqual(true);
|
||||
expect(secondSpecHasRun).toEqual(true);
|
||||
});
|
||||
|
||||
it("handles waits", function () {
|
||||
var firstSpecHasRun = false;
|
||||
var secondSpecHasRun = false;
|
||||
var suiteWithAfter = env.describe('one suite with a before', function () {
|
||||
|
||||
env.it('should be the first spec', function () {
|
||||
this.waits(500);
|
||||
this.runs(function () {
|
||||
firstSpecHasRun = true;
|
||||
});
|
||||
});
|
||||
|
||||
env.it('should be a spec', function () {
|
||||
secondSpecHasRun = true;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
expect(firstSpecHasRun).toEqual(false);
|
||||
expect(secondSpecHasRun).toEqual(false);
|
||||
|
||||
suiteWithAfter.execute();
|
||||
|
||||
expect(firstSpecHasRun).toEqual(false);
|
||||
expect(secondSpecHasRun).toEqual(false);
|
||||
|
||||
fakeTimer.tick(500);
|
||||
|
||||
expect(firstSpecHasRun).toEqual(true);
|
||||
expect(secondSpecHasRun).toEqual(true);
|
||||
});
|
||||
|
||||
it("testBeforeExecutesSafely", function() {
|
||||
@ -500,13 +819,12 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
expect(report).toEqual("firstsecond"); // "both tests should run");
|
||||
expect(suite.specs[0].results.getItems()[0].passed).toEqual(false); // "1st spec should fail");
|
||||
expect(suite.specs[1].results.getItems()[0].passed).toEqual(true); // "2nd spec should pass");
|
||||
|
||||
expect(suite.specs[0].results.getItems()[0].passed).toEqual(false); // "1st spec should fail");
|
||||
expect(suite.specs[1].results.getItems()[0].passed).toEqual(true); // "2nd spec should pass");
|
||||
expect(report).toEqual("firstsecond");
|
||||
var suiteResults = suite.getResults();
|
||||
expect(suiteResults.getItems()[0].getItems()[0].passed()).toEqual(false);
|
||||
expect(suiteResults.getItems()[1].getItems()[0].passed()).toEqual(true);
|
||||
});
|
||||
|
||||
it("testAfterExecutesSafely", function() {
|
||||
@ -540,18 +858,21 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
expect(report).toEqual("firstsecondthird"); // "all tests should run");
|
||||
//After each errors should not go in spec results because it confuses the count.
|
||||
expect(suite.specs.length).toEqual(3, 'testAfterExecutesSafely should have results for three specs');
|
||||
expect(suite.specs[0].results.getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 1st spec should pass");
|
||||
expect(suite.specs[1].results.getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 2nd spec should pass");
|
||||
expect(suite.specs[2].results.getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 3rd spec should pass");
|
||||
var suiteResults = suite.getResults();
|
||||
expect(suiteResults.getItems().length).toEqual(3, 'testAfterExecutesSafely should have results for three specs');
|
||||
|
||||
expect(suite.specs[0].results.getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 1st result for 1st suite spec should pass");
|
||||
expect(suite.specs[0].results.getItems()[1].passed).toEqual(false, "testAfterExecutesSafely 2nd result for 1st suite spec should fail because afterEach failed");
|
||||
expect(suite.specs[1].results.getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 2nd suite spec should pass");
|
||||
expect(suite.specs[2].results.getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 3rd suite spec should pass");
|
||||
expect(suiteResults.getItems()[0].getItems()[0].passed()).toEqual(true, "testAfterExecutesSafely 1st spec should pass");
|
||||
expect(suiteResults.getItems()[1].getItems()[0].passed()).toEqual(true, "testAfterExecutesSafely 2nd spec should pass");
|
||||
expect(suiteResults.getItems()[2].getItems()[0].passed()).toEqual(true, "testAfterExecutesSafely 3rd spec should pass");
|
||||
|
||||
expect(suiteResults.getItems()[0].getItems()[0].passed()).toEqual(true, "testAfterExecutesSafely 1st result for 1st suite spec should pass");
|
||||
expect(suiteResults.getItems()[0].getItems()[1].passed()).toEqual(false, "testAfterExecutesSafely 2nd result for 1st suite spec should fail because afterEach failed");
|
||||
expect(suiteResults.getItems()[1].getItems()[0].passed()).toEqual(true, "testAfterExecutesSafely 2nd suite spec should pass");
|
||||
expect(suiteResults.getItems()[2].getItems()[0].passed()).toEqual(true, "testAfterExecutesSafely 3rd suite spec should pass");
|
||||
});
|
||||
|
||||
it("testNestedDescribes", function() {
|
||||
@ -604,6 +925,8 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
|
||||
env.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
|
||||
var expected = [
|
||||
"outer beforeEach",
|
||||
@ -626,7 +949,7 @@ describe("jasmine spec running", function () {
|
||||
"inner 2 afterEach",
|
||||
"outer afterEach"
|
||||
];
|
||||
expect(env.equals_(actions, expected)).toEqual(true); // "nested describes order failed: <blockquote>" + jasmine.pp(actions) + "</blockquote> wanted <blockquote>" + jasmine.pp(expected) + "</blockquote");
|
||||
expect(env.equals_(actions, expected)).toEqual(true);
|
||||
});
|
||||
|
||||
it("builds up nested names", function() {
|
||||
@ -634,7 +957,8 @@ describe("jasmine spec running", function () {
|
||||
env.describe('Test Subject', function() {
|
||||
env.describe('when under circumstance A', function() {
|
||||
env.describe('and circumstance B', function() {
|
||||
nestedSpec = env.it('behaves thusly', function() {});
|
||||
nestedSpec = env.it('behaves thusly', function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -642,10 +966,40 @@ describe("jasmine spec running", function () {
|
||||
expect(nestedSpec.getFullName()).toEqual('Test Subject when under circumstance A and circumstance B behaves thusly.'); //, "Spec.fullName was incorrect: " + nestedSpec.getFullName());
|
||||
});
|
||||
|
||||
it("should skip empty suites", function () {
|
||||
env.describe('NonEmptySuite1', function() {
|
||||
env.it('should pass', function() {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
env.describe('NestedEmptySuite', function() {
|
||||
});
|
||||
env.it('should pass', function() {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
env.describe('EmptySuite', function() {});
|
||||
|
||||
env.describe('NonEmptySuite2', function() {
|
||||
env.it('should pass', function() {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
env.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
var runnerResults = env.currentRunner.getResults();
|
||||
expect(runnerResults.totalCount).toEqual(3);
|
||||
expect(runnerResults.passedCount).toEqual(3);
|
||||
expect(runnerResults.failedCount).toEqual(0);
|
||||
});
|
||||
|
||||
it("should bind 'this' to the running spec within the spec body", function() {
|
||||
var spec;
|
||||
var suite = env.describe('one suite description', function () {
|
||||
env.it('should be a test with queuedFunctions', function() {
|
||||
this.runs(function() {
|
||||
spec = this.runs(function() {
|
||||
this.foo = 0;
|
||||
this.foo++;
|
||||
});
|
||||
@ -672,11 +1026,11 @@ describe("jasmine spec running", function () {
|
||||
|
||||
suite.execute();
|
||||
fakeTimer.tick(600);
|
||||
|
||||
expect(suite.specs[0].foo).toEqual(2); // "Spec does not maintain scope in between functions");
|
||||
expect(suite.specs[0].results.getItems().length).toEqual(2); // "Spec did not get results for all expectations");
|
||||
expect(suite.specs[0].results.getItems()[0].passed).toEqual(false); // "Spec did not return false for a failed expectation");
|
||||
expect(suite.specs[0].results.getItems()[1].passed).toEqual(true); // "Spec did not return true for a passing expectation");
|
||||
expect(spec.foo).toEqual(2);
|
||||
var suiteResults = suite.getResults();
|
||||
expect(suiteResults.getItems()[0].getItems().length).toEqual(2);
|
||||
expect(suiteResults.getItems()[0].getItems()[0].passed()).toEqual(false);
|
||||
expect(suiteResults.getItems()[0].getItems()[1].passed()).toEqual(true);
|
||||
});
|
||||
|
||||
it("shouldn't run disabled tests", function() {
|
||||
@ -693,7 +1047,6 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
expect(suite.specs.length).toEqual(1);
|
||||
expect(xitSpecWasRun).toEqual(false);
|
||||
});
|
||||
|
||||
@ -740,7 +1093,7 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
|
||||
spec1 = env.it('spec with an expectation').runs(function () {
|
||||
this.addMatchers( { matcherForSpec: function(expected) {
|
||||
this.addMatchers({ matcherForSpec: function(expected) {
|
||||
return "matcherForSpec: actual: " + this.actual + "; expected: " + expected;
|
||||
} });
|
||||
spec1Matcher = this.expect("xxx");
|
||||
@ -752,6 +1105,7 @@ describe("jasmine spec running", function () {
|
||||
});
|
||||
|
||||
suite.execute();
|
||||
fakeTimer.tick(0);
|
||||
|
||||
expect(spec1Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: xxx; expected: expected");
|
||||
expect(spec1Matcher.matcherForSpec("expected")).toEqual("matcherForSpec: actual: xxx; expected: expected");
|
100
spec/suites/SuiteSpec.js
Normal file
100
spec/suites/SuiteSpec.js
Normal file
@ -0,0 +1,100 @@
|
||||
describe('Suite', function() {
|
||||
var fakeTimer;
|
||||
var env;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
|
||||
fakeTimer = new jasmine.FakeTimer();
|
||||
env.setTimeout = fakeTimer.setTimeout;
|
||||
env.clearTimeout = fakeTimer.clearTimeout;
|
||||
env.setInterval = fakeTimer.setInterval;
|
||||
env.clearInterval = fakeTimer.clearInterval;
|
||||
});
|
||||
|
||||
describe('Specs', function () {
|
||||
it('#specs should return all immediate children that are specs.', function () {
|
||||
var suite =env.describe('Suite 1', function () {
|
||||
env.it('Spec 1', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
env.it('Spec 2', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
env.describe('Suite 2', function () {
|
||||
env.it('Spec 3', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
env.it('Spec 4', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var suiteSpecs = suite.specs();
|
||||
expect(suiteSpecs.length).toEqual(3);
|
||||
expect(suiteSpecs[0].description).toEqual('Spec 1');
|
||||
expect(suiteSpecs[1].description).toEqual('Spec 2');
|
||||
expect(suiteSpecs[2].description).toEqual('Spec 4');
|
||||
});
|
||||
|
||||
describe('SpecCount', function () {
|
||||
|
||||
it('should keep a count of the number of specs that are run', function() {
|
||||
var suite = env.describe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
env.it('should be a third test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(suite.specCount()).toEqual(3);
|
||||
});
|
||||
|
||||
it('specCount should be correct even with runs/waits blocks', function() {
|
||||
var suite = env.describe('one suite description', function () {
|
||||
env.it('should be a test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
env.it('should be another test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
this.waits(10);
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
env.it('should be a third test', function() {
|
||||
this.runs(function () {
|
||||
this.expect(true).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
expect(suite.specCount()).toEqual(3);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -22,8 +22,8 @@ describe("TrivialReporter", function() {
|
||||
it("should display empty divs for every suite when the runner is starting", function() {
|
||||
trivialReporter = new jasmine.TrivialReporter({ body: body });
|
||||
trivialReporter.reportRunnerStarting({
|
||||
getAllSuites: function() {
|
||||
return [ new jasmine.Suite(null, "suite 1", null, null) ];
|
||||
suites: function() {
|
||||
return [ new jasmine.Suite({}, "suite 1", null, null) ];
|
||||
}
|
||||
});
|
||||
|
@ -1,92 +0,0 @@
|
||||
/**
|
||||
* base for Runner & Suite: allows for a queue of functions to get executed, allowing for
|
||||
* any one action to complete, including asynchronous calls, before going to the next
|
||||
* action.
|
||||
*
|
||||
* @constructor
|
||||
* @param {jasmine.Env} env
|
||||
*/
|
||||
jasmine.ActionCollection = function(env) {
|
||||
this.env = env;
|
||||
this.actions = [];
|
||||
this.index = 0;
|
||||
this.finished = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Marks the collection as done & calls the finish callback, if there is one
|
||||
*/
|
||||
jasmine.ActionCollection.prototype.finish = function() {
|
||||
if (this.finishCallback) {
|
||||
this.finishCallback();
|
||||
}
|
||||
this.finished = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Starts executing the queue of functions/actions.
|
||||
*/
|
||||
jasmine.ActionCollection.prototype.execute = function() {
|
||||
if (this.actions.length > 0) {
|
||||
this.next();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the current action.
|
||||
*/
|
||||
jasmine.ActionCollection.prototype.getCurrentAction = function() {
|
||||
return this.actions[this.index];
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the next queued function/action. If there are no more in the queue, calls #finish.
|
||||
*/
|
||||
jasmine.ActionCollection.prototype.next = function() {
|
||||
if (this.index >= this.actions.length) {
|
||||
this.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
var currentAction = this.getCurrentAction();
|
||||
|
||||
currentAction.execute(this);
|
||||
|
||||
if (currentAction.afterCallbacks) {
|
||||
for (var i = 0; i < currentAction.afterCallbacks.length; i++) {
|
||||
try {
|
||||
currentAction.afterCallbacks[i]();
|
||||
} catch (e) {
|
||||
alert(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.waitForDone(currentAction);
|
||||
};
|
||||
|
||||
jasmine.ActionCollection.prototype.waitForDone = function(action) {
|
||||
var self = this;
|
||||
var afterExecute = function afterExecute() {
|
||||
self.index++;
|
||||
self.next();
|
||||
};
|
||||
|
||||
if (action.finished) {
|
||||
var now = new Date().getTime();
|
||||
if (this.env.updateInterval && now - this.env.lastUpdate > this.env.updateInterval) {
|
||||
this.env.lastUpdate = now;
|
||||
this.env.setTimeout(afterExecute, 0);
|
||||
} else {
|
||||
afterExecute();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var id = this.env.setInterval(function() {
|
||||
if (action.finished) {
|
||||
self.env.clearInterval(id);
|
||||
afterExecute();
|
||||
}
|
||||
}, 150);
|
||||
};
|
26
src/Block.js
Normal file
26
src/Block.js
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Blocks are functions with executable code that make up a spec.
|
||||
*
|
||||
* @constructor
|
||||
* @param {jasmine.Env} env
|
||||
* @param {Function} func
|
||||
* @param {jasmine.Spec} spec
|
||||
*/
|
||||
jasmine.Block = function(env, func, spec) {
|
||||
this.env = env;
|
||||
this.func = func;
|
||||
this.spec = spec;
|
||||
};
|
||||
|
||||
jasmine.Block.prototype.execute = function(onComplete) {
|
||||
try {
|
||||
this.func.apply(this.spec);
|
||||
} catch (e) {
|
||||
this.fail(e);
|
||||
}
|
||||
onComplete();
|
||||
};
|
||||
|
||||
jasmine.Block.prototype.fail = function(e) {
|
||||
this.spec.results.addResult(new jasmine.ExpectationResult(false, jasmine.util.formatException(e), null));
|
||||
};
|
17
src/Env.js
17
src/Env.js
@ -18,6 +18,7 @@ jasmine.Env = function() {
|
||||
};
|
||||
|
||||
this.nextSpecId_ = 0;
|
||||
this.nextSuiteId_ = 0;
|
||||
this.equalityTesters_ = [];
|
||||
};
|
||||
|
||||
@ -27,6 +28,14 @@ jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;
|
||||
jasmine.Env.prototype.setInterval = jasmine.setInterval;
|
||||
jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
|
||||
|
||||
jasmine.Env.prototype.version = function () {
|
||||
if (jasmine.version_) {
|
||||
return jasmine.version_;
|
||||
} else {
|
||||
throw new Error('Version not set');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Register a reporter to receive status updates from Jasmine.
|
||||
* @param {jasmine.Reporter} reporter An object which will receive status updates.
|
||||
@ -44,9 +53,9 @@ jasmine.Env.prototype.describe = function(description, specDefinitions) {
|
||||
|
||||
var parentSuite = this.currentSuite;
|
||||
if (parentSuite) {
|
||||
parentSuite.specs.push(suite);
|
||||
parentSuite.add(suite);
|
||||
} else {
|
||||
this.currentRunner.suites.push(suite);
|
||||
this.currentRunner.add(suite);
|
||||
}
|
||||
|
||||
this.currentSuite = suite;
|
||||
@ -75,11 +84,11 @@ jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
|
||||
|
||||
jasmine.Env.prototype.it = function(description, func) {
|
||||
var spec = new jasmine.Spec(this, this.currentSuite, description);
|
||||
this.currentSuite.specs.push(spec);
|
||||
this.currentSuite.add(spec);
|
||||
this.currentSpec = spec;
|
||||
|
||||
if (func) {
|
||||
spec.addToQueue(func);
|
||||
spec.runs(func);
|
||||
}
|
||||
|
||||
return spec;
|
||||
|
@ -11,27 +11,27 @@ jasmine.JsApiReporter = function() {
|
||||
|
||||
jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
this.started = true;
|
||||
|
||||
for (var i = 0; i < runner.suites.length; i++) {
|
||||
var suite = runner.suites[i];
|
||||
var suites = runner.suites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
this.suites.push(this.summarize_(suite));
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
|
||||
var isSuite = suiteOrSpec instanceof jasmine.Suite
|
||||
var summary = {
|
||||
id: suiteOrSpec.id,
|
||||
name: suiteOrSpec.description,
|
||||
type: suiteOrSpec instanceof jasmine.Suite ? 'suite' : 'spec',
|
||||
type: isSuite ? 'suite' : 'spec',
|
||||
children: []
|
||||
};
|
||||
|
||||
if (suiteOrSpec.specs) {
|
||||
for (var i = 0; i < suiteOrSpec.specs.length; i++) {
|
||||
summary.children.push(this.summarize_(suiteOrSpec.specs[i]));
|
||||
if (isSuite) {
|
||||
var specs = suiteOrSpec.specs();
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
summary.children.push(this.summarize_(specs[i]));
|
||||
}
|
||||
}
|
||||
|
||||
return summary;
|
||||
};
|
||||
|
||||
|
@ -62,7 +62,7 @@ jasmine.NestedResults.prototype.addResult = function(result) {
|
||||
this.rollupCounts(result);
|
||||
} else {
|
||||
this.totalCount++;
|
||||
if (result.passed) {
|
||||
if (result.passed()) {
|
||||
this.passedCount++;
|
||||
} else {
|
||||
this.failedCount++;
|
||||
|
@ -28,7 +28,7 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
||||
} else if (value instanceof jasmine.Matchers.Any) {
|
||||
this.emitScalar(value.toString());
|
||||
} else if (typeof value === 'string') {
|
||||
this.emitScalar("'" + value + "'");
|
||||
this.emitString(value);
|
||||
} else if (typeof value === 'function') {
|
||||
this.emitScalar('Function');
|
||||
} else if (typeof value.nodeType === 'number') {
|
||||
@ -63,6 +63,7 @@ jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
|
||||
jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_;
|
||||
jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_;
|
||||
jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_;
|
||||
jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_;
|
||||
|
||||
jasmine.StringPrettyPrinter = function() {
|
||||
jasmine.PrettyPrinter.call(this);
|
||||
@ -75,6 +76,10 @@ jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) {
|
||||
this.append(value);
|
||||
};
|
||||
|
||||
jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
|
||||
this.append("'" + value + "'");
|
||||
};
|
||||
|
||||
jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
|
||||
this.append('[ ');
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
|
71
src/Queue.js
Normal file
71
src/Queue.js
Normal file
@ -0,0 +1,71 @@
|
||||
jasmine.Queue = function(env) {
|
||||
this.env = env;
|
||||
this.blocks = [];
|
||||
this.running = false;
|
||||
this.index = 0;
|
||||
this.offset = 0;
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.addBefore = function (block) {
|
||||
this.blocks.unshift(block);
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.add = function(block) {
|
||||
this.blocks.push(block);
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.insertNext = function (block) {
|
||||
this.blocks.splice((this.index + this.offset + 1), 0, block);
|
||||
this.offset++;
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.start = function(onComplete) {
|
||||
var self = this;
|
||||
self.running = true;
|
||||
self.onComplete = onComplete;
|
||||
if (self.blocks[0]) {
|
||||
self.blocks[0].execute(function () {
|
||||
self._next();
|
||||
});
|
||||
} else {
|
||||
self.finish();
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.isRunning = function () {
|
||||
return this.running;
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype._next = function () {
|
||||
var self = this;
|
||||
self.env.setTimeout(function () {
|
||||
self.offset = 0;
|
||||
self.index++;
|
||||
if (self.index < self.blocks.length) {
|
||||
self.blocks[self.index].execute(function () {
|
||||
self._next();
|
||||
});
|
||||
} else {
|
||||
self.finish();
|
||||
}
|
||||
}, 0);
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.finish = function () {
|
||||
this.running = false;
|
||||
if (this.onComplete) {
|
||||
this.onComplete();
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.getResults = function () {
|
||||
var results = new jasmine.NestedResults();
|
||||
for (var i = 0; i < this.blocks.length; i++) {
|
||||
if (this.blocks[i].getResults) {
|
||||
results.addResult(this.blocks[i].getResults());
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
|
@ -1,84 +0,0 @@
|
||||
/**
|
||||
* QueuedFunction is how ActionCollections' actions are implemented
|
||||
*
|
||||
* @constructor
|
||||
* @param {jasmine.Env} env
|
||||
* @param {Function} func
|
||||
* @param {Number} timeout
|
||||
* @param {Function} latchFunction
|
||||
* @param {jasmine.Spec} spec
|
||||
*/
|
||||
jasmine.QueuedFunction = function(env, func, timeout, latchFunction, spec) {
|
||||
this.env = env;
|
||||
this.func = func;
|
||||
this.timeout = timeout;
|
||||
this.latchFunction = latchFunction;
|
||||
this.spec = spec;
|
||||
|
||||
this.totalTimeSpentWaitingForLatch = 0;
|
||||
this.latchTimeoutIncrement = 100;
|
||||
};
|
||||
|
||||
jasmine.QueuedFunction.prototype.next = function() {
|
||||
this.spec.finish(); // default value is to be done after one function
|
||||
};
|
||||
|
||||
jasmine.QueuedFunction.prototype.safeExecute = function() {
|
||||
this.env.reporter.log('>> Jasmine Running ' + this.spec.suite.description + ' ' + this.spec.description + '...');
|
||||
|
||||
try {
|
||||
this.func.apply(this.spec);
|
||||
} catch (e) {
|
||||
this.fail(e);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.QueuedFunction.prototype.execute = function() {
|
||||
var self = this;
|
||||
var executeNow = function() {
|
||||
self.safeExecute();
|
||||
self.next();
|
||||
};
|
||||
|
||||
var executeLater = function() {
|
||||
self.env.setTimeout(executeNow, self.timeout);
|
||||
};
|
||||
|
||||
var executeNowOrLater = function() {
|
||||
var latchFunctionResult;
|
||||
|
||||
try {
|
||||
latchFunctionResult = self.latchFunction.apply(self.spec);
|
||||
} catch (e) {
|
||||
self.fail(e);
|
||||
self.next();
|
||||
return;
|
||||
}
|
||||
|
||||
if (latchFunctionResult) {
|
||||
executeNow();
|
||||
} else if (self.totalTimeSpentWaitingForLatch >= self.timeout) {
|
||||
var message = 'timed out after ' + self.timeout + ' msec waiting for ' + (self.latchFunction.description || 'something to happen');
|
||||
self.fail({
|
||||
name: 'timeout',
|
||||
message: message
|
||||
});
|
||||
self.next();
|
||||
} else {
|
||||
self.totalTimeSpentWaitingForLatch += self.latchTimeoutIncrement;
|
||||
self.env.setTimeout(executeNowOrLater, self.latchTimeoutIncrement);
|
||||
}
|
||||
};
|
||||
|
||||
if (this.latchFunction !== undefined) {
|
||||
executeNowOrLater();
|
||||
} else if (this.timeout > 0) {
|
||||
executeLater();
|
||||
} else {
|
||||
executeNow();
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.QueuedFunction.prototype.fail = function(e) {
|
||||
this.spec.results.addResult(new jasmine.ExpectationResult(false, jasmine.util.formatException(e), null));
|
||||
};
|
@ -5,49 +5,47 @@
|
||||
* @param {jasmine.Env} env
|
||||
*/
|
||||
jasmine.Runner = function(env) {
|
||||
jasmine.ActionCollection.call(this, env);
|
||||
|
||||
this.suites = this.actions;
|
||||
var self = this;
|
||||
self.env = env;
|
||||
self.queue = new jasmine.Queue(env);
|
||||
self.suites_ = [];
|
||||
};
|
||||
jasmine.util.inherit(jasmine.Runner, jasmine.ActionCollection);
|
||||
|
||||
jasmine.Runner.prototype.execute = function() {
|
||||
if (this.env.reporter.reportRunnerStarting) {
|
||||
this.env.reporter.reportRunnerStarting(this);
|
||||
var self = this;
|
||||
if (self.env.reporter.reportRunnerStarting) {
|
||||
self.env.reporter.reportRunnerStarting(this);
|
||||
}
|
||||
jasmine.ActionCollection.prototype.execute.call(this);
|
||||
self.queue.start(function () {
|
||||
self.finishCallback();
|
||||
});
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.finishCallback = function() {
|
||||
this.env.reporter.reportRunnerResults(this);
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.addSuite = function(suite) {
|
||||
this.suites_.push(suite);
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.add = function(block) {
|
||||
if (block instanceof jasmine.Suite) {
|
||||
this.addSuite(block);
|
||||
}
|
||||
this.queue.add(block);
|
||||
};
|
||||
|
||||
/** @deprecated */
|
||||
jasmine.Runner.prototype.getAllSuites = function() {
|
||||
var suitesToReturn = [];
|
||||
return this.suites_;
|
||||
};
|
||||
|
||||
function addSuite(suite) {
|
||||
suitesToReturn.push(suite);
|
||||
|
||||
for (var j = 0; j < suite.specs.length; j++) {
|
||||
var spec = suite.specs[j];
|
||||
if (spec instanceof jasmine.Suite) {
|
||||
addSuite(spec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < this.suites.length; i++) {
|
||||
var suite = this.suites[i];
|
||||
addSuite(suite);
|
||||
}
|
||||
|
||||
return suitesToReturn;
|
||||
jasmine.Runner.prototype.suites = function() {
|
||||
return this.suites_;
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.getResults = function() {
|
||||
var results = new jasmine.NestedResults();
|
||||
for (var i = 0; i < this.suites.length; i++) {
|
||||
results.rollupCounts(this.suites[i].getResults());
|
||||
}
|
||||
return results;
|
||||
};
|
||||
return this.queue.getResults();
|
||||
};
|
148
src/Spec.js
148
src/Spec.js
@ -7,21 +7,19 @@
|
||||
* @param {String} description
|
||||
*/
|
||||
jasmine.Spec = function(env, suite, description) {
|
||||
this.id = env.nextSpecId_++;
|
||||
this.env = env;
|
||||
this.suite = suite;
|
||||
this.description = description;
|
||||
this.queue = [];
|
||||
this.currentTimeout = 0;
|
||||
this.currentLatchFunction = undefined;
|
||||
this.finished = false;
|
||||
this.afterCallbacks = [];
|
||||
this.spies_ = [];
|
||||
var spec = this;
|
||||
spec.id = env.nextSpecId_++;
|
||||
spec.env = env;
|
||||
spec.suite = suite;
|
||||
spec.description = description;
|
||||
spec.queue = new jasmine.Queue(env);
|
||||
|
||||
this.results = new jasmine.NestedResults();
|
||||
this.results.description = description;
|
||||
this.runs = this.addToQueue;
|
||||
this.matchersClass = null;
|
||||
spec.afterCallbacks = [];
|
||||
spec.spies_ = [];
|
||||
|
||||
spec.results = new jasmine.NestedResults();
|
||||
spec.results.description = description;
|
||||
spec.matchersClass = null;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.getFullName = function() {
|
||||
@ -32,21 +30,20 @@ jasmine.Spec.prototype.getResults = function() {
|
||||
return this.results;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.addToQueue = function(func) {
|
||||
var queuedFunction = new jasmine.QueuedFunction(this.env, func, this.currentTimeout, this.currentLatchFunction, this);
|
||||
this.queue.push(queuedFunction);
|
||||
|
||||
if (this.queue.length > 1) {
|
||||
var previousQueuedFunction = this.queue[this.queue.length - 2];
|
||||
previousQueuedFunction.next = function() {
|
||||
queuedFunction.execute();
|
||||
};
|
||||
}
|
||||
|
||||
this.resetTimeout();
|
||||
jasmine.Spec.prototype.runs = function (func) {
|
||||
var block = new jasmine.Block(this.env, func, this);
|
||||
this.addToQueue(block);
|
||||
return this;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.addToQueue = function (block) {
|
||||
if (this.queue.isRunning()) {
|
||||
this.queue.insertNext(block);
|
||||
} else {
|
||||
this.queue.add(block);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @deprecated
|
||||
@ -62,25 +59,22 @@ jasmine.Spec.prototype.expect = function(actual) {
|
||||
return new (this.getMatchersClass_())(this.env, actual, this.results);
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
jasmine.Spec.prototype.waits = function(timeout) {
|
||||
this.currentTimeout = timeout;
|
||||
this.currentLatchFunction = undefined;
|
||||
var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this);
|
||||
this.addToQueue(waitsFunc);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, message) {
|
||||
this.currentTimeout = timeout;
|
||||
this.currentLatchFunction = latchFunction;
|
||||
this.currentLatchFunction.description = message;
|
||||
jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, timeoutMessage) {
|
||||
var waitsForFunc = new jasmine.WaitsForBlock(this.env, timeout, latchFunction, timeoutMessage, this);
|
||||
this.addToQueue(waitsForFunc);
|
||||
return this;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.failWithException = function (e) {
|
||||
this.results.addResult(new jasmine.ExpectationResult(false, jasmine.util.formatException(e), null));
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.getMatchersClass_ = function() {
|
||||
return this.matchersClass || jasmine.Matchers;
|
||||
};
|
||||
@ -97,70 +91,62 @@ jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
|
||||
this.matchersClass = newMatchersClass;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.resetTimeout = function() {
|
||||
this.currentTimeout = 0;
|
||||
this.currentLatchFunction = undefined;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.finishCallback = function() {
|
||||
this.env.reporter.reportSpecResults(this);
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.finish = function() {
|
||||
this.safeExecuteAfters();
|
||||
|
||||
jasmine.Spec.prototype.finish = function(onComplete) {
|
||||
this.removeAllSpies();
|
||||
this.finishCallback();
|
||||
this.finished = true;
|
||||
if (onComplete) {
|
||||
onComplete();
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.after = function(doAfter) {
|
||||
jasmine.Spec.prototype.after = function(doAfter, test) {
|
||||
|
||||
if (this.queue.isRunning()) {
|
||||
this.queue.add(new jasmine.Block(this.env, doAfter, this));
|
||||
} else {
|
||||
this.afterCallbacks.unshift(doAfter);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.execute = function() {
|
||||
if (!this.env.specFilter(this)) {
|
||||
this.results.skipped = true;
|
||||
this.finishCallback();
|
||||
this.finished = true;
|
||||
jasmine.Spec.prototype.execute = function(onComplete) {
|
||||
var spec = this;
|
||||
if (!spec.env.specFilter(spec)) {
|
||||
spec.results.skipped = true;
|
||||
spec.finish(onComplete);
|
||||
return;
|
||||
}
|
||||
this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...');
|
||||
|
||||
this.env.currentSpec = this;
|
||||
this.env.currentlyRunningTests = true;
|
||||
spec.env.currentSpec = spec;
|
||||
spec.env.currentlyRunningTests = true;
|
||||
|
||||
this.safeExecuteBefores();
|
||||
spec.addBeforesAndAftersToQueue();
|
||||
|
||||
if (this.queue[0]) {
|
||||
this.queue[0].execute();
|
||||
} else {
|
||||
this.finish();
|
||||
}
|
||||
this.env.currentlyRunningTests = false;
|
||||
spec.queue.start(function () {
|
||||
spec.finish(onComplete);
|
||||
});
|
||||
spec.env.currentlyRunningTests = false;
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.safeExecuteBefores = function() {
|
||||
var befores = [];
|
||||
jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
|
||||
for (var suite = this.suite; suite; suite = suite.parentSuite) {
|
||||
if (suite.beforeEachFunction) befores.push(suite.beforeEachFunction);
|
||||
if (suite.beforeQueue) {
|
||||
for (var i = 0; i < suite.beforeQueue.length; i++)
|
||||
this.queue.addBefore(new jasmine.Block(this.env, suite.beforeQueue[i], this));
|
||||
}
|
||||
}
|
||||
|
||||
while (befores.length) {
|
||||
this.safeExecuteBeforeOrAfter(befores.pop());
|
||||
for (i = 0; i < this.afterCallbacks.length; i++) {
|
||||
this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this));
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.safeExecuteAfters = function() {
|
||||
for (var suite = this.suite; suite; suite = suite.parentSuite) {
|
||||
if (suite.afterEachFunction) this.safeExecuteBeforeOrAfter(suite.afterEachFunction);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.safeExecuteBeforeOrAfter = function(func) {
|
||||
try {
|
||||
func.apply(this);
|
||||
} catch (e) {
|
||||
this.results.addResult(new jasmine.ExpectationResult(false, func.typeName + '() fail: ' + jasmine.util.formatException(e), null));
|
||||
for (suite = this.suite; suite; suite = suite.parentSuite) {
|
||||
if (suite.afterQueue) {
|
||||
for (var j = 0; j < suite.afterQueue.length; j++)
|
||||
this.queue.add(new jasmine.Block(this.env, suite.afterQueue[j], this));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
58
src/Suite.js
58
src/Suite.js
@ -8,16 +8,16 @@
|
||||
* @param {jasmine.Suite} parentSuite
|
||||
*/
|
||||
jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
|
||||
jasmine.ActionCollection.call(this, env);
|
||||
|
||||
this.description = description;
|
||||
this.specs = this.actions;
|
||||
this.parentSuite = parentSuite;
|
||||
|
||||
this.beforeEachFunction = null;
|
||||
this.afterEachFunction = null;
|
||||
var self = this;
|
||||
self.id = env.nextSuiteId_++;
|
||||
self.description = description;
|
||||
self.queue = new jasmine.Queue(env);
|
||||
self.parentSuite = parentSuite;
|
||||
self.env = env;
|
||||
self.beforeQueue = [];
|
||||
self.afterQueue = [];
|
||||
self.specs_ = [];
|
||||
};
|
||||
jasmine.util.inherit(jasmine.Suite, jasmine.ActionCollection);
|
||||
|
||||
jasmine.Suite.prototype.getFullName = function() {
|
||||
var fullName = this.description;
|
||||
@ -27,25 +27,49 @@ jasmine.Suite.prototype.getFullName = function() {
|
||||
return fullName;
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.finishCallback = function() {
|
||||
jasmine.Suite.prototype.finish = function(onComplete) {
|
||||
this.env.reporter.reportSuiteResults(this);
|
||||
this.finished = true;
|
||||
if (typeof(onComplete) == 'function') {
|
||||
onComplete();
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {
|
||||
beforeEachFunction.typeName = 'beforeEach';
|
||||
this.beforeEachFunction = beforeEachFunction;
|
||||
this.beforeQueue.push(beforeEachFunction);
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
|
||||
afterEachFunction.typeName = 'afterEach';
|
||||
this.afterEachFunction = afterEachFunction;
|
||||
this.afterQueue.push(afterEachFunction);
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.getResults = function() {
|
||||
var results = new jasmine.NestedResults();
|
||||
for (var i = 0; i < this.specs.length; i++) {
|
||||
results.rollupCounts(this.specs[i].getResults());
|
||||
}
|
||||
return results;
|
||||
return this.queue.getResults();
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.add = function(block) {
|
||||
if (block instanceof jasmine.Suite) {
|
||||
this.env.currentRunner.addSuite(block);
|
||||
} else {
|
||||
this.specs_.push(block);
|
||||
}
|
||||
this.queue.add(block);
|
||||
};
|
||||
|
||||
/** @deprecated */
|
||||
jasmine.Suite.prototype.specCount = function() {
|
||||
return this.specs_.length;
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.specs = function() {
|
||||
return this.specs_;
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.execute = function(onComplete) {
|
||||
var self = this;
|
||||
this.queue.start(function () {
|
||||
self.finish(onComplete);
|
||||
});
|
||||
};
|
13
src/WaitsBlock.js
Normal file
13
src/WaitsBlock.js
Normal file
@ -0,0 +1,13 @@
|
||||
jasmine.WaitsBlock = function(env, timeout, spec) {
|
||||
this.timeout = timeout;
|
||||
jasmine.Block.call(this, env, null, spec);
|
||||
};
|
||||
|
||||
jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
|
||||
|
||||
jasmine.WaitsBlock.prototype.execute = function (onComplete) {
|
||||
this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
|
||||
this.env.setTimeout(function () {
|
||||
onComplete();
|
||||
}, this.timeout);
|
||||
};
|
38
src/WaitsForBlock.js
Normal file
38
src/WaitsForBlock.js
Normal file
@ -0,0 +1,38 @@
|
||||
jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) {
|
||||
this.timeout = timeout;
|
||||
this.latchFunction = latchFunction;
|
||||
this.message = message;
|
||||
this.totalTimeSpentWaitingForLatch = 0;
|
||||
jasmine.Block.call(this, env, null, spec);
|
||||
};
|
||||
|
||||
jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);
|
||||
|
||||
jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 100;
|
||||
|
||||
jasmine.WaitsForBlock.prototype.execute = function (onComplete) {
|
||||
var self = this;
|
||||
self.env.reporter.log('>> Jasmine waiting for ' + (self.message || 'something to happen'));
|
||||
var latchFunctionResult;
|
||||
try {
|
||||
latchFunctionResult = self.latchFunction.apply(self.spec);
|
||||
} catch (e) {
|
||||
self.fail(e);
|
||||
onComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
if (latchFunctionResult) {
|
||||
onComplete();
|
||||
} else if (self.totalTimeSpentWaitingForLatch >= self.timeout) {
|
||||
var message = 'timed out after ' + self.timeout + ' msec waiting for ' + (self.message || 'something to happen');
|
||||
self.fail({
|
||||
name: 'timeout',
|
||||
message: message
|
||||
});
|
||||
self.spec._next();
|
||||
} else {
|
||||
self.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT;
|
||||
self.env.setTimeout(function () { self.execute(onComplete); }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);
|
||||
}
|
||||
};
|
@ -40,12 +40,16 @@ jasmine.MessageResult = function(text) {
|
||||
|
||||
jasmine.ExpectationResult = function(passed, message, details) {
|
||||
this.type = 'ExpectationResult';
|
||||
this.passed = passed;
|
||||
this.passed_ = passed;
|
||||
this.message = message;
|
||||
this.details = details;
|
||||
this.trace = new Error(message); // todo: test better
|
||||
};
|
||||
|
||||
jasmine.ExpectationResult.prototype.passed = function () {
|
||||
return this.passed_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Getter for the Jasmine environment. Ensures one gets created
|
||||
*/
|
||||
|
5
src/version.json
Normal file
5
src/version.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"major": 0,
|
||||
"minor": 9,
|
||||
"build": 0
|
||||
}
|
Loading…
Reference in New Issue
Block a user