mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:36:59 +00:00
Move generated files to gen/.
- The generated SDK goes into gen/patched_sdk. - Expanded multitests go into gen/codegen_tests. - Compiled tests go into gen/codegen_output. R=jmesserly@google.com Review URL: https://codereview.chromium.org/1988503002 .
This commit is contained in:
parent
4cf7ee3332
commit
1e5b3af2e0
|
@ -1,9 +1,9 @@
|
|||
analyzer:
|
||||
exclude:
|
||||
- doc/api/**
|
||||
- gen/**
|
||||
- node_modules/**
|
||||
- tool/input_sdk/**
|
||||
- tool/generated_sdk/**
|
||||
- test/codegen/**
|
||||
- test/samples/**
|
||||
- test/transformer/hello_app/**
|
||||
|
|
23
pkg/dev_compiler/.gitignore
vendored
23
pkg/dev_compiler/.gitignore
vendored
|
@ -14,26 +14,13 @@ packages
|
|||
node_modules
|
||||
doc/api/
|
||||
|
||||
# Ignore generated summary
|
||||
# Generated files go here.
|
||||
gen/
|
||||
|
||||
# Ignore generated summary.
|
||||
lib/runtime/dart_sdk.sum
|
||||
|
||||
# Ignore test output
|
||||
test/codegen/expect/dev_compiler/
|
||||
test/codegen/expect/language/
|
||||
test/codegen/expect/lib/
|
||||
test/codegen/expect/corelib/
|
||||
test/codegen/expect/sunflower/dev_compiler/
|
||||
test/codegen/expect/matcher/
|
||||
test/codegen/expect/path/
|
||||
test/codegen/expect/stack_trace/
|
||||
test/codegen/expect/unittest/
|
||||
test/codegen/expect/*.err
|
||||
test/**/*_multi.dart
|
||||
|
||||
# Created by ./tool/build_sdk.sh
|
||||
tool/generated_sdk/
|
||||
|
||||
# Created by ./tool/dependency_overrides.sh
|
||||
# Created by ./tool/dependency_overrides.sh.
|
||||
dependency_overrides/
|
||||
|
||||
# Include when developing application packages.
|
||||
|
|
|
@ -16,23 +16,23 @@ module.exports = function(config) {
|
|||
'lib/runtime/dart_*.js',
|
||||
'lib/runtime/dart/*.js',
|
||||
// {pattern: 'test/browser/*.js', included: false}
|
||||
'test/codegen/expect/async_helper/async_helper.js',
|
||||
'test/codegen/expect/dom/dom.js',
|
||||
'test/codegen/expect/expect/expect.js',
|
||||
'test/codegen/expect/path/path.js',
|
||||
'test/codegen/expect/stack_trace/stack_trace.js',
|
||||
'test/codegen/expect/js/js.js',
|
||||
'test/codegen/expect/matcher/matcher.js',
|
||||
'test/codegen/expect/unittest/unittest.js',
|
||||
'test/codegen/expect/syncstar_syntax.js',
|
||||
'test/codegen/expect/language/**.js',
|
||||
'test/codegen/expect/language/sub/sub.js',
|
||||
'test/codegen/expect/language/*.lib',
|
||||
'test/codegen/expect/corelib/**.js',
|
||||
'test/codegen/expect/lib/convert/**.js',
|
||||
'test/codegen/expect/lib/html/**.js',
|
||||
'test/codegen/expect/lib/math/**.js',
|
||||
'test/codegen/expect/lib/typed_data/**.js',
|
||||
'gen/codegen_output/async_helper/async_helper.js',
|
||||
'gen/codegen_output/dom/dom.js',
|
||||
'gen/codegen_output/expect/expect.js',
|
||||
'gen/codegen_output/path/path.js',
|
||||
'gen/codegen_output/stack_trace/stack_trace.js',
|
||||
'gen/codegen_output/js/js.js',
|
||||
'gen/codegen_output/matcher/matcher.js',
|
||||
'gen/codegen_output/unittest/unittest.js',
|
||||
'gen/codegen_output/syncstar_syntax.js',
|
||||
'gen/codegen_output/language/**.js',
|
||||
'gen/codegen_output/language/sub/sub.js',
|
||||
'gen/codegen_output/language/*.lib',
|
||||
'gen/codegen_output/corelib/**.js',
|
||||
'gen/codegen_output/lib/convert/**.js',
|
||||
'gen/codegen_output/lib/html/**.js',
|
||||
'gen/codegen_output/lib/math/**.js',
|
||||
'gen/codegen_output/lib/typed_data/**.js',
|
||||
'test/browser/*.js',
|
||||
'test-main.js',
|
||||
],
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
library foo;
|
||||
|
||||
main() {
|
||||
}
|
|
@ -1,710 +0,0 @@
|
|||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
// Copyright 1996 John Maloney and Mario Wolczko
|
||||
//
|
||||
// This file is part of GNU Smalltalk.
|
||||
//
|
||||
// GNU Smalltalk is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU General Public License as published by the Free
|
||||
// Software Foundation; either version 2, or (at your option) any later version.
|
||||
//
|
||||
// GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
|
||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// GNU Smalltalk; see the file COPYING. If not, write to the Free Software
|
||||
// Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// Translated first from Smalltalk to JavaScript, and finally to
|
||||
// Dart by Google 2008-2010.
|
||||
|
||||
/**
|
||||
* A Dart implementation of the DeltaBlue constraint-solving
|
||||
* algorithm, as described in:
|
||||
*
|
||||
* "The DeltaBlue Algorithm: An Incremental Constraint Hierarchy Solver"
|
||||
* Bjorn N. Freeman-Benson and John Maloney
|
||||
* January 1990 Communications of the ACM,
|
||||
* also available as University of Washington TR 89-08-06.
|
||||
*
|
||||
* Beware: this benchmark is written in a grotesque style where
|
||||
* the constraint model is built by side-effects from constructors.
|
||||
* I've kept it this way to avoid deviating too much from the original
|
||||
* implementation.
|
||||
*/
|
||||
|
||||
import "BenchmarkBase.dart";
|
||||
|
||||
main() {
|
||||
new DeltaBlue().report();
|
||||
}
|
||||
|
||||
/// Benchmark class required to report results.
|
||||
class DeltaBlue extends BenchmarkBase {
|
||||
const DeltaBlue() : super("DeltaBlue");
|
||||
|
||||
void run() {
|
||||
chainTest(100);
|
||||
projectionTest(100);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Strengths are used to measure the relative importance of constraints.
|
||||
* New strengths may be inserted in the strength hierarchy without
|
||||
* disrupting current constraints. Strengths cannot be created outside
|
||||
* this class, so == can be used for value comparison.
|
||||
*/
|
||||
class Strength {
|
||||
final int value;
|
||||
final String name;
|
||||
|
||||
const Strength(this.value, this.name);
|
||||
|
||||
Strength nextWeaker() => const <Strength>[
|
||||
STRONG_PREFERRED,
|
||||
PREFERRED,
|
||||
STRONG_DEFAULT,
|
||||
NORMAL,
|
||||
WEAK_DEFAULT,
|
||||
WEAKEST
|
||||
][value];
|
||||
|
||||
static bool stronger(Strength s1, Strength s2) {
|
||||
return s1.value < s2.value;
|
||||
}
|
||||
|
||||
static bool weaker(Strength s1, Strength s2) {
|
||||
return s1.value > s2.value;
|
||||
}
|
||||
|
||||
static Strength weakest(Strength s1, Strength s2) {
|
||||
return weaker(s1, s2) ? s1 : s2;
|
||||
}
|
||||
|
||||
static Strength strongest(Strength s1, Strength s2) {
|
||||
return stronger(s1, s2) ? s1 : s2;
|
||||
}
|
||||
}
|
||||
|
||||
// Compile time computed constants.
|
||||
const REQUIRED = const Strength(0, "required");
|
||||
const STRONG_PREFERRED = const Strength(1, "strongPreferred");
|
||||
const PREFERRED = const Strength(2, "preferred");
|
||||
const STRONG_DEFAULT = const Strength(3, "strongDefault");
|
||||
const NORMAL = const Strength(4, "normal");
|
||||
const WEAK_DEFAULT = const Strength(5, "weakDefault");
|
||||
const WEAKEST = const Strength(6, "weakest");
|
||||
|
||||
abstract class Constraint {
|
||||
final Strength strength;
|
||||
|
||||
const Constraint(this.strength);
|
||||
|
||||
bool isSatisfied();
|
||||
void markUnsatisfied();
|
||||
void addToGraph();
|
||||
void removeFromGraph();
|
||||
void chooseMethod(int mark);
|
||||
void markInputs(int mark);
|
||||
bool inputsKnown(int mark);
|
||||
Variable output();
|
||||
void execute();
|
||||
void recalculate();
|
||||
|
||||
/// Activate this constraint and attempt to satisfy it.
|
||||
void addConstraint() {
|
||||
addToGraph();
|
||||
planner.incrementalAdd(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to find a way to enforce this constraint. If successful,
|
||||
* record the solution, perhaps modifying the current dataflow
|
||||
* graph. Answer the constraint that this constraint overrides, if
|
||||
* there is one, or nil, if there isn't.
|
||||
* Assume: I am not already satisfied.
|
||||
*/
|
||||
Constraint satisfy(mark) {
|
||||
chooseMethod(mark);
|
||||
if (!isSatisfied()) {
|
||||
if (strength == REQUIRED) {
|
||||
print("Could not satisfy a required constraint!");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
markInputs(mark);
|
||||
Variable out = output();
|
||||
Constraint overridden = out.determinedBy;
|
||||
if (overridden != null) overridden.markUnsatisfied();
|
||||
out.determinedBy = this;
|
||||
if (!planner.addPropagate(this, mark)) print("Cycle encountered");
|
||||
out.mark = mark;
|
||||
return overridden;
|
||||
}
|
||||
|
||||
void destroyConstraint() {
|
||||
if (isSatisfied()) planner.incrementalRemove(this);
|
||||
removeFromGraph();
|
||||
}
|
||||
|
||||
/**
|
||||
* Normal constraints are not input constraints. An input constraint
|
||||
* is one that depends on external state, such as the mouse, the
|
||||
* keybord, a clock, or some arbitraty piece of imperative code.
|
||||
*/
|
||||
bool isInput() => false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract superclass for constraints having a single possible output variable.
|
||||
*/
|
||||
abstract class UnaryConstraint extends Constraint {
|
||||
final Variable myOutput;
|
||||
bool satisfied = false;
|
||||
|
||||
UnaryConstraint(this.myOutput, Strength strength) : super(strength) {
|
||||
addConstraint();
|
||||
}
|
||||
|
||||
/// Adds this constraint to the constraint graph
|
||||
void addToGraph() {
|
||||
myOutput.addConstraint(this);
|
||||
satisfied = false;
|
||||
}
|
||||
|
||||
/// Decides if this constraint can be satisfied and records that decision.
|
||||
void chooseMethod(int mark) {
|
||||
satisfied = (myOutput.mark != mark) &&
|
||||
Strength.stronger(strength, myOutput.walkStrength);
|
||||
}
|
||||
|
||||
/// Returns true if this constraint is satisfied in the current solution.
|
||||
bool isSatisfied() => satisfied;
|
||||
|
||||
void markInputs(int mark) {
|
||||
// has no inputs.
|
||||
}
|
||||
|
||||
/// Returns the current output variable.
|
||||
Variable output() => myOutput;
|
||||
|
||||
/**
|
||||
* Calculate the walkabout strength, the stay flag, and, if it is
|
||||
* 'stay', the value for the current output of this constraint. Assume
|
||||
* this constraint is satisfied.
|
||||
*/
|
||||
void recalculate() {
|
||||
myOutput.walkStrength = strength;
|
||||
myOutput.stay = !isInput();
|
||||
if (myOutput.stay) execute(); // Stay optimization.
|
||||
}
|
||||
|
||||
/// Records that this constraint is unsatisfied.
|
||||
void markUnsatisfied() {
|
||||
satisfied = false;
|
||||
}
|
||||
|
||||
bool inputsKnown(int mark) => true;
|
||||
|
||||
void removeFromGraph() {
|
||||
if (myOutput != null) myOutput.removeConstraint(this);
|
||||
satisfied = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Variables that should, with some level of preference, stay the same.
|
||||
* Planners may exploit the fact that instances, if satisfied, will not
|
||||
* change their output during plan execution. This is called "stay
|
||||
* optimization".
|
||||
*/
|
||||
class StayConstraint extends UnaryConstraint {
|
||||
StayConstraint(Variable v, Strength str) : super(v, str);
|
||||
|
||||
void execute() {
|
||||
// Stay constraints do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A unary input constraint used to mark a variable that the client
|
||||
* wishes to change.
|
||||
*/
|
||||
class EditConstraint extends UnaryConstraint {
|
||||
EditConstraint(Variable v, Strength str) : super(v, str);
|
||||
|
||||
/// Edits indicate that a variable is to be changed by imperative code.
|
||||
bool isInput() => true;
|
||||
|
||||
void execute() {
|
||||
// Edit constraints do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
// Directions.
|
||||
const int NONE = 1;
|
||||
const int FORWARD = 2;
|
||||
const int BACKWARD = 0;
|
||||
|
||||
/**
|
||||
* Abstract superclass for constraints having two possible output
|
||||
* variables.
|
||||
*/
|
||||
abstract class BinaryConstraint extends Constraint {
|
||||
Variable v1;
|
||||
Variable v2;
|
||||
int direction = NONE;
|
||||
|
||||
BinaryConstraint(this.v1, this.v2, Strength strength) : super(strength) {
|
||||
addConstraint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Decides if this constraint can be satisfied and which way it
|
||||
* should flow based on the relative strength of the variables related,
|
||||
* and record that decision.
|
||||
*/
|
||||
void chooseMethod(int mark) {
|
||||
if (v1.mark == mark) {
|
||||
direction = (v2.mark != mark &&
|
||||
Strength.stronger(strength, v2.walkStrength)) ? FORWARD : NONE;
|
||||
}
|
||||
if (v2.mark == mark) {
|
||||
direction = (v1.mark != mark &&
|
||||
Strength.stronger(strength, v1.walkStrength)) ? BACKWARD : NONE;
|
||||
}
|
||||
if (Strength.weaker(v1.walkStrength, v2.walkStrength)) {
|
||||
direction =
|
||||
Strength.stronger(strength, v1.walkStrength) ? BACKWARD : NONE;
|
||||
} else {
|
||||
direction =
|
||||
Strength.stronger(strength, v2.walkStrength) ? FORWARD : BACKWARD;
|
||||
}
|
||||
}
|
||||
|
||||
/// Add this constraint to the constraint graph.
|
||||
void addToGraph() {
|
||||
v1.addConstraint(this);
|
||||
v2.addConstraint(this);
|
||||
direction = NONE;
|
||||
}
|
||||
|
||||
/// Answer true if this constraint is satisfied in the current solution.
|
||||
bool isSatisfied() => direction != NONE;
|
||||
|
||||
/// Mark the input variable with the given mark.
|
||||
void markInputs(int mark) {
|
||||
input().mark = mark;
|
||||
}
|
||||
|
||||
/// Returns the current input variable
|
||||
Variable input() => direction == FORWARD ? v1 : v2;
|
||||
|
||||
/// Returns the current output variable.
|
||||
Variable output() => direction == FORWARD ? v2 : v1;
|
||||
|
||||
/**
|
||||
* Calculate the walkabout strength, the stay flag, and, if it is
|
||||
* 'stay', the value for the current output of this
|
||||
* constraint. Assume this constraint is satisfied.
|
||||
*/
|
||||
void recalculate() {
|
||||
Variable ihn = input(),
|
||||
out = output();
|
||||
out.walkStrength = Strength.weakest(strength, ihn.walkStrength);
|
||||
out.stay = ihn.stay;
|
||||
if (out.stay) execute();
|
||||
}
|
||||
|
||||
/// Record the fact that this constraint is unsatisfied.
|
||||
void markUnsatisfied() {
|
||||
direction = NONE;
|
||||
}
|
||||
|
||||
bool inputsKnown(int mark) {
|
||||
Variable i = input();
|
||||
return i.mark == mark || i.stay || i.determinedBy == null;
|
||||
}
|
||||
|
||||
void removeFromGraph() {
|
||||
if (v1 != null) v1.removeConstraint(this);
|
||||
if (v2 != null) v2.removeConstraint(this);
|
||||
direction = NONE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Relates two variables by the linear scaling relationship: "v2 =
|
||||
* (v1 * scale) + offset". Either v1 or v2 may be changed to maintain
|
||||
* this relationship but the scale factor and offset are considered
|
||||
* read-only.
|
||||
*/
|
||||
|
||||
class ScaleConstraint extends BinaryConstraint {
|
||||
final Variable scale;
|
||||
final Variable offset;
|
||||
|
||||
ScaleConstraint(
|
||||
Variable src, this.scale, this.offset, Variable dest, Strength strength)
|
||||
: super(src, dest, strength);
|
||||
|
||||
/// Adds this constraint to the constraint graph.
|
||||
void addToGraph() {
|
||||
super.addToGraph();
|
||||
scale.addConstraint(this);
|
||||
offset.addConstraint(this);
|
||||
}
|
||||
|
||||
void removeFromGraph() {
|
||||
super.removeFromGraph();
|
||||
if (scale != null) scale.removeConstraint(this);
|
||||
if (offset != null) offset.removeConstraint(this);
|
||||
}
|
||||
|
||||
void markInputs(int mark) {
|
||||
super.markInputs(mark);
|
||||
scale.mark = offset.mark = mark;
|
||||
}
|
||||
|
||||
/// Enforce this constraint. Assume that it is satisfied.
|
||||
void execute() {
|
||||
if (direction == FORWARD) {
|
||||
v2.value = v1.value * scale.value + offset.value;
|
||||
} else {
|
||||
v1.value = (v2.value - offset.value) ~/ scale.value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the walkabout strength, the stay flag, and, if it is
|
||||
* 'stay', the value for the current output of this constraint. Assume
|
||||
* this constraint is satisfied.
|
||||
*/
|
||||
void recalculate() {
|
||||
Variable ihn = input(),
|
||||
out = output();
|
||||
out.walkStrength = Strength.weakest(strength, ihn.walkStrength);
|
||||
out.stay = ihn.stay && scale.stay && offset.stay;
|
||||
if (out.stay) execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constrains two variables to have the same value.
|
||||
*/
|
||||
class EqualityConstraint extends BinaryConstraint {
|
||||
EqualityConstraint(Variable v1, Variable v2, Strength strength)
|
||||
: super(v1, v2, strength);
|
||||
|
||||
/// Enforce this constraint. Assume that it is satisfied.
|
||||
void execute() {
|
||||
output().value = input().value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A constrained variable. In addition to its value, it maintain the
|
||||
* structure of the constraint graph, the current dataflow graph, and
|
||||
* various parameters of interest to the DeltaBlue incremental
|
||||
* constraint solver.
|
||||
**/
|
||||
class Variable {
|
||||
List<Constraint> constraints = <Constraint>[];
|
||||
Constraint determinedBy;
|
||||
int mark = 0;
|
||||
Strength walkStrength = WEAKEST;
|
||||
bool stay = true;
|
||||
int value;
|
||||
final String name;
|
||||
|
||||
Variable(this.name, this.value);
|
||||
|
||||
/**
|
||||
* Add the given constraint to the set of all constraints that refer
|
||||
* this variable.
|
||||
*/
|
||||
void addConstraint(Constraint c) {
|
||||
constraints.add(c);
|
||||
}
|
||||
|
||||
/// Removes all traces of c from this variable.
|
||||
void removeConstraint(Constraint c) {
|
||||
constraints.remove(c);
|
||||
if (determinedBy == c) determinedBy = null;
|
||||
}
|
||||
}
|
||||
|
||||
class Planner {
|
||||
int currentMark = 0;
|
||||
|
||||
/**
|
||||
* Attempt to satisfy the given constraint and, if successful,
|
||||
* incrementally update the dataflow graph. Details: If satifying
|
||||
* the constraint is successful, it may override a weaker constraint
|
||||
* on its output. The algorithm attempts to resatisfy that
|
||||
* constraint using some other method. This process is repeated
|
||||
* until either a) it reaches a variable that was not previously
|
||||
* determined by any constraint or b) it reaches a constraint that
|
||||
* is too weak to be satisfied using any of its methods. The
|
||||
* variables of constraints that have been processed are marked with
|
||||
* a unique mark value so that we know where we've been. This allows
|
||||
* the algorithm to avoid getting into an infinite loop even if the
|
||||
* constraint graph has an inadvertent cycle.
|
||||
*/
|
||||
void incrementalAdd(Constraint c) {
|
||||
int mark = newMark();
|
||||
for (Constraint overridden = c.satisfy(mark);
|
||||
overridden != null;
|
||||
overridden = overridden.satisfy(mark));
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for retracting a constraint. Remove the given
|
||||
* constraint and incrementally update the dataflow graph.
|
||||
* Details: Retracting the given constraint may allow some currently
|
||||
* unsatisfiable downstream constraint to be satisfied. We therefore collect
|
||||
* a list of unsatisfied downstream constraints and attempt to
|
||||
* satisfy each one in turn. This list is traversed by constraint
|
||||
* strength, strongest first, as a heuristic for avoiding
|
||||
* unnecessarily adding and then overriding weak constraints.
|
||||
* Assume: [c] is satisfied.
|
||||
*/
|
||||
void incrementalRemove(Constraint c) {
|
||||
Variable out = c.output();
|
||||
c.markUnsatisfied();
|
||||
c.removeFromGraph();
|
||||
List<Constraint> unsatisfied = removePropagateFrom(out);
|
||||
Strength strength = REQUIRED;
|
||||
do {
|
||||
for (int i = 0; i < unsatisfied.length; i++) {
|
||||
Constraint u = unsatisfied[i];
|
||||
if (u.strength == strength) incrementalAdd(u);
|
||||
}
|
||||
strength = strength.nextWeaker();
|
||||
} while (strength != WEAKEST);
|
||||
}
|
||||
|
||||
/// Select a previously unused mark value.
|
||||
int newMark() => ++currentMark;
|
||||
|
||||
/**
|
||||
* Extract a plan for resatisfaction starting from the given source
|
||||
* constraints, usually a set of input constraints. This method
|
||||
* assumes that stay optimization is desired; the plan will contain
|
||||
* only constraints whose output variables are not stay. Constraints
|
||||
* that do no computation, such as stay and edit constraints, are
|
||||
* not included in the plan.
|
||||
* Details: The outputs of a constraint are marked when it is added
|
||||
* to the plan under construction. A constraint may be appended to
|
||||
* the plan when all its input variables are known. A variable is
|
||||
* known if either a) the variable is marked (indicating that has
|
||||
* been computed by a constraint appearing earlier in the plan), b)
|
||||
* the variable is 'stay' (i.e. it is a constant at plan execution
|
||||
* time), or c) the variable is not determined by any
|
||||
* constraint. The last provision is for past states of history
|
||||
* variables, which are not stay but which are also not computed by
|
||||
* any constraint.
|
||||
* Assume: [sources] are all satisfied.
|
||||
*/
|
||||
Plan makePlan(List<Constraint> sources) {
|
||||
int mark = newMark();
|
||||
Plan plan = new Plan();
|
||||
List<Constraint> todo = sources;
|
||||
while (todo.length > 0) {
|
||||
Constraint c = todo.removeLast();
|
||||
if (c.output().mark != mark && c.inputsKnown(mark)) {
|
||||
plan.addConstraint(c);
|
||||
c.output().mark = mark;
|
||||
addConstraintsConsumingTo(c.output(), todo);
|
||||
}
|
||||
}
|
||||
return plan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a plan for resatisfying starting from the output of the
|
||||
* given [constraints], usually a set of input constraints.
|
||||
*/
|
||||
Plan extractPlanFromConstraints(List<Constraint> constraints) {
|
||||
List<Constraint> sources = <Constraint>[];
|
||||
for (int i = 0; i < constraints.length; i++) {
|
||||
Constraint c = constraints[i];
|
||||
// if not in plan already and eligible for inclusion.
|
||||
if (c.isInput() && c.isSatisfied()) sources.add(c);
|
||||
}
|
||||
return makePlan(sources);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recompute the walkabout strengths and stay flags of all variables
|
||||
* downstream of the given constraint and recompute the actual
|
||||
* values of all variables whose stay flag is true. If a cycle is
|
||||
* detected, remove the given constraint and answer
|
||||
* false. Otherwise, answer true.
|
||||
* Details: Cycles are detected when a marked variable is
|
||||
* encountered downstream of the given constraint. The sender is
|
||||
* assumed to have marked the inputs of the given constraint with
|
||||
* the given mark. Thus, encountering a marked node downstream of
|
||||
* the output constraint means that there is a path from the
|
||||
* constraint's output to one of its inputs.
|
||||
*/
|
||||
bool addPropagate(Constraint c, int mark) {
|
||||
List<Constraint> todo = <Constraint>[c];
|
||||
while (todo.length > 0) {
|
||||
Constraint d = todo.removeLast();
|
||||
if (d.output().mark == mark) {
|
||||
incrementalRemove(c);
|
||||
return false;
|
||||
}
|
||||
d.recalculate();
|
||||
addConstraintsConsumingTo(d.output(), todo);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the walkabout strengths and stay flags of all variables
|
||||
* downstream of the given constraint. Answer a collection of
|
||||
* unsatisfied constraints sorted in order of decreasing strength.
|
||||
*/
|
||||
List<Constraint> removePropagateFrom(Variable out) {
|
||||
out.determinedBy = null;
|
||||
out.walkStrength = WEAKEST;
|
||||
out.stay = true;
|
||||
List<Constraint> unsatisfied = <Constraint>[];
|
||||
List<Variable> todo = <Variable>[out];
|
||||
while (todo.length > 0) {
|
||||
Variable v = todo.removeLast();
|
||||
for (int i = 0; i < v.constraints.length; i++) {
|
||||
Constraint c = v.constraints[i];
|
||||
if (!c.isSatisfied()) unsatisfied.add(c);
|
||||
}
|
||||
Constraint determining = v.determinedBy;
|
||||
for (int i = 0; i < v.constraints.length; i++) {
|
||||
Constraint next = v.constraints[i];
|
||||
if (next != determining && next.isSatisfied()) {
|
||||
next.recalculate();
|
||||
todo.add(next.output());
|
||||
}
|
||||
}
|
||||
}
|
||||
return unsatisfied;
|
||||
}
|
||||
|
||||
void addConstraintsConsumingTo(Variable v, List<Constraint> coll) {
|
||||
Constraint determining = v.determinedBy;
|
||||
for (int i = 0; i < v.constraints.length; i++) {
|
||||
Constraint c = v.constraints[i];
|
||||
if (c != determining && c.isSatisfied()) coll.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A Plan is an ordered list of constraints to be executed in sequence
|
||||
* to resatisfy all currently satisfiable constraints in the face of
|
||||
* one or more changing inputs.
|
||||
*/
|
||||
class Plan {
|
||||
List<Constraint> list = <Constraint>[];
|
||||
|
||||
void addConstraint(Constraint c) {
|
||||
list.add(c);
|
||||
}
|
||||
|
||||
int size() => list.length;
|
||||
|
||||
void execute() {
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
list[i].execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the standard DeltaBlue benchmark. A long chain of equality
|
||||
* constraints is constructed with a stay constraint on one end. An
|
||||
* edit constraint is then added to the opposite end and the time is
|
||||
* measured for adding and removing this constraint, and extracting
|
||||
* and executing a constraint satisfaction plan. There are two cases.
|
||||
* In case 1, the added constraint is stronger than the stay
|
||||
* constraint and values must propagate down the entire length of the
|
||||
* chain. In case 2, the added constraint is weaker than the stay
|
||||
* constraint so it cannot be accomodated. The cost in this case is,
|
||||
* of course, very low. Typical situations lie somewhere between these
|
||||
* two extremes.
|
||||
*/
|
||||
void chainTest(int n) {
|
||||
planner = new Planner();
|
||||
Variable prev = null,
|
||||
first = null,
|
||||
last = null;
|
||||
// Build chain of n equality constraints.
|
||||
for (int i = 0; i <= n; i++) {
|
||||
Variable v = new Variable("v", 0);
|
||||
if (prev != null) new EqualityConstraint(prev, v, REQUIRED);
|
||||
if (i == 0) first = v;
|
||||
if (i == n) last = v;
|
||||
prev = v;
|
||||
}
|
||||
new StayConstraint(last, STRONG_DEFAULT);
|
||||
EditConstraint edit = new EditConstraint(first, PREFERRED);
|
||||
Plan plan = planner.extractPlanFromConstraints(<Constraint>[edit]);
|
||||
for (int i = 0; i < 100; i++) {
|
||||
first.value = i;
|
||||
plan.execute();
|
||||
if (last.value != i) {
|
||||
print("Chain test failed:");
|
||||
print("Expected last value to be $i but it was ${last.value}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This test constructs a two sets of variables related to each
|
||||
* other by a simple linear transformation (scale and offset). The
|
||||
* time is measured to change a variable on either side of the
|
||||
* mapping and to change the scale and offset factors.
|
||||
*/
|
||||
void projectionTest(int n) {
|
||||
planner = new Planner();
|
||||
Variable scale = new Variable("scale", 10);
|
||||
Variable offset = new Variable("offset", 1000);
|
||||
Variable src = null,
|
||||
dst = null;
|
||||
|
||||
List<Variable> dests = <Variable>[];
|
||||
for (int i = 0; i < n; i++) {
|
||||
src = new Variable("src", i);
|
||||
dst = new Variable("dst", i);
|
||||
dests.add(dst);
|
||||
new StayConstraint(src, NORMAL);
|
||||
new ScaleConstraint(src, scale, offset, dst, REQUIRED);
|
||||
}
|
||||
change(src, 17);
|
||||
if (dst.value != 1170) print("Projection 1 failed");
|
||||
change(dst, 1050);
|
||||
if (src.value != 5) print("Projection 2 failed");
|
||||
change(scale, 5);
|
||||
for (int i = 0; i < n - 1; i++) {
|
||||
if (dests[i].value != i * 5 + 1000) print("Projection 3 failed");
|
||||
}
|
||||
change(offset, 2000);
|
||||
for (int i = 0; i < n - 1; i++) {
|
||||
if (dests[i].value != i * 5 + 2000) print("Projection 4 failed");
|
||||
}
|
||||
}
|
||||
|
||||
void change(Variable v, int newValue) {
|
||||
EditConstraint edit = new EditConstraint(v, PREFERRED);
|
||||
Plan plan = planner.extractPlanFromConstraints(<EditConstraint>[edit]);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
v.value = newValue;
|
||||
plan.execute();
|
||||
}
|
||||
edit.destroyConstraint();
|
||||
}
|
||||
|
||||
Planner planner;
|
|
@ -1,87 +0,0 @@
|
|||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class A {
|
||||
var x;
|
||||
}
|
||||
|
||||
void test_closure_with_mutate() {
|
||||
var a = new A();
|
||||
a.x = () {
|
||||
print("hi");
|
||||
a = null;
|
||||
};
|
||||
a
|
||||
..x()
|
||||
..x();
|
||||
print(a);
|
||||
}
|
||||
|
||||
void test_closure_without_mutate() {
|
||||
var a = new A();
|
||||
a.x = () {
|
||||
print(a);
|
||||
};
|
||||
a
|
||||
..x()
|
||||
..x();
|
||||
print(a);
|
||||
}
|
||||
|
||||
void test_mutate_inside_cascade() {
|
||||
var a;
|
||||
a = new A()
|
||||
..x = (a = null)
|
||||
..x = (a = null);
|
||||
print(a);
|
||||
}
|
||||
|
||||
void test_mutate_outside_cascade() {
|
||||
var a, b;
|
||||
a = new A()
|
||||
..x = (b = null)
|
||||
..x = (b = null);
|
||||
a = null;
|
||||
print(a);
|
||||
}
|
||||
|
||||
void test_VariableDeclaration_single() {
|
||||
var a = []
|
||||
..length = 2
|
||||
..add(42);
|
||||
print(a);
|
||||
}
|
||||
|
||||
void test_VariableDeclaration_last() {
|
||||
var a = 42,
|
||||
b = []
|
||||
..length = 2
|
||||
..add(a);
|
||||
print(b);
|
||||
}
|
||||
|
||||
void test_VariableDeclaration_first() {
|
||||
var a = []
|
||||
..length = 2
|
||||
..add(3),
|
||||
b = 2;
|
||||
print(a);
|
||||
}
|
||||
|
||||
void test_increment() {
|
||||
var a = new A();
|
||||
var y = a
|
||||
..x += 1
|
||||
..x -= 1;
|
||||
}
|
||||
|
||||
class Base<T> {
|
||||
final List<T> x = <T>[];
|
||||
}
|
||||
|
||||
class Foo extends Base<int> {
|
||||
void test_final_field_generic(t) {
|
||||
x..add(1)..add(2)..add(3)..add(4);
|
||||
}
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class A {}
|
||||
|
||||
class B {
|
||||
B();
|
||||
}
|
||||
|
||||
class C {
|
||||
C.named();
|
||||
}
|
||||
|
||||
class C2 extends C {
|
||||
C2.named() : super.named();
|
||||
}
|
||||
|
||||
class D {
|
||||
D();
|
||||
|
||||
D.named();
|
||||
}
|
||||
|
||||
class E {
|
||||
String name;
|
||||
|
||||
E(this.name);
|
||||
}
|
||||
|
||||
class F extends E {
|
||||
F(String name) : super(name);
|
||||
}
|
||||
|
||||
class G {
|
||||
// default parameters not implemented
|
||||
G([String p1]);
|
||||
}
|
||||
|
||||
class H {
|
||||
// default parameters not implemented
|
||||
H({String p1});
|
||||
}
|
||||
|
||||
class I {
|
||||
String name;
|
||||
|
||||
I() : name = 'default';
|
||||
|
||||
I.named(this.name);
|
||||
}
|
||||
|
||||
class J {
|
||||
num nonInitialized;
|
||||
bool initialized;
|
||||
|
||||
J() : initialized = true;
|
||||
}
|
||||
|
||||
class K {
|
||||
String s = 'a';
|
||||
|
||||
K();
|
||||
|
||||
K.withS(this.s);
|
||||
}
|
||||
|
||||
class L {
|
||||
var foo;
|
||||
L(this.foo);
|
||||
}
|
||||
|
||||
class M extends L {
|
||||
M.named(int x) : super(x + 42);
|
||||
}
|
||||
|
||||
class N extends M {
|
||||
N.named(int y) : super.named(y + 100);
|
||||
}
|
||||
|
||||
class P extends N {
|
||||
P(int z) : super.named(z + 9000);
|
||||
P.foo(int x) : this(x + 42);
|
||||
P.bar() : this.foo(1);
|
||||
}
|
||||
|
||||
class Q<T> {
|
||||
T x;
|
||||
|
||||
Q(y) : x = y;
|
||||
|
||||
static Q foo() => new Q("hello");
|
||||
|
||||
String bar() {
|
||||
var q = foo();
|
||||
return q.x;
|
||||
}
|
||||
|
||||
String bar2() {
|
||||
var q = new Q("world");
|
||||
return q.x;
|
||||
}
|
||||
|
||||
static String baz() {
|
||||
var q = new Q<int>(42);
|
||||
return q.bar() + q.bar2();
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import "../language/compiler_annotations.dart";
|
||||
|
||||
@DontInline()
|
||||
returnStringOrNull() {
|
||||
() => 42;
|
||||
return new DateTime.now().millisecondsSinceEpoch == 0 ? 'foo' : null;
|
||||
}
|
||||
|
||||
main() {
|
||||
Expect.throws(() => 'foo' + returnStringOrNull(),
|
||||
(e) => e is ArgumentError);
|
||||
Expect.throws(() => 'foo'.split(returnStringOrNull()),
|
||||
(e) => e is ArgumentError || e is NoSuchMethodError);
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class Foo<T> {
|
||||
T _t;
|
||||
add(T t) {
|
||||
_t = t;
|
||||
}
|
||||
|
||||
forEach(void fn(T t)) {
|
||||
// No check needed for `fn`
|
||||
fn(_t);
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo<int> {
|
||||
add(int x) {
|
||||
print('Bar.add got $x');
|
||||
super.add(x);
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
Foo<Object> foo = new Bar();
|
||||
foo.add('hi'); // should throw
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
dart_library.library('8invalid-chars.in+file_name', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const $8invalid$45chars$46in$43file_name = Object.create(null);
|
||||
$8invalid$45chars$46in$43file_name.main = function() {
|
||||
};
|
||||
dart.fn($8invalid$45chars$46in$43file_name.main);
|
||||
// Exports:
|
||||
exports.$8invalid$45chars$46in$43file_name = $8invalid$45chars$46in$43file_name;
|
||||
});
|
|
@ -1,95 +0,0 @@
|
|||
dart_library.library('BenchmarkBase', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const BenchmarkBase$ = Object.create(null);
|
||||
BenchmarkBase$.Expect = class Expect extends core.Object {
|
||||
static equals(expected, actual) {
|
||||
if (!dart.equals(expected, actual)) {
|
||||
dart.throw(dart.str`Values not equal: ${expected} vs ${actual}`);
|
||||
}
|
||||
}
|
||||
static listEquals(expected, actual) {
|
||||
if (expected[dartx.length] != actual[dartx.length]) {
|
||||
dart.throw(dart.str`Lists have different lengths: ${expected[dartx.length]} vs ${actual[dartx.length]}`);
|
||||
}
|
||||
for (let i = 0; i < dart.notNull(actual[dartx.length]); i++) {
|
||||
BenchmarkBase$.Expect.equals(expected[dartx.get](i), actual[dartx.get](i));
|
||||
}
|
||||
}
|
||||
fail(message) {
|
||||
dart.throw(message);
|
||||
}
|
||||
};
|
||||
dart.setSignature(BenchmarkBase$.Expect, {
|
||||
methods: () => ({fail: [dart.dynamic, [dart.dynamic]]}),
|
||||
statics: () => ({
|
||||
equals: [dart.void, [dart.dynamic, dart.dynamic]],
|
||||
listEquals: [dart.void, [core.List, core.List]]
|
||||
}),
|
||||
names: ['equals', 'listEquals']
|
||||
});
|
||||
BenchmarkBase$.BenchmarkBase = class BenchmarkBase extends core.Object {
|
||||
new(name) {
|
||||
this.name = name;
|
||||
}
|
||||
run() {}
|
||||
warmup() {
|
||||
this.run();
|
||||
}
|
||||
exercise() {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
this.run();
|
||||
}
|
||||
}
|
||||
setup() {}
|
||||
teardown() {}
|
||||
static measureFor(f, timeMinimum) {
|
||||
let time = 0;
|
||||
let iter = 0;
|
||||
let watch = new core.Stopwatch();
|
||||
watch.start();
|
||||
let elapsed = 0;
|
||||
while (dart.notNull(elapsed) < dart.notNull(timeMinimum)) {
|
||||
dart.dcall(f);
|
||||
elapsed = watch.elapsedMilliseconds;
|
||||
iter++;
|
||||
}
|
||||
return 1000.0 * dart.notNull(elapsed) / iter;
|
||||
}
|
||||
measure() {
|
||||
this.setup();
|
||||
BenchmarkBase$.BenchmarkBase.measureFor(dart.fn(() => {
|
||||
this.warmup();
|
||||
}), 100);
|
||||
let result = BenchmarkBase$.BenchmarkBase.measureFor(dart.fn(() => {
|
||||
this.exercise();
|
||||
}), 2000);
|
||||
this.teardown();
|
||||
return result;
|
||||
}
|
||||
report() {
|
||||
let score = this.measure();
|
||||
core.print(dart.str`${this.name}(RunTime): ${score} us.`);
|
||||
}
|
||||
};
|
||||
dart.setSignature(BenchmarkBase$.BenchmarkBase, {
|
||||
constructors: () => ({new: [BenchmarkBase$.BenchmarkBase, [core.String]]}),
|
||||
methods: () => ({
|
||||
run: [dart.void, []],
|
||||
warmup: [dart.void, []],
|
||||
exercise: [dart.void, []],
|
||||
setup: [dart.void, []],
|
||||
teardown: [dart.void, []],
|
||||
measure: [core.double, []],
|
||||
report: [dart.void, []]
|
||||
}),
|
||||
statics: () => ({measureFor: [core.double, [core.Function, core.int]]}),
|
||||
names: ['measureFor']
|
||||
});
|
||||
// Exports:
|
||||
exports.BenchmarkBase = BenchmarkBase$;
|
||||
});
|
|
@ -1,607 +0,0 @@
|
|||
dart_library.library('DeltaBlue', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const DeltaBlue$ = Object.create(null);
|
||||
const BenchmarkBase$ = Object.create(null);
|
||||
DeltaBlue$.main = function() {
|
||||
new DeltaBlue$.DeltaBlue().report();
|
||||
};
|
||||
dart.fn(DeltaBlue$.main);
|
||||
BenchmarkBase$.BenchmarkBase = class BenchmarkBase extends core.Object {
|
||||
new(name) {
|
||||
this.name = name;
|
||||
}
|
||||
run() {}
|
||||
warmup() {
|
||||
this.run();
|
||||
}
|
||||
exercise() {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
this.run();
|
||||
}
|
||||
}
|
||||
setup() {}
|
||||
teardown() {}
|
||||
static measureFor(f, timeMinimum) {
|
||||
let time = 0;
|
||||
let iter = 0;
|
||||
let watch = new core.Stopwatch();
|
||||
watch.start();
|
||||
let elapsed = 0;
|
||||
while (dart.notNull(elapsed) < dart.notNull(timeMinimum)) {
|
||||
dart.dcall(f);
|
||||
elapsed = watch.elapsedMilliseconds;
|
||||
iter++;
|
||||
}
|
||||
return 1000.0 * dart.notNull(elapsed) / iter;
|
||||
}
|
||||
measure() {
|
||||
this.setup();
|
||||
BenchmarkBase$.BenchmarkBase.measureFor(dart.fn(() => {
|
||||
this.warmup();
|
||||
}), 100);
|
||||
let result = BenchmarkBase$.BenchmarkBase.measureFor(dart.fn(() => {
|
||||
this.exercise();
|
||||
}), 2000);
|
||||
this.teardown();
|
||||
return result;
|
||||
}
|
||||
report() {
|
||||
let score = this.measure();
|
||||
core.print(dart.str`${this.name}(RunTime): ${score} us.`);
|
||||
}
|
||||
};
|
||||
dart.setSignature(BenchmarkBase$.BenchmarkBase, {
|
||||
constructors: () => ({new: [BenchmarkBase$.BenchmarkBase, [core.String]]}),
|
||||
methods: () => ({
|
||||
run: [dart.void, []],
|
||||
warmup: [dart.void, []],
|
||||
exercise: [dart.void, []],
|
||||
setup: [dart.void, []],
|
||||
teardown: [dart.void, []],
|
||||
measure: [core.double, []],
|
||||
report: [dart.void, []]
|
||||
}),
|
||||
statics: () => ({measureFor: [core.double, [core.Function, core.int]]}),
|
||||
names: ['measureFor']
|
||||
});
|
||||
DeltaBlue$.DeltaBlue = class DeltaBlue extends BenchmarkBase$.BenchmarkBase {
|
||||
new() {
|
||||
super.new("DeltaBlue");
|
||||
}
|
||||
run() {
|
||||
DeltaBlue$.chainTest(100);
|
||||
DeltaBlue$.projectionTest(100);
|
||||
}
|
||||
};
|
||||
dart.setSignature(DeltaBlue$.DeltaBlue, {
|
||||
constructors: () => ({new: [DeltaBlue$.DeltaBlue, []]})
|
||||
});
|
||||
let const$;
|
||||
DeltaBlue$.Strength = class Strength extends core.Object {
|
||||
new(value, name) {
|
||||
this.value = value;
|
||||
this.name = name;
|
||||
}
|
||||
nextWeaker() {
|
||||
return (const$ || (const$ = dart.const(dart.list([DeltaBlue$.STRONG_PREFERRED, DeltaBlue$.PREFERRED, DeltaBlue$.STRONG_DEFAULT, DeltaBlue$.NORMAL, DeltaBlue$.WEAK_DEFAULT, DeltaBlue$.WEAKEST], DeltaBlue$.Strength))))[dartx.get](this.value);
|
||||
}
|
||||
static stronger(s1, s2) {
|
||||
return dart.notNull(s1.value) < dart.notNull(s2.value);
|
||||
}
|
||||
static weaker(s1, s2) {
|
||||
return dart.notNull(s1.value) > dart.notNull(s2.value);
|
||||
}
|
||||
static weakest(s1, s2) {
|
||||
return dart.notNull(DeltaBlue$.Strength.weaker(s1, s2)) ? s1 : s2;
|
||||
}
|
||||
static strongest(s1, s2) {
|
||||
return dart.notNull(DeltaBlue$.Strength.stronger(s1, s2)) ? s1 : s2;
|
||||
}
|
||||
};
|
||||
dart.setSignature(DeltaBlue$.Strength, {
|
||||
constructors: () => ({new: [DeltaBlue$.Strength, [core.int, core.String]]}),
|
||||
methods: () => ({nextWeaker: [DeltaBlue$.Strength, []]}),
|
||||
statics: () => ({
|
||||
stronger: [core.bool, [DeltaBlue$.Strength, DeltaBlue$.Strength]],
|
||||
weaker: [core.bool, [DeltaBlue$.Strength, DeltaBlue$.Strength]],
|
||||
weakest: [DeltaBlue$.Strength, [DeltaBlue$.Strength, DeltaBlue$.Strength]],
|
||||
strongest: [DeltaBlue$.Strength, [DeltaBlue$.Strength, DeltaBlue$.Strength]]
|
||||
}),
|
||||
names: ['stronger', 'weaker', 'weakest', 'strongest']
|
||||
});
|
||||
DeltaBlue$.REQUIRED = dart.const(new DeltaBlue$.Strength(0, "required"));
|
||||
DeltaBlue$.STRONG_PREFERRED = dart.const(new DeltaBlue$.Strength(1, "strongPreferred"));
|
||||
DeltaBlue$.PREFERRED = dart.const(new DeltaBlue$.Strength(2, "preferred"));
|
||||
DeltaBlue$.STRONG_DEFAULT = dart.const(new DeltaBlue$.Strength(3, "strongDefault"));
|
||||
DeltaBlue$.NORMAL = dart.const(new DeltaBlue$.Strength(4, "normal"));
|
||||
DeltaBlue$.WEAK_DEFAULT = dart.const(new DeltaBlue$.Strength(5, "weakDefault"));
|
||||
DeltaBlue$.WEAKEST = dart.const(new DeltaBlue$.Strength(6, "weakest"));
|
||||
DeltaBlue$.Constraint = class Constraint extends core.Object {
|
||||
new(strength) {
|
||||
this.strength = strength;
|
||||
}
|
||||
addConstraint() {
|
||||
this.addToGraph();
|
||||
DeltaBlue$.planner.incrementalAdd(this);
|
||||
}
|
||||
satisfy(mark) {
|
||||
this.chooseMethod(dart.as(mark, core.int));
|
||||
if (!dart.notNull(this.isSatisfied())) {
|
||||
if (dart.equals(this.strength, DeltaBlue$.REQUIRED)) {
|
||||
core.print("Could not satisfy a required constraint!");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
this.markInputs(dart.as(mark, core.int));
|
||||
let out = this.output();
|
||||
let overridden = out.determinedBy;
|
||||
if (overridden != null) overridden.markUnsatisfied();
|
||||
out.determinedBy = this;
|
||||
if (!dart.notNull(DeltaBlue$.planner.addPropagate(this, dart.as(mark, core.int)))) core.print("Cycle encountered");
|
||||
out.mark = dart.as(mark, core.int);
|
||||
return overridden;
|
||||
}
|
||||
destroyConstraint() {
|
||||
if (dart.notNull(this.isSatisfied())) DeltaBlue$.planner.incrementalRemove(this);
|
||||
this.removeFromGraph();
|
||||
}
|
||||
isInput() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
dart.setSignature(DeltaBlue$.Constraint, {
|
||||
constructors: () => ({new: [DeltaBlue$.Constraint, [DeltaBlue$.Strength]]}),
|
||||
methods: () => ({
|
||||
addConstraint: [dart.void, []],
|
||||
satisfy: [DeltaBlue$.Constraint, [dart.dynamic]],
|
||||
destroyConstraint: [dart.void, []],
|
||||
isInput: [core.bool, []]
|
||||
})
|
||||
});
|
||||
DeltaBlue$.UnaryConstraint = class UnaryConstraint extends DeltaBlue$.Constraint {
|
||||
new(myOutput, strength) {
|
||||
this.myOutput = myOutput;
|
||||
this.satisfied = false;
|
||||
super.new(strength);
|
||||
this.addConstraint();
|
||||
}
|
||||
addToGraph() {
|
||||
this.myOutput.addConstraint(this);
|
||||
this.satisfied = false;
|
||||
}
|
||||
chooseMethod(mark) {
|
||||
this.satisfied = this.myOutput.mark != mark && dart.notNull(DeltaBlue$.Strength.stronger(this.strength, this.myOutput.walkStrength));
|
||||
}
|
||||
isSatisfied() {
|
||||
return this.satisfied;
|
||||
}
|
||||
markInputs(mark) {}
|
||||
output() {
|
||||
return this.myOutput;
|
||||
}
|
||||
recalculate() {
|
||||
this.myOutput.walkStrength = this.strength;
|
||||
this.myOutput.stay = !dart.notNull(this.isInput());
|
||||
if (dart.notNull(this.myOutput.stay)) this.execute();
|
||||
}
|
||||
markUnsatisfied() {
|
||||
this.satisfied = false;
|
||||
}
|
||||
inputsKnown(mark) {
|
||||
return true;
|
||||
}
|
||||
removeFromGraph() {
|
||||
if (this.myOutput != null) this.myOutput.removeConstraint(this);
|
||||
this.satisfied = false;
|
||||
}
|
||||
};
|
||||
dart.setSignature(DeltaBlue$.UnaryConstraint, {
|
||||
constructors: () => ({new: [DeltaBlue$.UnaryConstraint, [DeltaBlue$.Variable, DeltaBlue$.Strength]]}),
|
||||
methods: () => ({
|
||||
addToGraph: [dart.void, []],
|
||||
chooseMethod: [dart.void, [core.int]],
|
||||
isSatisfied: [core.bool, []],
|
||||
markInputs: [dart.void, [core.int]],
|
||||
output: [DeltaBlue$.Variable, []],
|
||||
recalculate: [dart.void, []],
|
||||
markUnsatisfied: [dart.void, []],
|
||||
inputsKnown: [core.bool, [core.int]],
|
||||
removeFromGraph: [dart.void, []]
|
||||
})
|
||||
});
|
||||
DeltaBlue$.StayConstraint = class StayConstraint extends DeltaBlue$.UnaryConstraint {
|
||||
new(v, str) {
|
||||
super.new(v, str);
|
||||
}
|
||||
execute() {}
|
||||
};
|
||||
dart.setSignature(DeltaBlue$.StayConstraint, {
|
||||
constructors: () => ({new: [DeltaBlue$.StayConstraint, [DeltaBlue$.Variable, DeltaBlue$.Strength]]}),
|
||||
methods: () => ({execute: [dart.void, []]})
|
||||
});
|
||||
DeltaBlue$.EditConstraint = class EditConstraint extends DeltaBlue$.UnaryConstraint {
|
||||
new(v, str) {
|
||||
super.new(v, str);
|
||||
}
|
||||
isInput() {
|
||||
return true;
|
||||
}
|
||||
execute() {}
|
||||
};
|
||||
dart.setSignature(DeltaBlue$.EditConstraint, {
|
||||
constructors: () => ({new: [DeltaBlue$.EditConstraint, [DeltaBlue$.Variable, DeltaBlue$.Strength]]}),
|
||||
methods: () => ({execute: [dart.void, []]})
|
||||
});
|
||||
DeltaBlue$.NONE = 1;
|
||||
DeltaBlue$.FORWARD = 2;
|
||||
DeltaBlue$.BACKWARD = 0;
|
||||
DeltaBlue$.BinaryConstraint = class BinaryConstraint extends DeltaBlue$.Constraint {
|
||||
new(v1, v2, strength) {
|
||||
this.v1 = v1;
|
||||
this.v2 = v2;
|
||||
this.direction = DeltaBlue$.NONE;
|
||||
super.new(strength);
|
||||
this.addConstraint();
|
||||
}
|
||||
chooseMethod(mark) {
|
||||
if (this.v1.mark == mark) {
|
||||
this.direction = this.v2.mark != mark && dart.notNull(DeltaBlue$.Strength.stronger(this.strength, this.v2.walkStrength)) ? DeltaBlue$.FORWARD : DeltaBlue$.NONE;
|
||||
}
|
||||
if (this.v2.mark == mark) {
|
||||
this.direction = this.v1.mark != mark && dart.notNull(DeltaBlue$.Strength.stronger(this.strength, this.v1.walkStrength)) ? DeltaBlue$.BACKWARD : DeltaBlue$.NONE;
|
||||
}
|
||||
if (dart.notNull(DeltaBlue$.Strength.weaker(this.v1.walkStrength, this.v2.walkStrength))) {
|
||||
this.direction = dart.notNull(DeltaBlue$.Strength.stronger(this.strength, this.v1.walkStrength)) ? DeltaBlue$.BACKWARD : DeltaBlue$.NONE;
|
||||
} else {
|
||||
this.direction = dart.notNull(DeltaBlue$.Strength.stronger(this.strength, this.v2.walkStrength)) ? DeltaBlue$.FORWARD : DeltaBlue$.BACKWARD;
|
||||
}
|
||||
}
|
||||
addToGraph() {
|
||||
this.v1.addConstraint(this);
|
||||
this.v2.addConstraint(this);
|
||||
this.direction = DeltaBlue$.NONE;
|
||||
}
|
||||
isSatisfied() {
|
||||
return this.direction != DeltaBlue$.NONE;
|
||||
}
|
||||
markInputs(mark) {
|
||||
this.input().mark = mark;
|
||||
}
|
||||
input() {
|
||||
return this.direction == DeltaBlue$.FORWARD ? this.v1 : this.v2;
|
||||
}
|
||||
output() {
|
||||
return this.direction == DeltaBlue$.FORWARD ? this.v2 : this.v1;
|
||||
}
|
||||
recalculate() {
|
||||
let ihn = this.input(), out = this.output();
|
||||
out.walkStrength = DeltaBlue$.Strength.weakest(this.strength, ihn.walkStrength);
|
||||
out.stay = ihn.stay;
|
||||
if (dart.notNull(out.stay)) this.execute();
|
||||
}
|
||||
markUnsatisfied() {
|
||||
this.direction = DeltaBlue$.NONE;
|
||||
}
|
||||
inputsKnown(mark) {
|
||||
let i = this.input();
|
||||
return i.mark == mark || dart.notNull(i.stay) || i.determinedBy == null;
|
||||
}
|
||||
removeFromGraph() {
|
||||
if (this.v1 != null) this.v1.removeConstraint(this);
|
||||
if (this.v2 != null) this.v2.removeConstraint(this);
|
||||
this.direction = DeltaBlue$.NONE;
|
||||
}
|
||||
};
|
||||
dart.setSignature(DeltaBlue$.BinaryConstraint, {
|
||||
constructors: () => ({new: [DeltaBlue$.BinaryConstraint, [DeltaBlue$.Variable, DeltaBlue$.Variable, DeltaBlue$.Strength]]}),
|
||||
methods: () => ({
|
||||
chooseMethod: [dart.void, [core.int]],
|
||||
addToGraph: [dart.void, []],
|
||||
isSatisfied: [core.bool, []],
|
||||
markInputs: [dart.void, [core.int]],
|
||||
input: [DeltaBlue$.Variable, []],
|
||||
output: [DeltaBlue$.Variable, []],
|
||||
recalculate: [dart.void, []],
|
||||
markUnsatisfied: [dart.void, []],
|
||||
inputsKnown: [core.bool, [core.int]],
|
||||
removeFromGraph: [dart.void, []]
|
||||
})
|
||||
});
|
||||
DeltaBlue$.ScaleConstraint = class ScaleConstraint extends DeltaBlue$.BinaryConstraint {
|
||||
new(src, scale, offset, dest, strength) {
|
||||
this.scale = scale;
|
||||
this.offset = offset;
|
||||
super.new(src, dest, strength);
|
||||
}
|
||||
addToGraph() {
|
||||
super.addToGraph();
|
||||
this.scale.addConstraint(this);
|
||||
this.offset.addConstraint(this);
|
||||
}
|
||||
removeFromGraph() {
|
||||
super.removeFromGraph();
|
||||
if (this.scale != null) this.scale.removeConstraint(this);
|
||||
if (this.offset != null) this.offset.removeConstraint(this);
|
||||
}
|
||||
markInputs(mark) {
|
||||
super.markInputs(mark);
|
||||
this.scale.mark = this.offset.mark = mark;
|
||||
}
|
||||
execute() {
|
||||
if (this.direction == DeltaBlue$.FORWARD) {
|
||||
this.v2.value = dart.notNull(this.v1.value) * dart.notNull(this.scale.value) + dart.notNull(this.offset.value);
|
||||
} else {
|
||||
this.v1.value = ((dart.notNull(this.v2.value) - dart.notNull(this.offset.value)) / dart.notNull(this.scale.value))[dartx.truncate]();
|
||||
}
|
||||
}
|
||||
recalculate() {
|
||||
let ihn = this.input(), out = this.output();
|
||||
out.walkStrength = DeltaBlue$.Strength.weakest(this.strength, ihn.walkStrength);
|
||||
out.stay = dart.notNull(ihn.stay) && dart.notNull(this.scale.stay) && dart.notNull(this.offset.stay);
|
||||
if (dart.notNull(out.stay)) this.execute();
|
||||
}
|
||||
};
|
||||
dart.setSignature(DeltaBlue$.ScaleConstraint, {
|
||||
constructors: () => ({new: [DeltaBlue$.ScaleConstraint, [DeltaBlue$.Variable, DeltaBlue$.Variable, DeltaBlue$.Variable, DeltaBlue$.Variable, DeltaBlue$.Strength]]}),
|
||||
methods: () => ({execute: [dart.void, []]})
|
||||
});
|
||||
DeltaBlue$.EqualityConstraint = class EqualityConstraint extends DeltaBlue$.BinaryConstraint {
|
||||
new(v1, v2, strength) {
|
||||
super.new(v1, v2, strength);
|
||||
}
|
||||
execute() {
|
||||
this.output().value = this.input().value;
|
||||
}
|
||||
};
|
||||
dart.setSignature(DeltaBlue$.EqualityConstraint, {
|
||||
constructors: () => ({new: [DeltaBlue$.EqualityConstraint, [DeltaBlue$.Variable, DeltaBlue$.Variable, DeltaBlue$.Strength]]}),
|
||||
methods: () => ({execute: [dart.void, []]})
|
||||
});
|
||||
DeltaBlue$.Variable = class Variable extends core.Object {
|
||||
new(name, value) {
|
||||
this.constraints = dart.list([], DeltaBlue$.Constraint);
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.determinedBy = null;
|
||||
this.mark = 0;
|
||||
this.walkStrength = DeltaBlue$.WEAKEST;
|
||||
this.stay = true;
|
||||
}
|
||||
addConstraint(c) {
|
||||
this.constraints[dartx.add](c);
|
||||
}
|
||||
removeConstraint(c) {
|
||||
this.constraints[dartx.remove](c);
|
||||
if (dart.equals(this.determinedBy, c)) this.determinedBy = null;
|
||||
}
|
||||
};
|
||||
dart.setSignature(DeltaBlue$.Variable, {
|
||||
constructors: () => ({new: [DeltaBlue$.Variable, [core.String, core.int]]}),
|
||||
methods: () => ({
|
||||
addConstraint: [dart.void, [DeltaBlue$.Constraint]],
|
||||
removeConstraint: [dart.void, [DeltaBlue$.Constraint]]
|
||||
})
|
||||
});
|
||||
DeltaBlue$.Planner = class Planner extends core.Object {
|
||||
new() {
|
||||
this.currentMark = 0;
|
||||
}
|
||||
incrementalAdd(c) {
|
||||
let mark = this.newMark();
|
||||
for (let overridden = c.satisfy(mark); overridden != null; overridden = overridden.satisfy(mark))
|
||||
;
|
||||
}
|
||||
incrementalRemove(c) {
|
||||
let out = c.output();
|
||||
c.markUnsatisfied();
|
||||
c.removeFromGraph();
|
||||
let unsatisfied = this.removePropagateFrom(out);
|
||||
let strength = DeltaBlue$.REQUIRED;
|
||||
do {
|
||||
for (let i = 0; i < dart.notNull(unsatisfied[dartx.length]); i++) {
|
||||
let u = unsatisfied[dartx.get](i);
|
||||
if (dart.equals(u.strength, strength)) this.incrementalAdd(u);
|
||||
}
|
||||
strength = strength.nextWeaker();
|
||||
} while (!dart.equals(strength, DeltaBlue$.WEAKEST));
|
||||
}
|
||||
newMark() {
|
||||
return this.currentMark = dart.notNull(this.currentMark) + 1;
|
||||
}
|
||||
makePlan(sources) {
|
||||
let mark = this.newMark();
|
||||
let plan = new DeltaBlue$.Plan();
|
||||
let todo = sources;
|
||||
while (dart.notNull(todo[dartx.length]) > 0) {
|
||||
let c = todo[dartx.removeLast]();
|
||||
if (c.output().mark != mark && dart.notNull(c.inputsKnown(mark))) {
|
||||
plan.addConstraint(c);
|
||||
c.output().mark = mark;
|
||||
this.addConstraintsConsumingTo(c.output(), todo);
|
||||
}
|
||||
}
|
||||
return plan;
|
||||
}
|
||||
extractPlanFromConstraints(constraints) {
|
||||
let sources = dart.list([], DeltaBlue$.Constraint);
|
||||
for (let i = 0; i < dart.notNull(constraints[dartx.length]); i++) {
|
||||
let c = constraints[dartx.get](i);
|
||||
if (dart.notNull(c.isInput()) && dart.notNull(c.isSatisfied())) sources[dartx.add](c);
|
||||
}
|
||||
return this.makePlan(sources);
|
||||
}
|
||||
addPropagate(c, mark) {
|
||||
let todo = dart.list([c], DeltaBlue$.Constraint);
|
||||
while (dart.notNull(todo[dartx.length]) > 0) {
|
||||
let d = todo[dartx.removeLast]();
|
||||
if (d.output().mark == mark) {
|
||||
this.incrementalRemove(c);
|
||||
return false;
|
||||
}
|
||||
d.recalculate();
|
||||
this.addConstraintsConsumingTo(d.output(), todo);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
removePropagateFrom(out) {
|
||||
out.determinedBy = null;
|
||||
out.walkStrength = DeltaBlue$.WEAKEST;
|
||||
out.stay = true;
|
||||
let unsatisfied = dart.list([], DeltaBlue$.Constraint);
|
||||
let todo = dart.list([out], DeltaBlue$.Variable);
|
||||
while (dart.notNull(todo[dartx.length]) > 0) {
|
||||
let v = todo[dartx.removeLast]();
|
||||
for (let i = 0; i < dart.notNull(v.constraints[dartx.length]); i++) {
|
||||
let c = v.constraints[dartx.get](i);
|
||||
if (!dart.notNull(c.isSatisfied())) unsatisfied[dartx.add](c);
|
||||
}
|
||||
let determining = v.determinedBy;
|
||||
for (let i = 0; i < dart.notNull(v.constraints[dartx.length]); i++) {
|
||||
let next = v.constraints[dartx.get](i);
|
||||
if (!dart.equals(next, determining) && dart.notNull(next.isSatisfied())) {
|
||||
next.recalculate();
|
||||
todo[dartx.add](next.output());
|
||||
}
|
||||
}
|
||||
}
|
||||
return unsatisfied;
|
||||
}
|
||||
addConstraintsConsumingTo(v, coll) {
|
||||
let determining = v.determinedBy;
|
||||
for (let i = 0; i < dart.notNull(v.constraints[dartx.length]); i++) {
|
||||
let c = v.constraints[dartx.get](i);
|
||||
if (!dart.equals(c, determining) && dart.notNull(c.isSatisfied())) coll[dartx.add](c);
|
||||
}
|
||||
}
|
||||
};
|
||||
dart.setSignature(DeltaBlue$.Planner, {
|
||||
methods: () => ({
|
||||
incrementalAdd: [dart.void, [DeltaBlue$.Constraint]],
|
||||
incrementalRemove: [dart.void, [DeltaBlue$.Constraint]],
|
||||
newMark: [core.int, []],
|
||||
makePlan: [DeltaBlue$.Plan, [core.List$(DeltaBlue$.Constraint)]],
|
||||
extractPlanFromConstraints: [DeltaBlue$.Plan, [core.List$(DeltaBlue$.Constraint)]],
|
||||
addPropagate: [core.bool, [DeltaBlue$.Constraint, core.int]],
|
||||
removePropagateFrom: [core.List$(DeltaBlue$.Constraint), [DeltaBlue$.Variable]],
|
||||
addConstraintsConsumingTo: [dart.void, [DeltaBlue$.Variable, core.List$(DeltaBlue$.Constraint)]]
|
||||
})
|
||||
});
|
||||
DeltaBlue$.Plan = class Plan extends core.Object {
|
||||
new() {
|
||||
this.list = dart.list([], DeltaBlue$.Constraint);
|
||||
}
|
||||
addConstraint(c) {
|
||||
this.list[dartx.add](c);
|
||||
}
|
||||
size() {
|
||||
return this.list[dartx.length];
|
||||
}
|
||||
execute() {
|
||||
for (let i = 0; i < dart.notNull(this.list[dartx.length]); i++) {
|
||||
this.list[dartx.get](i).execute();
|
||||
}
|
||||
}
|
||||
};
|
||||
dart.setSignature(DeltaBlue$.Plan, {
|
||||
methods: () => ({
|
||||
addConstraint: [dart.void, [DeltaBlue$.Constraint]],
|
||||
size: [core.int, []],
|
||||
execute: [dart.void, []]
|
||||
})
|
||||
});
|
||||
DeltaBlue$.chainTest = function(n) {
|
||||
DeltaBlue$.planner = new DeltaBlue$.Planner();
|
||||
let prev = null, first = null, last = null;
|
||||
for (let i = 0; i <= dart.notNull(n); i++) {
|
||||
let v = new DeltaBlue$.Variable("v", 0);
|
||||
if (prev != null) new DeltaBlue$.EqualityConstraint(prev, v, DeltaBlue$.REQUIRED);
|
||||
if (i == 0) first = v;
|
||||
if (i == n) last = v;
|
||||
prev = v;
|
||||
}
|
||||
new DeltaBlue$.StayConstraint(last, DeltaBlue$.STRONG_DEFAULT);
|
||||
let edit = new DeltaBlue$.EditConstraint(first, DeltaBlue$.PREFERRED);
|
||||
let plan = DeltaBlue$.planner.extractPlanFromConstraints(dart.list([edit], DeltaBlue$.Constraint));
|
||||
for (let i = 0; i < 100; i++) {
|
||||
first.value = i;
|
||||
plan.execute();
|
||||
if (last.value != i) {
|
||||
core.print("Chain test failed:");
|
||||
core.print(dart.str`Expected last value to be ${i} but it was ${last.value}.`);
|
||||
}
|
||||
}
|
||||
};
|
||||
dart.fn(DeltaBlue$.chainTest, dart.void, [core.int]);
|
||||
DeltaBlue$.projectionTest = function(n) {
|
||||
DeltaBlue$.planner = new DeltaBlue$.Planner();
|
||||
let scale = new DeltaBlue$.Variable("scale", 10);
|
||||
let offset = new DeltaBlue$.Variable("offset", 1000);
|
||||
let src = null, dst = null;
|
||||
let dests = dart.list([], DeltaBlue$.Variable);
|
||||
for (let i = 0; i < dart.notNull(n); i++) {
|
||||
src = new DeltaBlue$.Variable("src", i);
|
||||
dst = new DeltaBlue$.Variable("dst", i);
|
||||
dests[dartx.add](dst);
|
||||
new DeltaBlue$.StayConstraint(src, DeltaBlue$.NORMAL);
|
||||
new DeltaBlue$.ScaleConstraint(src, scale, offset, dst, DeltaBlue$.REQUIRED);
|
||||
}
|
||||
DeltaBlue$.change(src, 17);
|
||||
if (dst.value != 1170) core.print("Projection 1 failed");
|
||||
DeltaBlue$.change(dst, 1050);
|
||||
if (src.value != 5) core.print("Projection 2 failed");
|
||||
DeltaBlue$.change(scale, 5);
|
||||
for (let i = 0; i < dart.notNull(n) - 1; i++) {
|
||||
if (dests[dartx.get](i).value != i * 5 + 1000) core.print("Projection 3 failed");
|
||||
}
|
||||
DeltaBlue$.change(offset, 2000);
|
||||
for (let i = 0; i < dart.notNull(n) - 1; i++) {
|
||||
if (dests[dartx.get](i).value != i * 5 + 2000) core.print("Projection 4 failed");
|
||||
}
|
||||
};
|
||||
dart.fn(DeltaBlue$.projectionTest, dart.void, [core.int]);
|
||||
DeltaBlue$.change = function(v, newValue) {
|
||||
let edit = new DeltaBlue$.EditConstraint(v, DeltaBlue$.PREFERRED);
|
||||
let plan = DeltaBlue$.planner.extractPlanFromConstraints(dart.list([edit], DeltaBlue$.EditConstraint));
|
||||
for (let i = 0; i < 10; i++) {
|
||||
v.value = newValue;
|
||||
plan.execute();
|
||||
}
|
||||
edit.destroyConstraint();
|
||||
};
|
||||
dart.fn(DeltaBlue$.change, dart.void, [DeltaBlue$.Variable, core.int]);
|
||||
DeltaBlue$.planner = null;
|
||||
BenchmarkBase$.Expect = class Expect extends core.Object {
|
||||
static equals(expected, actual) {
|
||||
if (!dart.equals(expected, actual)) {
|
||||
dart.throw(dart.str`Values not equal: ${expected} vs ${actual}`);
|
||||
}
|
||||
}
|
||||
static listEquals(expected, actual) {
|
||||
if (expected[dartx.length] != actual[dartx.length]) {
|
||||
dart.throw(dart.str`Lists have different lengths: ${expected[dartx.length]} vs ${actual[dartx.length]}`);
|
||||
}
|
||||
for (let i = 0; i < dart.notNull(actual[dartx.length]); i++) {
|
||||
BenchmarkBase$.Expect.equals(expected[dartx.get](i), actual[dartx.get](i));
|
||||
}
|
||||
}
|
||||
fail(message) {
|
||||
dart.throw(message);
|
||||
}
|
||||
};
|
||||
dart.setSignature(BenchmarkBase$.Expect, {
|
||||
methods: () => ({fail: [dart.dynamic, [dart.dynamic]]}),
|
||||
statics: () => ({
|
||||
equals: [dart.void, [dart.dynamic, dart.dynamic]],
|
||||
listEquals: [dart.void, [core.List, core.List]]
|
||||
}),
|
||||
names: ['equals', 'listEquals']
|
||||
});
|
||||
// Exports:
|
||||
exports.DeltaBlue = DeltaBlue$;
|
||||
exports.BenchmarkBase = BenchmarkBase$;
|
||||
});
|
|
@ -1,70 +0,0 @@
|
|||
dart_library.library('async_helper', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const async_helper = Object.create(null);
|
||||
async_helper._initialized = false;
|
||||
async_helper._Action0 = dart.typedef('_Action0', () => dart.functionType(dart.void, []));
|
||||
async_helper._onAsyncEnd = null;
|
||||
async_helper._asyncLevel = 0;
|
||||
async_helper._buildException = function(msg) {
|
||||
return core.Exception.new(dart.str`Fatal: ${msg}. This is most likely a bug in your test.`);
|
||||
};
|
||||
dart.fn(async_helper._buildException, core.Exception, [core.String]);
|
||||
async_helper.asyncTestInitialize = function(callback) {
|
||||
async_helper._asyncLevel = 0;
|
||||
async_helper._initialized = false;
|
||||
async_helper._onAsyncEnd = callback;
|
||||
};
|
||||
dart.fn(async_helper.asyncTestInitialize, dart.void, [async_helper._Action0]);
|
||||
dart.copyProperties(async_helper, {
|
||||
get asyncTestStarted() {
|
||||
return async_helper._initialized;
|
||||
}
|
||||
});
|
||||
async_helper.asyncStart = function() {
|
||||
if (dart.notNull(async_helper._initialized) && async_helper._asyncLevel == 0) {
|
||||
dart.throw(async_helper._buildException('asyncStart() was called even though we are done ' + 'with testing.'));
|
||||
}
|
||||
if (!dart.notNull(async_helper._initialized)) {
|
||||
if (async_helper._onAsyncEnd == null) {
|
||||
dart.throw(async_helper._buildException('asyncStart() was called before asyncTestInitialize()'));
|
||||
}
|
||||
core.print('unittest-suite-wait-for-done');
|
||||
async_helper._initialized = true;
|
||||
}
|
||||
async_helper._asyncLevel = dart.notNull(async_helper._asyncLevel) + 1;
|
||||
};
|
||||
dart.fn(async_helper.asyncStart, dart.void, []);
|
||||
async_helper.asyncEnd = function() {
|
||||
if (dart.notNull(async_helper._asyncLevel) <= 0) {
|
||||
if (!dart.notNull(async_helper._initialized)) {
|
||||
dart.throw(async_helper._buildException('asyncEnd() was called before asyncStart().'));
|
||||
} else {
|
||||
dart.throw(async_helper._buildException('asyncEnd() was called more often than ' + 'asyncStart().'));
|
||||
}
|
||||
}
|
||||
async_helper._asyncLevel = dart.notNull(async_helper._asyncLevel) - 1;
|
||||
if (async_helper._asyncLevel == 0) {
|
||||
let callback = async_helper._onAsyncEnd;
|
||||
async_helper._onAsyncEnd = null;
|
||||
callback();
|
||||
core.print('unittest-suite-success');
|
||||
}
|
||||
};
|
||||
dart.fn(async_helper.asyncEnd, dart.void, []);
|
||||
async_helper.asyncSuccess = function(_) {
|
||||
return async_helper.asyncEnd();
|
||||
};
|
||||
dart.fn(async_helper.asyncSuccess, dart.void, [dart.dynamic]);
|
||||
async_helper.asyncTest = function(f) {
|
||||
async_helper.asyncStart();
|
||||
dart.dsend(f(), 'then', async_helper.asyncSuccess);
|
||||
};
|
||||
dart.fn(async_helper.asyncTest, dart.void, [dart.functionType(dart.dynamic, [])]);
|
||||
// Exports:
|
||||
exports.async_helper = async_helper;
|
||||
});
|
|
@ -1,70 +0,0 @@
|
|||
dart_library.library('async_helper', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const async_helper = Object.create(null);
|
||||
async_helper._initialized = false;
|
||||
async_helper._Action0 = dart.typedef('_Action0', () => dart.functionType(dart.void, []));
|
||||
async_helper._onAsyncEnd = null;
|
||||
async_helper._asyncLevel = 0;
|
||||
async_helper._buildException = function(msg) {
|
||||
return core.Exception.new(dart.str`Fatal: ${msg}. This is most likely a bug in your test.`);
|
||||
};
|
||||
dart.fn(async_helper._buildException, core.Exception, [core.String]);
|
||||
async_helper.asyncTestInitialize = function(callback) {
|
||||
async_helper._asyncLevel = 0;
|
||||
async_helper._initialized = false;
|
||||
async_helper._onAsyncEnd = callback;
|
||||
};
|
||||
dart.fn(async_helper.asyncTestInitialize, dart.void, [async_helper._Action0]);
|
||||
dart.copyProperties(async_helper, {
|
||||
get asyncTestStarted() {
|
||||
return async_helper._initialized;
|
||||
}
|
||||
});
|
||||
async_helper.asyncStart = function() {
|
||||
if (dart.notNull(async_helper._initialized) && async_helper._asyncLevel == 0) {
|
||||
dart.throw(async_helper._buildException('asyncStart() was called even though we are done ' + 'with testing.'));
|
||||
}
|
||||
if (!dart.notNull(async_helper._initialized)) {
|
||||
if (async_helper._onAsyncEnd == null) {
|
||||
dart.throw(async_helper._buildException('asyncStart() was called before asyncTestInitialize()'));
|
||||
}
|
||||
core.print('unittest-suite-wait-for-done');
|
||||
async_helper._initialized = true;
|
||||
}
|
||||
async_helper._asyncLevel = dart.notNull(async_helper._asyncLevel) + 1;
|
||||
};
|
||||
dart.fn(async_helper.asyncStart, dart.void, []);
|
||||
async_helper.asyncEnd = function() {
|
||||
if (dart.notNull(async_helper._asyncLevel) <= 0) {
|
||||
if (!dart.notNull(async_helper._initialized)) {
|
||||
dart.throw(async_helper._buildException('asyncEnd() was called before asyncStart().'));
|
||||
} else {
|
||||
dart.throw(async_helper._buildException('asyncEnd() was called more often than ' + 'asyncStart().'));
|
||||
}
|
||||
}
|
||||
async_helper._asyncLevel = dart.notNull(async_helper._asyncLevel) - 1;
|
||||
if (async_helper._asyncLevel == 0) {
|
||||
let callback = async_helper._onAsyncEnd;
|
||||
async_helper._onAsyncEnd = null;
|
||||
callback();
|
||||
core.print('unittest-suite-success');
|
||||
}
|
||||
};
|
||||
dart.fn(async_helper.asyncEnd, dart.void, []);
|
||||
async_helper.asyncSuccess = function(_) {
|
||||
return async_helper.asyncEnd();
|
||||
};
|
||||
dart.fn(async_helper.asyncSuccess, dart.void, [dart.dynamic]);
|
||||
async_helper.asyncTest = function(f) {
|
||||
async_helper.asyncStart();
|
||||
dart.dsend(f(), 'then', async_helper.asyncSuccess);
|
||||
};
|
||||
dart.fn(async_helper.asyncTest, dart.void, [dart.functionType(dart.dynamic, [])]);
|
||||
// Exports:
|
||||
exports.async_helper = async_helper;
|
||||
});
|
|
@ -1,115 +0,0 @@
|
|||
dart_library.library('cascade', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const cascade = Object.create(null);
|
||||
cascade.A = class A extends core.Object {
|
||||
new() {
|
||||
this.x = null;
|
||||
}
|
||||
};
|
||||
cascade.test_closure_with_mutate = function() {
|
||||
let a = new cascade.A();
|
||||
a.x = dart.fn(() => {
|
||||
core.print("hi");
|
||||
a = null;
|
||||
});
|
||||
let _ = a;
|
||||
dart.dsend(_, 'x');
|
||||
dart.dsend(_, 'x');
|
||||
core.print(a);
|
||||
};
|
||||
dart.fn(cascade.test_closure_with_mutate, dart.void, []);
|
||||
cascade.test_closure_without_mutate = function() {
|
||||
let a = new cascade.A();
|
||||
a.x = dart.fn(() => {
|
||||
core.print(a);
|
||||
});
|
||||
dart.dsend(a, 'x');
|
||||
dart.dsend(a, 'x');
|
||||
core.print(a);
|
||||
};
|
||||
dart.fn(cascade.test_closure_without_mutate, dart.void, []);
|
||||
cascade.test_mutate_inside_cascade = function() {
|
||||
let a = null;
|
||||
let _ = new cascade.A();
|
||||
_.x = a = null;
|
||||
_.x = a = null;
|
||||
a = _;
|
||||
core.print(a);
|
||||
};
|
||||
dart.fn(cascade.test_mutate_inside_cascade, dart.void, []);
|
||||
cascade.test_mutate_outside_cascade = function() {
|
||||
let a = null, b = null;
|
||||
a = new cascade.A();
|
||||
a.x = b = null;
|
||||
a.x = b = null;
|
||||
a = null;
|
||||
core.print(a);
|
||||
};
|
||||
dart.fn(cascade.test_mutate_outside_cascade, dart.void, []);
|
||||
cascade.test_VariableDeclaration_single = function() {
|
||||
let a = [];
|
||||
a[dartx.length] = 2;
|
||||
a[dartx.add](42);
|
||||
core.print(a);
|
||||
};
|
||||
dart.fn(cascade.test_VariableDeclaration_single, dart.void, []);
|
||||
cascade.test_VariableDeclaration_last = function() {
|
||||
let a = 42, b = (() => {
|
||||
let _ = [];
|
||||
_[dartx.length] = 2;
|
||||
_[dartx.add](a);
|
||||
return _;
|
||||
})();
|
||||
core.print(b);
|
||||
};
|
||||
dart.fn(cascade.test_VariableDeclaration_last, dart.void, []);
|
||||
cascade.test_VariableDeclaration_first = function() {
|
||||
let a = (() => {
|
||||
let _ = [];
|
||||
_[dartx.length] = 2;
|
||||
_[dartx.add](3);
|
||||
return _;
|
||||
})(), b = 2;
|
||||
core.print(a);
|
||||
};
|
||||
dart.fn(cascade.test_VariableDeclaration_first, dart.void, []);
|
||||
cascade.test_increment = function() {
|
||||
let a = new cascade.A();
|
||||
let y = ((() => {
|
||||
a.x = dart.dsend(a.x, '+', 1);
|
||||
a.x = dart.dsend(a.x, '-', 1);
|
||||
return a;
|
||||
})());
|
||||
};
|
||||
dart.fn(cascade.test_increment, dart.void, []);
|
||||
cascade.Base$ = dart.generic(T => {
|
||||
class Base extends core.Object {
|
||||
new() {
|
||||
this.x = dart.list([], T);
|
||||
}
|
||||
}
|
||||
return Base;
|
||||
});
|
||||
cascade.Base = cascade.Base$();
|
||||
cascade.Foo = class Foo extends cascade.Base$(core.int) {
|
||||
new() {
|
||||
super.new();
|
||||
}
|
||||
test_final_field_generic(t) {
|
||||
this.x[dartx.add](1);
|
||||
this.x[dartx.add](2);
|
||||
this.x[dartx.add](3);
|
||||
this.x[dartx.add](4);
|
||||
}
|
||||
};
|
||||
dart.setSignature(cascade.Foo, {
|
||||
methods: () => ({test_final_field_generic: [dart.void, [dart.dynamic]]})
|
||||
});
|
||||
// Exports:
|
||||
exports.cascade = cascade;
|
||||
});
|
|
@ -1,96 +0,0 @@
|
|||
export const closure = Object.create(null);
|
||||
import { core, js, dart, dartx } from 'dart_sdk';
|
||||
closure.generic_function = function(T) {
|
||||
return (items: core.List<T>, seed: T): core.List<T> => {
|
||||
let strings = items[dartx.map](core.String)(dart.fn((i: T): string => dart.str`${i}`, core.String, [T]))[dartx.toList]();
|
||||
return items;
|
||||
};
|
||||
};
|
||||
dart.fn(closure.generic_function, T => [core.List$(T), [core.List$(T), T]]);
|
||||
closure.Callback = dart.typedef('Callback', () => dart.functionType(dart.void, [], {i: core.int}));
|
||||
closure.Foo$ = dart.generic(T => {
|
||||
class Foo<T> extends core.Object {
|
||||
i: number;
|
||||
b: boolean;
|
||||
s: string;
|
||||
v: T;
|
||||
static some_static_constant: string;
|
||||
static some_static_final: string;
|
||||
static some_static_var: string;
|
||||
new(i: number, v: T) {
|
||||
this.i = i;
|
||||
this.v = v;
|
||||
this.b = null;
|
||||
this.s = null;
|
||||
}
|
||||
static build() {
|
||||
return new (closure.Foo$(T))(1, null);
|
||||
}
|
||||
untyped_method(a, b) {}
|
||||
pass(t: T) {
|
||||
dart.as(t, T);
|
||||
return t;
|
||||
}
|
||||
typed_method(foo: closure.Foo<any>, list: core.List<any>, i: number, n: number, d: number, b: boolean, s: string, a: any[], o: Object, f: Function) {
|
||||
return '';
|
||||
}
|
||||
optional_params(a, b = null, c: number = null) {}
|
||||
static named_params(a, {b = null, c = null}: {b?: any, c?: number} = {}) {}
|
||||
nullary_method() {}
|
||||
function_params(f: (x: any, y?: any) => number, g: (x: any, opts?: {y?: string, z?: any}) => any, cb: closure.Callback) {
|
||||
cb({i: this.i});
|
||||
}
|
||||
run(a: core.List<any>, b: string, c: (d: string) => core.List<any>, e: (f: (g: any) => any) => core.List<number>, {h = null}: {h?: core.Map<core.Map<any, any>, core.Map<any, any>>} = {}) {}
|
||||
get prop() {
|
||||
return null;
|
||||
}
|
||||
set prop(value: string) {}
|
||||
static get staticProp() {
|
||||
return null;
|
||||
}
|
||||
static set staticProp(value: string) {}
|
||||
}
|
||||
dart.setSignature(Foo, {
|
||||
constructors: () => ({
|
||||
new: [closure.Foo$(T), [core.int, T]],
|
||||
build: [closure.Foo$(T), []]
|
||||
}),
|
||||
methods: () => ({
|
||||
untyped_method: [dart.dynamic, [dart.dynamic, dart.dynamic]],
|
||||
pass: [T, [T]],
|
||||
typed_method: [core.String, [closure.Foo, core.List, core.int, core.num, core.double, core.bool, core.String, js.JsArray, js.JsObject, js.JsFunction]],
|
||||
optional_params: [dart.dynamic, [dart.dynamic], [dart.dynamic, core.int]],
|
||||
nullary_method: [dart.dynamic, []],
|
||||
function_params: [dart.dynamic, [dart.functionType(core.int, [dart.dynamic], [dart.dynamic]), dart.functionType(dart.dynamic, [dart.dynamic], {y: core.String, z: dart.dynamic}), closure.Callback]],
|
||||
run: [dart.dynamic, [core.List, core.String, dart.functionType(core.List, [core.String]), dart.functionType(core.List$(core.int), [dart.functionType(dart.dynamic, [dart.dynamic])])], {h: core.Map$(core.Map, core.Map)}]
|
||||
}),
|
||||
statics: () => ({named_params: [dart.dynamic, [dart.dynamic], {b: dart.dynamic, c: core.int}]}),
|
||||
names: ['named_params']
|
||||
});
|
||||
return Foo;
|
||||
});
|
||||
closure.Foo = closure.Foo$();
|
||||
/** @final {string} */
|
||||
closure.Foo.some_static_constant = "abc";
|
||||
/** @final {string} */
|
||||
closure.Foo.some_static_final = "abc";
|
||||
/** @type {string} */
|
||||
closure.Foo.some_static_var = "abc";
|
||||
closure.Bar = class Bar extends core.Object {};
|
||||
closure.Baz = class Baz extends dart.mixin(closure.Foo$(core.int), closure.Bar) {
|
||||
new(i: number) {
|
||||
super.new(i, 123);
|
||||
}
|
||||
};
|
||||
dart.setSignature(closure.Baz, {
|
||||
constructors: () => ({new: [closure.Baz, [core.int]]})
|
||||
});
|
||||
closure.main = function(args): void {
|
||||
};
|
||||
dart.fn(closure.main, dart.void, [dart.dynamic]);
|
||||
/** @final {string} */
|
||||
closure.some_top_level_constant = "abc";
|
||||
/** @final {string} */
|
||||
closure.some_top_level_final = "abc";
|
||||
/** @type {string} */
|
||||
closure.some_top_level_var = "abc";
|
|
@ -1,202 +0,0 @@
|
|||
dart_library.library('constructors', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const constructors = Object.create(null);
|
||||
constructors.A = class A extends core.Object {};
|
||||
constructors.B = class B extends core.Object {
|
||||
new() {
|
||||
}
|
||||
};
|
||||
dart.setSignature(constructors.B, {
|
||||
constructors: () => ({new: [constructors.B, []]})
|
||||
});
|
||||
constructors.C = class C extends core.Object {
|
||||
named() {
|
||||
}
|
||||
};
|
||||
dart.defineNamedConstructor(constructors.C, 'named');
|
||||
dart.setSignature(constructors.C, {
|
||||
constructors: () => ({named: [constructors.C, []]})
|
||||
});
|
||||
constructors.C2 = class C2 extends constructors.C {
|
||||
named() {
|
||||
super.named();
|
||||
}
|
||||
};
|
||||
dart.defineNamedConstructor(constructors.C2, 'named');
|
||||
dart.setSignature(constructors.C2, {
|
||||
constructors: () => ({named: [constructors.C2, []]})
|
||||
});
|
||||
constructors.D = class D extends core.Object {
|
||||
new() {
|
||||
}
|
||||
named() {
|
||||
}
|
||||
};
|
||||
dart.defineNamedConstructor(constructors.D, 'named');
|
||||
dart.setSignature(constructors.D, {
|
||||
constructors: () => ({
|
||||
new: [constructors.D, []],
|
||||
named: [constructors.D, []]
|
||||
})
|
||||
});
|
||||
constructors.E = class E extends core.Object {
|
||||
new(name) {
|
||||
this.name = name;
|
||||
}
|
||||
};
|
||||
dart.setSignature(constructors.E, {
|
||||
constructors: () => ({new: [constructors.E, [core.String]]})
|
||||
});
|
||||
constructors.F = class F extends constructors.E {
|
||||
new(name) {
|
||||
super.new(name);
|
||||
}
|
||||
};
|
||||
dart.setSignature(constructors.F, {
|
||||
constructors: () => ({new: [constructors.F, [core.String]]})
|
||||
});
|
||||
constructors.G = class G extends core.Object {
|
||||
new(p1) {
|
||||
if (p1 === void 0) p1 = null;
|
||||
}
|
||||
};
|
||||
dart.setSignature(constructors.G, {
|
||||
constructors: () => ({new: [constructors.G, [], [core.String]]})
|
||||
});
|
||||
constructors.H = class H extends core.Object {
|
||||
new(opts) {
|
||||
let p1 = opts && 'p1' in opts ? opts.p1 : null;
|
||||
}
|
||||
};
|
||||
dart.setSignature(constructors.H, {
|
||||
constructors: () => ({new: [constructors.H, [], {p1: core.String}]})
|
||||
});
|
||||
constructors.I = class I extends core.Object {
|
||||
new() {
|
||||
this.name = 'default';
|
||||
}
|
||||
named(name) {
|
||||
this.name = name;
|
||||
}
|
||||
};
|
||||
dart.defineNamedConstructor(constructors.I, 'named');
|
||||
dart.setSignature(constructors.I, {
|
||||
constructors: () => ({
|
||||
new: [constructors.I, []],
|
||||
named: [constructors.I, [core.String]]
|
||||
})
|
||||
});
|
||||
constructors.J = class J extends core.Object {
|
||||
new() {
|
||||
this.initialized = true;
|
||||
this.nonInitialized = null;
|
||||
}
|
||||
};
|
||||
dart.setSignature(constructors.J, {
|
||||
constructors: () => ({new: [constructors.J, []]})
|
||||
});
|
||||
constructors.K = class K extends core.Object {
|
||||
new() {
|
||||
this.s = 'a';
|
||||
}
|
||||
withS(s) {
|
||||
this.s = s;
|
||||
}
|
||||
};
|
||||
dart.defineNamedConstructor(constructors.K, 'withS');
|
||||
dart.setSignature(constructors.K, {
|
||||
constructors: () => ({
|
||||
new: [constructors.K, []],
|
||||
withS: [constructors.K, [core.String]]
|
||||
})
|
||||
});
|
||||
constructors.L = class L extends core.Object {
|
||||
new(foo) {
|
||||
this.foo = foo;
|
||||
}
|
||||
};
|
||||
dart.setSignature(constructors.L, {
|
||||
constructors: () => ({new: [constructors.L, [dart.dynamic]]})
|
||||
});
|
||||
constructors.M = class M extends constructors.L {
|
||||
named(x) {
|
||||
super.new(dart.notNull(x) + 42);
|
||||
}
|
||||
};
|
||||
dart.defineNamedConstructor(constructors.M, 'named');
|
||||
dart.setSignature(constructors.M, {
|
||||
constructors: () => ({named: [constructors.M, [core.int]]})
|
||||
});
|
||||
constructors.N = class N extends constructors.M {
|
||||
named(y) {
|
||||
super.named(dart.notNull(y) + 100);
|
||||
}
|
||||
};
|
||||
dart.defineNamedConstructor(constructors.N, 'named');
|
||||
dart.setSignature(constructors.N, {
|
||||
constructors: () => ({named: [constructors.N, [core.int]]})
|
||||
});
|
||||
constructors.P = class P extends constructors.N {
|
||||
new(z) {
|
||||
super.named(dart.notNull(z) + 9000);
|
||||
}
|
||||
foo(x) {
|
||||
P.prototype.new.call(this, dart.notNull(x) + 42);
|
||||
}
|
||||
bar() {
|
||||
P.prototype.foo.call(this, 1);
|
||||
}
|
||||
};
|
||||
dart.defineNamedConstructor(constructors.P, 'foo');
|
||||
dart.defineNamedConstructor(constructors.P, 'bar');
|
||||
dart.setSignature(constructors.P, {
|
||||
constructors: () => ({
|
||||
new: [constructors.P, [core.int]],
|
||||
foo: [constructors.P, [core.int]],
|
||||
bar: [constructors.P, []]
|
||||
})
|
||||
});
|
||||
constructors.Q$ = dart.generic(T => {
|
||||
class Q extends core.Object {
|
||||
new(y) {
|
||||
this.x = dart.as(y, T);
|
||||
}
|
||||
static foo() {
|
||||
return new constructors.Q("hello");
|
||||
}
|
||||
bar() {
|
||||
let q = constructors.Q.foo();
|
||||
return dart.as(q.x, core.String);
|
||||
}
|
||||
bar2() {
|
||||
let q = new constructors.Q("world");
|
||||
return dart.as(q.x, core.String);
|
||||
}
|
||||
static baz() {
|
||||
let q = new (constructors.Q$(core.int))(42);
|
||||
return dart.notNull(q.bar()) + dart.notNull(q.bar2());
|
||||
}
|
||||
}
|
||||
dart.setSignature(Q, {
|
||||
constructors: () => ({new: [constructors.Q$(T), [dart.dynamic]]}),
|
||||
methods: () => ({
|
||||
bar: [core.String, []],
|
||||
bar2: [core.String, []]
|
||||
}),
|
||||
statics: () => ({
|
||||
foo: [constructors.Q, []],
|
||||
baz: [core.String, []]
|
||||
}),
|
||||
names: ['foo', 'baz']
|
||||
});
|
||||
return Q;
|
||||
});
|
||||
constructors.Q = constructors.Q$();
|
||||
// Exports:
|
||||
exports.constructors = constructors;
|
||||
});
|
|
@ -1 +0,0 @@
|
|||
[warning] Unsound implicit cast from dynamic to T (test/codegen/constructors.dart, line 90, col 14)
|
|
@ -1,51 +0,0 @@
|
|||
dart_library.library('covariance', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const covariance = Object.create(null);
|
||||
const _t = Symbol('_t');
|
||||
covariance.Foo$ = dart.generic(T => {
|
||||
class Foo extends core.Object {
|
||||
new() {
|
||||
this[_t] = null;
|
||||
}
|
||||
add(t) {
|
||||
dart.as(t, T);
|
||||
this[_t] = t;
|
||||
}
|
||||
forEach(fn) {
|
||||
fn(this[_t]);
|
||||
}
|
||||
}
|
||||
dart.setSignature(Foo, {
|
||||
methods: () => ({
|
||||
add: [dart.dynamic, [T]],
|
||||
forEach: [dart.dynamic, [dart.functionType(dart.void, [T])]]
|
||||
})
|
||||
});
|
||||
return Foo;
|
||||
});
|
||||
covariance.Foo = covariance.Foo$();
|
||||
covariance.Bar = class Bar extends covariance.Foo$(core.int) {
|
||||
new() {
|
||||
super.new();
|
||||
}
|
||||
add(x) {
|
||||
core.print(dart.str`Bar.add got ${x}`);
|
||||
super.add(x);
|
||||
}
|
||||
};
|
||||
dart.setSignature(covariance.Bar, {
|
||||
methods: () => ({add: [dart.dynamic, [core.int]]})
|
||||
});
|
||||
covariance.main = function() {
|
||||
let foo = new covariance.Bar();
|
||||
foo.add('hi');
|
||||
};
|
||||
dart.fn(covariance.main);
|
||||
// Exports:
|
||||
exports.covariance = covariance;
|
||||
});
|
|
@ -1,69 +0,0 @@
|
|||
dart_library.library('destructuring', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const destructuring = Object.create(null);
|
||||
destructuring.f = function(a, b, c = 1) {
|
||||
destructuring.f(a, b, c);
|
||||
};
|
||||
dart.fn(destructuring.f, dart.dynamic, [core.int, dart.dynamic], [dart.dynamic]);
|
||||
destructuring.f_sync = function(a, b, c) {
|
||||
return dart.syncStar(function*(a, b, c = 1) {
|
||||
}, dart.dynamic, a, b, c);
|
||||
};
|
||||
dart.fn(destructuring.f_sync, dart.dynamic, [core.int, dart.dynamic], [dart.dynamic]);
|
||||
destructuring.f_async = function(a, b, c) {
|
||||
return dart.asyncStar(function*(stream, a, b, c = 1) {
|
||||
}, dart.dynamic, a, b, c);
|
||||
};
|
||||
dart.fn(destructuring.f_async, dart.dynamic, [core.int, dart.dynamic], [dart.dynamic]);
|
||||
destructuring.g = function(a, b, {c = 1} = {}) {
|
||||
destructuring.f(a, b, c);
|
||||
};
|
||||
dart.fn(destructuring.g, dart.dynamic, [core.int, dart.dynamic], {c: dart.dynamic});
|
||||
destructuring.g_sync = function(a, b, opts) {
|
||||
return dart.syncStar(function*(a, b, {c = 1} = {}) {
|
||||
}, dart.dynamic, a, b, opts);
|
||||
};
|
||||
dart.fn(destructuring.g_sync, dart.dynamic, [core.int, dart.dynamic], {c: dart.dynamic});
|
||||
destructuring.g_async = function(a, b, opts) {
|
||||
return dart.asyncStar(function*(stream, a, b, {c = 1} = {}) {
|
||||
}, dart.dynamic, a, b, opts);
|
||||
};
|
||||
dart.fn(destructuring.g_async, dart.dynamic, [core.int, dart.dynamic], {c: dart.dynamic});
|
||||
destructuring.r = function(a, ...others) {
|
||||
destructuring.r(a, ...others);
|
||||
};
|
||||
dart.fn(destructuring.r, dart.dynamic, [core.int, dart.dynamic]);
|
||||
destructuring.r_sync = function(a, ...others) {
|
||||
return dart.syncStar(function*(a, ...others) {
|
||||
}, dart.dynamic, a, ...others);
|
||||
};
|
||||
dart.fn(destructuring.r_sync, dart.dynamic, [core.int, dart.dynamic]);
|
||||
destructuring.r_async = function(a, ...others) {
|
||||
return dart.asyncStar(function*(stream, a, ...others) {
|
||||
}, dart.dynamic, a, ...others);
|
||||
};
|
||||
dart.fn(destructuring.r_async, dart.dynamic, [core.int, dart.dynamic]);
|
||||
destructuring.invalid_names1 = function(let$, func, arguments$) {
|
||||
destructuring.f(let$, func, arguments$);
|
||||
};
|
||||
dart.fn(destructuring.invalid_names1, dart.dynamic, [core.int, dart.dynamic, dart.dynamic]);
|
||||
destructuring.invalid_names2 = function(let$ = null, func = 1, arguments$ = null) {
|
||||
destructuring.f(let$, func, arguments$);
|
||||
};
|
||||
dart.fn(destructuring.invalid_names2, dart.dynamic, [], [core.int, dart.dynamic, dart.dynamic]);
|
||||
destructuring.invalid_names3 = function({["let"]: let$ = null, ["function"]: func = null, ["arguments"]: arguments$ = 2} = {}) {
|
||||
destructuring.f(let$, func, arguments$);
|
||||
};
|
||||
dart.fn(destructuring.invalid_names3, dart.dynamic, [], {let: core.int, function: dart.dynamic, arguments: dart.dynamic});
|
||||
destructuring.names_clashing_with_object_props = function({constructor = null, valueOf = null, hasOwnProperty = 2} = Object.create(null)) {
|
||||
destructuring.f(constructor, valueOf, hasOwnProperty);
|
||||
};
|
||||
dart.fn(destructuring.names_clashing_with_object_props, dart.dynamic, [], {constructor: core.int, valueOf: dart.dynamic, hasOwnProperty: dart.dynamic});
|
||||
// Exports:
|
||||
exports.destructuring = destructuring;
|
||||
});
|
|
@ -1,41 +0,0 @@
|
|||
export const es6_modules = Object.create(null);
|
||||
import { core, dart, dartx } from 'dart_sdk';
|
||||
es6_modules.Callback = dart.typedef('Callback', () => dart.functionType(dart.void, [], {i: core.int}));
|
||||
es6_modules.A = class A extends core.Object {};
|
||||
es6_modules._A = class _A extends core.Object {};
|
||||
es6_modules.B$ = dart.generic(T => {
|
||||
class B extends core.Object {}
|
||||
return B;
|
||||
});
|
||||
es6_modules.B = es6_modules.B$();
|
||||
es6_modules._B$ = dart.generic(T => {
|
||||
class _B extends core.Object {}
|
||||
return _B;
|
||||
});
|
||||
es6_modules._B = es6_modules._B$();
|
||||
es6_modules.f = function() {
|
||||
};
|
||||
dart.fn(es6_modules.f);
|
||||
es6_modules._f = function() {
|
||||
};
|
||||
dart.fn(es6_modules._f);
|
||||
es6_modules.constant = "abc";
|
||||
es6_modules.finalConstant = "abc";
|
||||
dart.defineLazy(es6_modules, {
|
||||
get lazy() {
|
||||
return dart.fn(() => {
|
||||
core.print('lazy');
|
||||
return "abc";
|
||||
}, core.String, [])();
|
||||
}
|
||||
});
|
||||
es6_modules.mutable = "abc";
|
||||
dart.defineLazy(es6_modules, {
|
||||
get lazyMutable() {
|
||||
return dart.fn(() => {
|
||||
core.print('lazyMutable');
|
||||
return "abc";
|
||||
}, core.String, [])();
|
||||
},
|
||||
set lazyMutable(_) {}
|
||||
});
|
|
@ -1,303 +0,0 @@
|
|||
dart_library.library('expect', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const expect = Object.create(null);
|
||||
expect.Expect = class Expect extends core.Object {
|
||||
static _truncateString(string, start, end, length) {
|
||||
if (dart.notNull(end) - dart.notNull(start) > dart.notNull(length)) {
|
||||
end = dart.notNull(start) + dart.notNull(length);
|
||||
} else if (dart.notNull(end) - dart.notNull(start) < dart.notNull(length)) {
|
||||
let overflow = dart.notNull(length) - (dart.notNull(end) - dart.notNull(start));
|
||||
if (overflow > 10) overflow = 10;
|
||||
start = dart.notNull(start) - ((overflow + 1) / 2)[dartx.truncate]();
|
||||
end = dart.notNull(end) + (overflow / 2)[dartx.truncate]();
|
||||
if (dart.notNull(start) < 0) start = 0;
|
||||
if (dart.notNull(end) > dart.notNull(string[dartx.length])) end = string[dartx.length];
|
||||
}
|
||||
if (start == 0 && end == string[dartx.length]) return string;
|
||||
let buf = new core.StringBuffer();
|
||||
if (dart.notNull(start) > 0) buf.write("...");
|
||||
for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(i) + 1) {
|
||||
let code = string[dartx.codeUnitAt](i);
|
||||
if (dart.notNull(code) < 32) {
|
||||
buf.write("\\x");
|
||||
buf.write("0123456789abcdef"[dartx.get]((dart.notNull(code) / 16)[dartx.truncate]()));
|
||||
buf.write("0123456789abcdef"[dartx.get](code[dartx['%']](16)));
|
||||
} else {
|
||||
buf.writeCharCode(string[dartx.codeUnitAt](i));
|
||||
}
|
||||
}
|
||||
if (dart.notNull(end) < dart.notNull(string[dartx.length])) buf.write("...");
|
||||
return buf.toString();
|
||||
}
|
||||
static _stringDifference(expected, actual) {
|
||||
if (dart.notNull(expected[dartx.length]) < 20 && dart.notNull(actual[dartx.length]) < 20) return null;
|
||||
for (let i = 0; i < dart.notNull(expected[dartx.length]) && i < dart.notNull(actual[dartx.length]); i++) {
|
||||
if (expected[dartx.codeUnitAt](i) != actual[dartx.codeUnitAt](i)) {
|
||||
let start = i;
|
||||
i++;
|
||||
while (i < dart.notNull(expected[dartx.length]) && i < dart.notNull(actual[dartx.length])) {
|
||||
if (expected[dartx.codeUnitAt](i) == actual[dartx.codeUnitAt](i)) break;
|
||||
i++;
|
||||
}
|
||||
let end = i;
|
||||
let truncExpected = expect.Expect._truncateString(expected, start, end, 20);
|
||||
let truncActual = expect.Expect._truncateString(actual, start, end, 20);
|
||||
return dart.str`at index ${start}: Expected <${truncExpected}>, ` + dart.str`Found: <${truncActual}>`;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
static equals(expected, actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (dart.equals(expected, actual)) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
if (typeof expected == 'string' && typeof actual == 'string') {
|
||||
let stringDifference = expect.Expect._stringDifference(expected, actual);
|
||||
if (stringDifference != null) {
|
||||
expect.Expect._fail(dart.str`Expect.equals(${stringDifference}${msg}) fails.`);
|
||||
}
|
||||
}
|
||||
expect.Expect._fail(dart.str`Expect.equals(expected: <${expected}>, actual: <${actual}>${msg}) fails.`);
|
||||
}
|
||||
static isTrue(actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (dart.notNull(expect._identical(actual, true))) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
expect.Expect._fail(dart.str`Expect.isTrue(${actual}${msg}) fails.`);
|
||||
}
|
||||
static isFalse(actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (dart.notNull(expect._identical(actual, false))) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
expect.Expect._fail(dart.str`Expect.isFalse(${actual}${msg}) fails.`);
|
||||
}
|
||||
static isNull(actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (null == actual) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
expect.Expect._fail(dart.str`Expect.isNull(actual: <${actual}>${msg}) fails.`);
|
||||
}
|
||||
static isNotNull(actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (null != actual) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
expect.Expect._fail(dart.str`Expect.isNotNull(actual: <${actual}>${msg}) fails.`);
|
||||
}
|
||||
static identical(expected, actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (dart.notNull(expect._identical(expected, actual))) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
expect.Expect._fail(dart.str`Expect.identical(expected: <${expected}>, actual: <${actual}>${msg}) ` + "fails.");
|
||||
}
|
||||
static fail(msg) {
|
||||
expect.Expect._fail(dart.str`Expect.fail('${msg}')`);
|
||||
}
|
||||
static approxEquals(expected, actual, tolerance, reason) {
|
||||
if (tolerance === void 0) tolerance = null;
|
||||
if (reason === void 0) reason = null;
|
||||
if (tolerance == null) {
|
||||
tolerance = (dart.notNull(expected) / 10000.0)[dartx.abs]();
|
||||
}
|
||||
if (dart.notNull((dart.notNull(expected) - dart.notNull(actual))[dartx.abs]()) <= dart.notNull(tolerance)) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
expect.Expect._fail(dart.str`Expect.approxEquals(expected:<${expected}>, actual:<${actual}>, ` + dart.str`tolerance:<${tolerance}>${msg}) fails`);
|
||||
}
|
||||
static notEquals(unexpected, actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (!dart.equals(unexpected, actual)) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
expect.Expect._fail(dart.str`Expect.notEquals(unexpected: <${unexpected}>, actual:<${actual}>${msg}) ` + "fails.");
|
||||
}
|
||||
static listEquals(expected, actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
let n = dart.notNull(expected[dartx.length]) < dart.notNull(actual[dartx.length]) ? expected[dartx.length] : actual[dartx.length];
|
||||
for (let i = 0; i < dart.notNull(n); i++) {
|
||||
if (!dart.equals(expected[dartx.get](i), actual[dartx.get](i))) {
|
||||
expect.Expect._fail(dart.str`Expect.listEquals(at index ${i}, ` + dart.str`expected: <${expected[dartx.get](i)}>, actual: <${actual[dartx.get](i)}>${msg}) fails`);
|
||||
}
|
||||
}
|
||||
if (expected[dartx.length] != actual[dartx.length]) {
|
||||
expect.Expect._fail('Expect.listEquals(list length, ' + dart.str`expected: <${expected[dartx.length]}>, actual: <${actual[dartx.length]}>${msg}) ` + 'fails: Next element <' + dart.str`${dart.notNull(expected[dartx.length]) > dart.notNull(n) ? expected[dartx.get](n) : actual[dartx.get](n)}>`);
|
||||
}
|
||||
}
|
||||
static mapEquals(expected, actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
for (let key of expected[dartx.keys]) {
|
||||
if (!dart.notNull(actual[dartx.containsKey](key))) {
|
||||
expect.Expect._fail(dart.str`Expect.mapEquals(missing expected key: <${key}>${msg}) fails`);
|
||||
}
|
||||
expect.Expect.equals(expected[dartx.get](key), actual[dartx.get](key));
|
||||
}
|
||||
for (let key of actual[dartx.keys]) {
|
||||
if (!dart.notNull(expected[dartx.containsKey](key))) {
|
||||
expect.Expect._fail(dart.str`Expect.mapEquals(unexpected key: <${key}>${msg}) fails`);
|
||||
}
|
||||
}
|
||||
}
|
||||
static stringEquals(expected, actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (expected == actual) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
let defaultMessage = dart.str`Expect.stringEquals(expected: <${expected}>", <${actual}>${msg}) fails`;
|
||||
if (expected == null || actual == null) {
|
||||
expect.Expect._fail(dart.str`${defaultMessage}`);
|
||||
}
|
||||
let left = 0;
|
||||
let right = 0;
|
||||
let eLen = expected[dartx.length];
|
||||
let aLen = actual[dartx.length];
|
||||
while (true) {
|
||||
if (left == eLen || left == aLen || expected[dartx.get](left) != actual[dartx.get](left)) {
|
||||
break;
|
||||
}
|
||||
left++;
|
||||
}
|
||||
let eRem = dart.notNull(eLen) - left;
|
||||
let aRem = dart.notNull(aLen) - left;
|
||||
while (true) {
|
||||
if (right == eRem || right == aRem || expected[dartx.get](dart.notNull(eLen) - right - 1) != actual[dartx.get](dart.notNull(aLen) - right - 1)) {
|
||||
break;
|
||||
}
|
||||
right++;
|
||||
}
|
||||
let leftSnippet = expected[dartx.substring](left < 10 ? 0 : left - 10, left);
|
||||
let rightSnippetLength = right < 10 ? right : 10;
|
||||
let rightSnippet = expected[dartx.substring](dart.notNull(eLen) - right, dart.notNull(eLen) - right + rightSnippetLength);
|
||||
let eSnippet = expected[dartx.substring](left, dart.notNull(eLen) - right);
|
||||
let aSnippet = actual[dartx.substring](left, dart.notNull(aLen) - right);
|
||||
if (dart.notNull(eSnippet[dartx.length]) > 43) {
|
||||
eSnippet = dart.notNull(eSnippet[dartx.substring](0, 20)) + "..." + dart.notNull(eSnippet[dartx.substring](dart.notNull(eSnippet[dartx.length]) - 20));
|
||||
}
|
||||
if (dart.notNull(aSnippet[dartx.length]) > 43) {
|
||||
aSnippet = dart.notNull(aSnippet[dartx.substring](0, 20)) + "..." + dart.notNull(aSnippet[dartx.substring](dart.notNull(aSnippet[dartx.length]) - 20));
|
||||
}
|
||||
let leftLead = "...";
|
||||
let rightTail = "...";
|
||||
if (left <= 10) leftLead = "";
|
||||
if (right <= 10) rightTail = "";
|
||||
let diff = dart.str`\nDiff (${left}..${dart.notNull(eLen) - right}/${dart.notNull(aLen) - right}):\n` + dart.str`${leftLead}${leftSnippet}[ ${eSnippet} ]${rightSnippet}${rightTail}\n` + dart.str`${leftLead}${leftSnippet}[ ${aSnippet} ]${rightSnippet}${rightTail}`;
|
||||
expect.Expect._fail(dart.str`${defaultMessage}${diff}`);
|
||||
}
|
||||
static setEquals(expected, actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
let missingSet = core.Set.from(expected);
|
||||
missingSet.removeAll(actual);
|
||||
let extraSet = core.Set.from(actual);
|
||||
extraSet.removeAll(expected);
|
||||
if (dart.notNull(extraSet.isEmpty) && dart.notNull(missingSet.isEmpty)) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
let sb = new core.StringBuffer(dart.str`Expect.setEquals(${msg}) fails`);
|
||||
if (!dart.notNull(missingSet.isEmpty)) {
|
||||
sb.write('\nExpected collection does not contain: ');
|
||||
}
|
||||
for (let val of missingSet) {
|
||||
sb.write(dart.str`${val} `);
|
||||
}
|
||||
if (!dart.notNull(extraSet.isEmpty)) {
|
||||
sb.write('\nExpected collection should not contain: ');
|
||||
}
|
||||
for (let val of extraSet) {
|
||||
sb.write(dart.str`${val} `);
|
||||
}
|
||||
expect.Expect._fail(sb.toString());
|
||||
}
|
||||
static throws(f, check, reason) {
|
||||
if (check === void 0) check = null;
|
||||
if (reason === void 0) reason = null;
|
||||
let msg = reason == null ? "" : dart.str`(${reason})`;
|
||||
if (!dart.is(f, expect._Nullary)) {
|
||||
expect.Expect._fail(dart.str`Expect.throws${msg}: Function f not callable with zero arguments`);
|
||||
}
|
||||
try {
|
||||
f();
|
||||
} catch (e) {
|
||||
let s = dart.stackTrace(e);
|
||||
if (check != null) {
|
||||
if (!dart.notNull(dart.dcall(check, e))) {
|
||||
expect.Expect._fail(dart.str`Expect.throws${msg}: Unexpected '${e}'\n${s}`);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
expect.Expect._fail(dart.str`Expect.throws${msg} fails: Did not throw`);
|
||||
}
|
||||
static _getMessage(reason) {
|
||||
return reason == null ? "" : dart.str`, '${reason}'`;
|
||||
}
|
||||
static _fail(message) {
|
||||
dart.throw(new expect.ExpectException(message));
|
||||
}
|
||||
};
|
||||
dart.setSignature(expect.Expect, {
|
||||
statics: () => ({
|
||||
_truncateString: [core.String, [core.String, core.int, core.int, core.int]],
|
||||
_stringDifference: [core.String, [core.String, core.String]],
|
||||
equals: [dart.void, [dart.dynamic, dart.dynamic], [core.String]],
|
||||
isTrue: [dart.void, [dart.dynamic], [core.String]],
|
||||
isFalse: [dart.void, [dart.dynamic], [core.String]],
|
||||
isNull: [dart.void, [dart.dynamic], [core.String]],
|
||||
isNotNull: [dart.void, [dart.dynamic], [core.String]],
|
||||
identical: [dart.void, [dart.dynamic, dart.dynamic], [core.String]],
|
||||
fail: [dart.void, [core.String]],
|
||||
approxEquals: [dart.void, [core.num, core.num], [core.num, core.String]],
|
||||
notEquals: [dart.void, [dart.dynamic, dart.dynamic], [core.String]],
|
||||
listEquals: [dart.void, [core.List, core.List], [core.String]],
|
||||
mapEquals: [dart.void, [core.Map, core.Map], [core.String]],
|
||||
stringEquals: [dart.void, [core.String, core.String], [core.String]],
|
||||
setEquals: [dart.void, [core.Iterable, core.Iterable], [core.String]],
|
||||
throws: [dart.void, [dart.functionType(dart.void, [])], [expect._CheckExceptionFn, core.String]],
|
||||
_getMessage: [core.String, [core.String]],
|
||||
_fail: [dart.void, [core.String]]
|
||||
}),
|
||||
names: ['_truncateString', '_stringDifference', 'equals', 'isTrue', 'isFalse', 'isNull', 'isNotNull', 'identical', 'fail', 'approxEquals', 'notEquals', 'listEquals', 'mapEquals', 'stringEquals', 'setEquals', 'throws', '_getMessage', '_fail']
|
||||
});
|
||||
expect._identical = function(a, b) {
|
||||
return core.identical(a, b);
|
||||
};
|
||||
dart.fn(expect._identical, core.bool, [dart.dynamic, dart.dynamic]);
|
||||
expect._CheckExceptionFn = dart.typedef('_CheckExceptionFn', () => dart.functionType(core.bool, [dart.dynamic]));
|
||||
expect._Nullary = dart.typedef('_Nullary', () => dart.functionType(dart.dynamic, []));
|
||||
expect.ExpectException = class ExpectException extends core.Object {
|
||||
new(message) {
|
||||
this.message = message;
|
||||
}
|
||||
toString() {
|
||||
return this.message;
|
||||
}
|
||||
};
|
||||
expect.ExpectException[dart.implements] = () => [core.Exception];
|
||||
dart.setSignature(expect.ExpectException, {
|
||||
constructors: () => ({new: [expect.ExpectException, [core.String]]})
|
||||
});
|
||||
expect.NoInline = class NoInline extends core.Object {
|
||||
new() {
|
||||
}
|
||||
};
|
||||
dart.setSignature(expect.NoInline, {
|
||||
constructors: () => ({new: [expect.NoInline, []]})
|
||||
});
|
||||
expect.TrustTypeAnnotations = class TrustTypeAnnotations extends core.Object {
|
||||
new() {
|
||||
}
|
||||
};
|
||||
dart.setSignature(expect.TrustTypeAnnotations, {
|
||||
constructors: () => ({new: [expect.TrustTypeAnnotations, []]})
|
||||
});
|
||||
expect.AssumeDynamic = class AssumeDynamic extends core.Object {
|
||||
new() {
|
||||
}
|
||||
};
|
||||
dart.setSignature(expect.AssumeDynamic, {
|
||||
constructors: () => ({new: [expect.AssumeDynamic, []]})
|
||||
});
|
||||
// Exports:
|
||||
exports.expect = expect;
|
||||
});
|
|
@ -1,303 +0,0 @@
|
|||
dart_library.library('expect', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const expect = Object.create(null);
|
||||
expect.Expect = class Expect extends core.Object {
|
||||
static _truncateString(string, start, end, length) {
|
||||
if (dart.notNull(end) - dart.notNull(start) > dart.notNull(length)) {
|
||||
end = dart.notNull(start) + dart.notNull(length);
|
||||
} else if (dart.notNull(end) - dart.notNull(start) < dart.notNull(length)) {
|
||||
let overflow = dart.notNull(length) - (dart.notNull(end) - dart.notNull(start));
|
||||
if (overflow > 10) overflow = 10;
|
||||
start = dart.notNull(start) - ((overflow + 1) / 2)[dartx.truncate]();
|
||||
end = dart.notNull(end) + (overflow / 2)[dartx.truncate]();
|
||||
if (dart.notNull(start) < 0) start = 0;
|
||||
if (dart.notNull(end) > dart.notNull(string[dartx.length])) end = string[dartx.length];
|
||||
}
|
||||
if (start == 0 && end == string[dartx.length]) return string;
|
||||
let buf = new core.StringBuffer();
|
||||
if (dart.notNull(start) > 0) buf.write("...");
|
||||
for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(i) + 1) {
|
||||
let code = string[dartx.codeUnitAt](i);
|
||||
if (dart.notNull(code) < 32) {
|
||||
buf.write("\\x");
|
||||
buf.write("0123456789abcdef"[dartx.get]((dart.notNull(code) / 16)[dartx.truncate]()));
|
||||
buf.write("0123456789abcdef"[dartx.get](code[dartx['%']](16)));
|
||||
} else {
|
||||
buf.writeCharCode(string[dartx.codeUnitAt](i));
|
||||
}
|
||||
}
|
||||
if (dart.notNull(end) < dart.notNull(string[dartx.length])) buf.write("...");
|
||||
return buf.toString();
|
||||
}
|
||||
static _stringDifference(expected, actual) {
|
||||
if (dart.notNull(expected[dartx.length]) < 20 && dart.notNull(actual[dartx.length]) < 20) return null;
|
||||
for (let i = 0; i < dart.notNull(expected[dartx.length]) && i < dart.notNull(actual[dartx.length]); i++) {
|
||||
if (expected[dartx.codeUnitAt](i) != actual[dartx.codeUnitAt](i)) {
|
||||
let start = i;
|
||||
i++;
|
||||
while (i < dart.notNull(expected[dartx.length]) && i < dart.notNull(actual[dartx.length])) {
|
||||
if (expected[dartx.codeUnitAt](i) == actual[dartx.codeUnitAt](i)) break;
|
||||
i++;
|
||||
}
|
||||
let end = i;
|
||||
let truncExpected = expect.Expect._truncateString(expected, start, end, 20);
|
||||
let truncActual = expect.Expect._truncateString(actual, start, end, 20);
|
||||
return dart.str`at index ${start}: Expected <${truncExpected}>, ` + dart.str`Found: <${truncActual}>`;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
static equals(expected, actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (dart.equals(expected, actual)) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
if (typeof expected == 'string' && typeof actual == 'string') {
|
||||
let stringDifference = expect.Expect._stringDifference(expected, actual);
|
||||
if (stringDifference != null) {
|
||||
expect.Expect._fail(dart.str`Expect.equals(${stringDifference}${msg}) fails.`);
|
||||
}
|
||||
}
|
||||
expect.Expect._fail(dart.str`Expect.equals(expected: <${expected}>, actual: <${actual}>${msg}) fails.`);
|
||||
}
|
||||
static isTrue(actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (dart.notNull(expect._identical(actual, true))) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
expect.Expect._fail(dart.str`Expect.isTrue(${actual}${msg}) fails.`);
|
||||
}
|
||||
static isFalse(actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (dart.notNull(expect._identical(actual, false))) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
expect.Expect._fail(dart.str`Expect.isFalse(${actual}${msg}) fails.`);
|
||||
}
|
||||
static isNull(actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (null == actual) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
expect.Expect._fail(dart.str`Expect.isNull(actual: <${actual}>${msg}) fails.`);
|
||||
}
|
||||
static isNotNull(actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (null != actual) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
expect.Expect._fail(dart.str`Expect.isNotNull(actual: <${actual}>${msg}) fails.`);
|
||||
}
|
||||
static identical(expected, actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (dart.notNull(expect._identical(expected, actual))) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
expect.Expect._fail(dart.str`Expect.identical(expected: <${expected}>, actual: <${actual}>${msg}) ` + "fails.");
|
||||
}
|
||||
static fail(msg) {
|
||||
expect.Expect._fail(dart.str`Expect.fail('${msg}')`);
|
||||
}
|
||||
static approxEquals(expected, actual, tolerance, reason) {
|
||||
if (tolerance === void 0) tolerance = null;
|
||||
if (reason === void 0) reason = null;
|
||||
if (tolerance == null) {
|
||||
tolerance = (dart.notNull(expected) / 10000.0)[dartx.abs]();
|
||||
}
|
||||
if (dart.notNull((dart.notNull(expected) - dart.notNull(actual))[dartx.abs]()) <= dart.notNull(tolerance)) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
expect.Expect._fail(dart.str`Expect.approxEquals(expected:<${expected}>, actual:<${actual}>, ` + dart.str`tolerance:<${tolerance}>${msg}) fails`);
|
||||
}
|
||||
static notEquals(unexpected, actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (!dart.equals(unexpected, actual)) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
expect.Expect._fail(dart.str`Expect.notEquals(unexpected: <${unexpected}>, actual:<${actual}>${msg}) ` + "fails.");
|
||||
}
|
||||
static listEquals(expected, actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
let n = dart.notNull(expected[dartx.length]) < dart.notNull(actual[dartx.length]) ? expected[dartx.length] : actual[dartx.length];
|
||||
for (let i = 0; i < dart.notNull(n); i++) {
|
||||
if (!dart.equals(expected[dartx.get](i), actual[dartx.get](i))) {
|
||||
expect.Expect._fail(dart.str`Expect.listEquals(at index ${i}, ` + dart.str`expected: <${expected[dartx.get](i)}>, actual: <${actual[dartx.get](i)}>${msg}) fails`);
|
||||
}
|
||||
}
|
||||
if (expected[dartx.length] != actual[dartx.length]) {
|
||||
expect.Expect._fail('Expect.listEquals(list length, ' + dart.str`expected: <${expected[dartx.length]}>, actual: <${actual[dartx.length]}>${msg}) ` + 'fails: Next element <' + dart.str`${dart.notNull(expected[dartx.length]) > dart.notNull(n) ? expected[dartx.get](n) : actual[dartx.get](n)}>`);
|
||||
}
|
||||
}
|
||||
static mapEquals(expected, actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
for (let key of expected[dartx.keys]) {
|
||||
if (!dart.notNull(actual[dartx.containsKey](key))) {
|
||||
expect.Expect._fail(dart.str`Expect.mapEquals(missing expected key: <${key}>${msg}) fails`);
|
||||
}
|
||||
expect.Expect.equals(expected[dartx.get](key), actual[dartx.get](key));
|
||||
}
|
||||
for (let key of actual[dartx.keys]) {
|
||||
if (!dart.notNull(expected[dartx.containsKey](key))) {
|
||||
expect.Expect._fail(dart.str`Expect.mapEquals(unexpected key: <${key}>${msg}) fails`);
|
||||
}
|
||||
}
|
||||
}
|
||||
static stringEquals(expected, actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
if (expected == actual) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
let defaultMessage = dart.str`Expect.stringEquals(expected: <${expected}>", <${actual}>${msg}) fails`;
|
||||
if (expected == null || actual == null) {
|
||||
expect.Expect._fail(dart.str`${defaultMessage}`);
|
||||
}
|
||||
let left = 0;
|
||||
let right = 0;
|
||||
let eLen = expected[dartx.length];
|
||||
let aLen = actual[dartx.length];
|
||||
while (true) {
|
||||
if (left == eLen || left == aLen || expected[dartx.get](left) != actual[dartx.get](left)) {
|
||||
break;
|
||||
}
|
||||
left++;
|
||||
}
|
||||
let eRem = dart.notNull(eLen) - left;
|
||||
let aRem = dart.notNull(aLen) - left;
|
||||
while (true) {
|
||||
if (right == eRem || right == aRem || expected[dartx.get](dart.notNull(eLen) - right - 1) != actual[dartx.get](dart.notNull(aLen) - right - 1)) {
|
||||
break;
|
||||
}
|
||||
right++;
|
||||
}
|
||||
let leftSnippet = expected[dartx.substring](left < 10 ? 0 : left - 10, left);
|
||||
let rightSnippetLength = right < 10 ? right : 10;
|
||||
let rightSnippet = expected[dartx.substring](dart.notNull(eLen) - right, dart.notNull(eLen) - right + rightSnippetLength);
|
||||
let eSnippet = expected[dartx.substring](left, dart.notNull(eLen) - right);
|
||||
let aSnippet = actual[dartx.substring](left, dart.notNull(aLen) - right);
|
||||
if (dart.notNull(eSnippet[dartx.length]) > 43) {
|
||||
eSnippet = dart.notNull(eSnippet[dartx.substring](0, 20)) + "..." + dart.notNull(eSnippet[dartx.substring](dart.notNull(eSnippet[dartx.length]) - 20));
|
||||
}
|
||||
if (dart.notNull(aSnippet[dartx.length]) > 43) {
|
||||
aSnippet = dart.notNull(aSnippet[dartx.substring](0, 20)) + "..." + dart.notNull(aSnippet[dartx.substring](dart.notNull(aSnippet[dartx.length]) - 20));
|
||||
}
|
||||
let leftLead = "...";
|
||||
let rightTail = "...";
|
||||
if (left <= 10) leftLead = "";
|
||||
if (right <= 10) rightTail = "";
|
||||
let diff = dart.str`\nDiff (${left}..${dart.notNull(eLen) - right}/${dart.notNull(aLen) - right}):\n` + dart.str`${leftLead}${leftSnippet}[ ${eSnippet} ]${rightSnippet}${rightTail}\n` + dart.str`${leftLead}${leftSnippet}[ ${aSnippet} ]${rightSnippet}${rightTail}`;
|
||||
expect.Expect._fail(dart.str`${defaultMessage}${diff}`);
|
||||
}
|
||||
static setEquals(expected, actual, reason) {
|
||||
if (reason === void 0) reason = null;
|
||||
let missingSet = core.Set.from(expected);
|
||||
missingSet.removeAll(actual);
|
||||
let extraSet = core.Set.from(actual);
|
||||
extraSet.removeAll(expected);
|
||||
if (dart.notNull(extraSet.isEmpty) && dart.notNull(missingSet.isEmpty)) return;
|
||||
let msg = expect.Expect._getMessage(reason);
|
||||
let sb = new core.StringBuffer(dart.str`Expect.setEquals(${msg}) fails`);
|
||||
if (!dart.notNull(missingSet.isEmpty)) {
|
||||
sb.write('\nExpected collection does not contain: ');
|
||||
}
|
||||
for (let val of missingSet) {
|
||||
sb.write(dart.str`${val} `);
|
||||
}
|
||||
if (!dart.notNull(extraSet.isEmpty)) {
|
||||
sb.write('\nExpected collection should not contain: ');
|
||||
}
|
||||
for (let val of extraSet) {
|
||||
sb.write(dart.str`${val} `);
|
||||
}
|
||||
expect.Expect._fail(sb.toString());
|
||||
}
|
||||
static throws(f, check, reason) {
|
||||
if (check === void 0) check = null;
|
||||
if (reason === void 0) reason = null;
|
||||
let msg = reason == null ? "" : dart.str`(${reason})`;
|
||||
if (!dart.is(f, expect._Nullary)) {
|
||||
expect.Expect._fail(dart.str`Expect.throws${msg}: Function f not callable with zero arguments`);
|
||||
}
|
||||
try {
|
||||
f();
|
||||
} catch (e) {
|
||||
let s = dart.stackTrace(e);
|
||||
if (check != null) {
|
||||
if (!dart.notNull(dart.dcall(check, e))) {
|
||||
expect.Expect._fail(dart.str`Expect.throws${msg}: Unexpected '${e}'\n${s}`);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
expect.Expect._fail(dart.str`Expect.throws${msg} fails: Did not throw`);
|
||||
}
|
||||
static _getMessage(reason) {
|
||||
return reason == null ? "" : dart.str`, '${reason}'`;
|
||||
}
|
||||
static _fail(message) {
|
||||
dart.throw(new expect.ExpectException(message));
|
||||
}
|
||||
};
|
||||
dart.setSignature(expect.Expect, {
|
||||
statics: () => ({
|
||||
_truncateString: [core.String, [core.String, core.int, core.int, core.int]],
|
||||
_stringDifference: [core.String, [core.String, core.String]],
|
||||
equals: [dart.void, [dart.dynamic, dart.dynamic], [core.String]],
|
||||
isTrue: [dart.void, [dart.dynamic], [core.String]],
|
||||
isFalse: [dart.void, [dart.dynamic], [core.String]],
|
||||
isNull: [dart.void, [dart.dynamic], [core.String]],
|
||||
isNotNull: [dart.void, [dart.dynamic], [core.String]],
|
||||
identical: [dart.void, [dart.dynamic, dart.dynamic], [core.String]],
|
||||
fail: [dart.void, [core.String]],
|
||||
approxEquals: [dart.void, [core.num, core.num], [core.num, core.String]],
|
||||
notEquals: [dart.void, [dart.dynamic, dart.dynamic], [core.String]],
|
||||
listEquals: [dart.void, [core.List, core.List], [core.String]],
|
||||
mapEquals: [dart.void, [core.Map, core.Map], [core.String]],
|
||||
stringEquals: [dart.void, [core.String, core.String], [core.String]],
|
||||
setEquals: [dart.void, [core.Iterable, core.Iterable], [core.String]],
|
||||
throws: [dart.void, [dart.functionType(dart.void, [])], [expect._CheckExceptionFn, core.String]],
|
||||
_getMessage: [core.String, [core.String]],
|
||||
_fail: [dart.void, [core.String]]
|
||||
}),
|
||||
names: ['_truncateString', '_stringDifference', 'equals', 'isTrue', 'isFalse', 'isNull', 'isNotNull', 'identical', 'fail', 'approxEquals', 'notEquals', 'listEquals', 'mapEquals', 'stringEquals', 'setEquals', 'throws', '_getMessage', '_fail']
|
||||
});
|
||||
expect._identical = function(a, b) {
|
||||
return core.identical(a, b);
|
||||
};
|
||||
dart.fn(expect._identical, core.bool, [dart.dynamic, dart.dynamic]);
|
||||
expect._CheckExceptionFn = dart.typedef('_CheckExceptionFn', () => dart.functionType(core.bool, [dart.dynamic]));
|
||||
expect._Nullary = dart.typedef('_Nullary', () => dart.functionType(dart.dynamic, []));
|
||||
expect.ExpectException = class ExpectException extends core.Object {
|
||||
new(message) {
|
||||
this.message = message;
|
||||
}
|
||||
toString() {
|
||||
return this.message;
|
||||
}
|
||||
};
|
||||
expect.ExpectException[dart.implements] = () => [core.Exception];
|
||||
dart.setSignature(expect.ExpectException, {
|
||||
constructors: () => ({new: [expect.ExpectException, [core.String]]})
|
||||
});
|
||||
expect.NoInline = class NoInline extends core.Object {
|
||||
new() {
|
||||
}
|
||||
};
|
||||
dart.setSignature(expect.NoInline, {
|
||||
constructors: () => ({new: [expect.NoInline, []]})
|
||||
});
|
||||
expect.TrustTypeAnnotations = class TrustTypeAnnotations extends core.Object {
|
||||
new() {
|
||||
}
|
||||
};
|
||||
dart.setSignature(expect.TrustTypeAnnotations, {
|
||||
constructors: () => ({new: [expect.TrustTypeAnnotations, []]})
|
||||
});
|
||||
expect.AssumeDynamic = class AssumeDynamic extends core.Object {
|
||||
new() {
|
||||
}
|
||||
};
|
||||
dart.setSignature(expect.AssumeDynamic, {
|
||||
constructors: () => ({new: [expect.AssumeDynamic, []]})
|
||||
});
|
||||
// Exports:
|
||||
exports.expect = expect;
|
||||
});
|
|
@ -1,24 +0,0 @@
|
|||
dart_library.library('extensions', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const collection = dart_sdk.collection;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const extensions = Object.create(null);
|
||||
extensions.StringIterable = class StringIterable extends collection.IterableBase$(core.String) {
|
||||
new() {
|
||||
this.iterator = null;
|
||||
super.new();
|
||||
}
|
||||
};
|
||||
dart.setSignature(extensions.StringIterable, {});
|
||||
dart.defineExtensionMembers(extensions.StringIterable, ['iterator']);
|
||||
extensions.main = function() {
|
||||
return new extensions.StringIterable();
|
||||
};
|
||||
dart.fn(extensions.main);
|
||||
// Exports:
|
||||
exports.extensions = extensions;
|
||||
});
|
|
@ -1,149 +0,0 @@
|
|||
dart_library.library('fieldtest', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const fieldtest = Object.create(null);
|
||||
fieldtest.A = class A extends core.Object {
|
||||
new() {
|
||||
this.x = 42;
|
||||
}
|
||||
};
|
||||
fieldtest.B$ = dart.generic(T => {
|
||||
class B extends core.Object {
|
||||
new() {
|
||||
this.x = null;
|
||||
this.y = null;
|
||||
this.z = null;
|
||||
}
|
||||
}
|
||||
return B;
|
||||
});
|
||||
fieldtest.B = fieldtest.B$();
|
||||
fieldtest.foo = function(a) {
|
||||
core.print(a.x);
|
||||
return a.x;
|
||||
};
|
||||
dart.fn(fieldtest.foo, core.int, [fieldtest.A]);
|
||||
fieldtest.bar = function(a) {
|
||||
core.print(dart.dload(a, 'x'));
|
||||
return dart.as(dart.dload(a, 'x'), core.int);
|
||||
};
|
||||
dart.fn(fieldtest.bar, core.int, [dart.dynamic]);
|
||||
fieldtest.baz = function(a) {
|
||||
return a.x;
|
||||
};
|
||||
dart.fn(fieldtest.baz, dart.dynamic, [fieldtest.A]);
|
||||
fieldtest.compute = function() {
|
||||
return 123;
|
||||
};
|
||||
dart.fn(fieldtest.compute, core.int, []);
|
||||
dart.defineLazy(fieldtest, {
|
||||
get y() {
|
||||
return dart.notNull(fieldtest.compute()) + 444;
|
||||
},
|
||||
set y(_) {}
|
||||
});
|
||||
dart.copyProperties(fieldtest, {
|
||||
get q() {
|
||||
return 'life, ' + 'the universe ' + 'and everything';
|
||||
}
|
||||
});
|
||||
dart.copyProperties(fieldtest, {
|
||||
get z() {
|
||||
return 42;
|
||||
},
|
||||
set z(value) {
|
||||
fieldtest.y = dart.as(value, core.int);
|
||||
}
|
||||
});
|
||||
fieldtest.BaseWithGetter = class BaseWithGetter extends core.Object {
|
||||
get foo() {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
fieldtest.Derived = class Derived extends fieldtest.BaseWithGetter {
|
||||
new() {
|
||||
this[foo] = 2;
|
||||
this.bar = 3;
|
||||
}
|
||||
get foo() {
|
||||
return this[foo];
|
||||
}
|
||||
set foo(value) {
|
||||
this[foo] = value;
|
||||
}
|
||||
};
|
||||
const foo = Symbol(fieldtest.Derived.name + "." + 'foo'.toString());
|
||||
fieldtest.Generic$ = dart.generic(T => {
|
||||
class Generic extends core.Object {
|
||||
foo(t) {
|
||||
dart.as(t, T);
|
||||
return core.print(dart.notNull(fieldtest.Generic.bar) + dart.notNull(dart.as(t, core.String)));
|
||||
}
|
||||
}
|
||||
dart.setSignature(Generic, {
|
||||
methods: () => ({foo: [dart.dynamic, [T]]})
|
||||
});
|
||||
return Generic;
|
||||
});
|
||||
fieldtest.Generic = fieldtest.Generic$();
|
||||
fieldtest.Generic.bar = 'hello';
|
||||
fieldtest.StaticFieldOrder1 = class StaticFieldOrder1 extends core.Object {};
|
||||
fieldtest.StaticFieldOrder1.d = 4;
|
||||
dart.defineLazy(fieldtest.StaticFieldOrder1, {
|
||||
get a() {
|
||||
return fieldtest.StaticFieldOrder1.b + 1;
|
||||
},
|
||||
get c() {
|
||||
return fieldtest.StaticFieldOrder1.d + 2;
|
||||
},
|
||||
get b() {
|
||||
return fieldtest.StaticFieldOrder1.c + 3;
|
||||
}
|
||||
});
|
||||
fieldtest.StaticFieldOrder2 = class StaticFieldOrder2 extends core.Object {};
|
||||
fieldtest.StaticFieldOrder2.d = 4;
|
||||
dart.defineLazy(fieldtest.StaticFieldOrder2, {
|
||||
get a() {
|
||||
return fieldtest.StaticFieldOrder2.b + 1;
|
||||
},
|
||||
get c() {
|
||||
return fieldtest.StaticFieldOrder2.d + 2;
|
||||
},
|
||||
get b() {
|
||||
return fieldtest.StaticFieldOrder2.c + 3;
|
||||
}
|
||||
});
|
||||
fieldtest.MyEnum = class MyEnum extends core.Object {
|
||||
new(index) {
|
||||
this.index = index;
|
||||
}
|
||||
toString() {
|
||||
return {
|
||||
0: "MyEnum.Val1",
|
||||
1: "MyEnum.Val2",
|
||||
2: "MyEnum.Val3",
|
||||
3: "MyEnum.Val4"
|
||||
}[this.index];
|
||||
}
|
||||
};
|
||||
fieldtest.MyEnum.Val1 = dart.const(new fieldtest.MyEnum(0));
|
||||
fieldtest.MyEnum.Val2 = dart.const(new fieldtest.MyEnum(1));
|
||||
fieldtest.MyEnum.Val3 = dart.const(new fieldtest.MyEnum(2));
|
||||
fieldtest.MyEnum.Val4 = dart.const(new fieldtest.MyEnum(3));
|
||||
fieldtest.MyEnum.values = dart.const(dart.list([fieldtest.MyEnum.Val1, fieldtest.MyEnum.Val2, fieldtest.MyEnum.Val3, fieldtest.MyEnum.Val4], fieldtest.MyEnum));
|
||||
fieldtest.main = function() {
|
||||
let a = new fieldtest.A();
|
||||
fieldtest.foo(a);
|
||||
fieldtest.bar(a);
|
||||
core.print(fieldtest.baz(a));
|
||||
core.print(new (fieldtest.Generic$(core.String))().foo(' world'));
|
||||
core.print(fieldtest.MyEnum.values);
|
||||
};
|
||||
dart.fn(fieldtest.main, dart.void, []);
|
||||
// Exports:
|
||||
exports.fieldtest = fieldtest;
|
||||
});
|
|
@ -1,29 +0,0 @@
|
|||
dart_library.library('functions', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const functions = Object.create(null);
|
||||
functions.bootstrap = function() {
|
||||
return dart.list([new functions.Foo()], functions.Foo);
|
||||
};
|
||||
dart.lazyFn(functions.bootstrap, () => [core.List$(functions.Foo), []]);
|
||||
functions.A2B$ = dart.generic((A, B) => {
|
||||
const A2B = dart.typedef('A2B', () => dart.functionType(B, [A]));
|
||||
return A2B;
|
||||
});
|
||||
functions.A2B = functions.A2B$();
|
||||
functions.id = function(f) {
|
||||
return f;
|
||||
};
|
||||
dart.lazyFn(functions.id, () => [functions.A2B$(functions.Foo, functions.Foo), [functions.A2B$(functions.Foo, functions.Foo)]]);
|
||||
functions.Foo = class Foo extends core.Object {};
|
||||
functions.main = function() {
|
||||
core.print(functions.bootstrap()[dartx.get](0));
|
||||
};
|
||||
dart.fn(functions.main, dart.void, []);
|
||||
// Exports:
|
||||
exports.functions = functions;
|
||||
});
|
|
@ -1,11 +0,0 @@
|
|||
dart_library.library('html_config', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const html_config = Object.create(null);
|
||||
// Exports:
|
||||
exports.html_config = html_config;
|
||||
});
|
|
@ -1,31 +0,0 @@
|
|||
dart_library.library('js', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const js = dart_sdk.js;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const js$ = Object.create(null);
|
||||
js$.JS = class JS extends core.Object {
|
||||
new(name) {
|
||||
if (name === void 0) name = null;
|
||||
this.name = name;
|
||||
}
|
||||
};
|
||||
dart.setSignature(js$.JS, {
|
||||
constructors: () => ({new: [js$.JS, [], [core.String]]})
|
||||
});
|
||||
js$._Anonymous = class _Anonymous extends core.Object {
|
||||
new() {
|
||||
}
|
||||
};
|
||||
dart.setSignature(js$._Anonymous, {
|
||||
constructors: () => ({new: [js$._Anonymous, []]})
|
||||
});
|
||||
js$.anonymous = dart.const(new js$._Anonymous());
|
||||
js$.allowInteropCaptureThis = js.allowInteropCaptureThis;
|
||||
js$.allowInterop = js.allowInterop;
|
||||
// Exports:
|
||||
exports.js = js$;
|
||||
});
|
|
@ -1,326 +0,0 @@
|
|||
[error] Target of URI does not exist: 'dom.dart' (test/codegen/js_test.dart, line 10, col 8)
|
||||
[error] Target of URI does not exist: 'minitest.dart' (test/codegen/js_test.dart, line 11, col 8)
|
||||
[error] The function 'group' is not defined. (test/codegen/js_test.dart, line 39, col 3)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 41, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 44, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 49, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 52, col 7)
|
||||
[error] The function 'equals' is not defined. (test/codegen/js_test.dart, line 52, col 18)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 57, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 62, col 7)
|
||||
[error] The function 'isNot' is not defined. (test/codegen/js_test.dart, line 62, col 20)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 63, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 68, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 71, col 7)
|
||||
[error] The function 'same' is not defined. (test/codegen/js_test.dart, line 71, col 30)
|
||||
[error] The function 'group' is not defined. (test/codegen/js_test.dart, line 75, col 5)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 76, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 80, col 9)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 82, col 9)
|
||||
[error] The function 'group' is not defined. (test/codegen/js_test.dart, line 88, col 3)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 90, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 91, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 92, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 95, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 96, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 97, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 100, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 102, col 7)
|
||||
[error] The function 'group' is not defined. (test/codegen/js_test.dart, line 107, col 3)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 109, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 111, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 112, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 113, col 7)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 113, col 43)
|
||||
[error] Undefined name 'isNoSuchMethodError' (test/codegen/js_test.dart, line 113, col 51)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 116, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 119, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 120, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 123, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 125, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 129, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 132, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 133, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 136, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 139, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 141, col 7)
|
||||
[error] Undefined name 'isNotNull' (test/codegen/js_test.dart, line 141, col 39)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 144, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 146, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 149, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 152, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 155, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 159, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 162, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 167, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 170, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 172, col 7)
|
||||
[error] Undefined name 'isNotNull' (test/codegen/js_test.dart, line 172, col 17)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 175, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 178, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 180, col 7)
|
||||
[error] Undefined name 'isNotNull' (test/codegen/js_test.dart, line 180, col 17)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 181, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 182, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 185, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 187, col 7)
|
||||
[error] Undefined name 'isNotNull' (test/codegen/js_test.dart, line 187, col 17)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 188, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 191, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 192, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 195, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 198, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 200, col 7)
|
||||
[error] Undefined name 'isNotNull' (test/codegen/js_test.dart, line 200, col 39)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 203, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 206, col 9)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 208, col 7)
|
||||
[error] The function 'group' is not defined. (test/codegen/js_test.dart, line 212, col 3)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 214, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 216, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 219, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 220, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 223, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 225, col 7)
|
||||
[error] The function 'same' is not defined. (test/codegen/js_test.dart, line 225, col 64)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 228, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 229, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 230, col 7)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 230, col 50)
|
||||
[error] Undefined name 'isNoSuchMethodError' (test/codegen/js_test.dart, line 230, col 58)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 233, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 234, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 238, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 239, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 240, col 7)
|
||||
[error] The function 'group' is not defined. (test/codegen/js_test.dart, line 245, col 3)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 247, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 250, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 251, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 254, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 257, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 260, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 261, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 264, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 266, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 269, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 270, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 274, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 276, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 279, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 280, col 7)
|
||||
[error] The function 'isNot' is not defined. (test/codegen/js_test.dart, line 280, col 17)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 281, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 285, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 287, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 288, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 289, col 7)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 289, col 31)
|
||||
[error] Undefined name 'isRangeError' (test/codegen/js_test.dart, line 289, col 39)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 290, col 7)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 290, col 30)
|
||||
[error] Undefined name 'isRangeError' (test/codegen/js_test.dart, line 290, col 38)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 293, col 4)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 297, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 298, col 7)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 298, col 35)
|
||||
[error] Undefined name 'isRangeError' (test/codegen/js_test.dart, line 298, col 43)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 299, col 7)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 299, col 34)
|
||||
[error] Undefined name 'isRangeError' (test/codegen/js_test.dart, line 299, col 42)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 302, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 304, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 306, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 308, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 310, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 313, col 6)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 316, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 318, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 321, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 324, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 327, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 330, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 333, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 335, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 337, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 338, col 7)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 338, col 42)
|
||||
[error] Undefined name 'isRangeError' (test/codegen/js_test.dart, line 338, col 50)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 339, col 7)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 339, col 43)
|
||||
[error] Undefined name 'isRangeError' (test/codegen/js_test.dart, line 339, col 51)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 342, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 344, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 345, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 346, col 7)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 346, col 39)
|
||||
[error] Undefined name 'isRangeError' (test/codegen/js_test.dart, line 346, col 47)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 347, col 7)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 347, col 40)
|
||||
[error] Undefined name 'isRangeError' (test/codegen/js_test.dart, line 347, col 48)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 350, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 352, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 353, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 355, col 7)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 355, col 40)
|
||||
[error] Undefined name 'isRangeError' (test/codegen/js_test.dart, line 355, col 48)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 358, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 361, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 362, col 7)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 362, col 46)
|
||||
[error] Undefined name 'isRangeError' (test/codegen/js_test.dart, line 362, col 54)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 363, col 7)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 363, col 45)
|
||||
[error] Undefined name 'isRangeError' (test/codegen/js_test.dart, line 363, col 53)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 364, col 7)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 364, col 45)
|
||||
[error] Undefined name 'isRangeError' (test/codegen/js_test.dart, line 364, col 53)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 367, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 370, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 372, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 375, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 378, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 381, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 384, col 7)
|
||||
[error] The function 'group' is not defined. (test/codegen/js_test.dart, line 389, col 3)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 391, col 5)
|
||||
[error] Undefined name 'document' (test/codegen/js_test.dart, line 392, col 49)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 394, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 395, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 396, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 399, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 401, col 9)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 402, col 13)
|
||||
[error] The function 'group' is not defined. (test/codegen/js_test.dart, line 408, col 3)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 409, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 410, col 7)
|
||||
[error] Undefined name 'throws' (test/codegen/js_test.dart, line 410, col 58)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 413, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 418, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 419, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 423, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 429, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 432, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 435, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 439, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 442, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 445, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 448, col 7)
|
||||
[error] The function 'group' is not defined. (test/codegen/js_test.dart, line 454, col 3)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 456, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 459, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 460, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 462, col 9)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 466, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 469, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 470, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 472, col 9)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 476, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 479, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 481, col 9)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 485, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 495, col 7)
|
||||
[error] The operator '[]' is not defined for the class 'Object'. (test/codegen/js_test.dart, line 495, col 43)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 496, col 7)
|
||||
[error] The operator '[]' is not defined for the class 'Object'. (test/codegen/js_test.dart, line 496, col 46)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 497, col 7)
|
||||
[error] The operator '[]' is not defined for the class 'Object'. (test/codegen/js_test.dart, line 497, col 46)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 498, col 7)
|
||||
[error] The operator '[]' is not defined for the class 'Object'. (test/codegen/js_test.dart, line 498, col 45)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 499, col 7)
|
||||
[error] The operator '[]' is not defined for the class 'Object'. (test/codegen/js_test.dart, line 499, col 45)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 500, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 501, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 504, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 505, col 7)
|
||||
[error] The function 'throwsA' is not defined. (test/codegen/js_test.dart, line 506, col 11)
|
||||
[error] The function 'group' is not defined. (test/codegen/js_test.dart, line 510, col 3)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 512, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 515, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 516, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 518, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 521, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 523, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 525, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 528, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 530, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 531, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 534, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 536, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 537, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 538, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 541, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 544, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 545, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 547, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 550, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 553, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 554, col 7)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 557, col 5)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 559, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 560, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 562, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 563, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 567, col 7)
|
||||
[error] The function 'group' is not defined. (test/codegen/js_test.dart, line 572, col 3)
|
||||
[error] The function 'group' is not defined. (test/codegen/js_test.dart, line 574, col 5)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 576, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 578, col 9)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 581, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 582, col 9)
|
||||
[error] The name 'Window' is not defined and cannot be used in an 'is' expression (test/codegen/js_test.dart, line 582, col 37)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 585, col 7)
|
||||
[error] Undefined name 'document' (test/codegen/js_test.dart, line 586, col 22)
|
||||
[error] Undefined name 'document' (test/codegen/js_test.dart, line 587, col 9)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 592, col 9)
|
||||
[error] The function 'isNot' is not defined. (test/codegen/js_test.dart, line 592, col 31)
|
||||
[error] The name 'Window' is not defined and cannot be used in an 'is' expression (test/codegen/js_test.dart, line 592, col 49)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 593, col 9)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 597, col 9)
|
||||
[error] The function 'isNot' is not defined. (test/codegen/js_test.dart, line 597, col 28)
|
||||
[error] The name 'Node' is not defined and cannot be used in an 'is' expression (test/codegen/js_test.dart, line 597, col 46)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 598, col 9)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 603, col 11)
|
||||
[error] The function 'isNot' is not defined. (test/codegen/js_test.dart, line 603, col 21)
|
||||
[error] The name 'Event' is not defined and cannot be used in an 'is' expression (test/codegen/js_test.dart, line 603, col 39)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 604, col 11)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 609, col 9)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 612, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 613, col 9)
|
||||
[error] The name 'Document' is not defined and cannot be used in an 'is' expression (test/codegen/js_test.dart, line 613, col 39)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 616, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 618, col 9)
|
||||
[error] The name 'Blob' is not defined and cannot be used in an 'is' expression (test/codegen/js_test.dart, line 618, col 24)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 619, col 9)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 622, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 624, col 9)
|
||||
[error] The name 'DivElement' is not defined and cannot be used in an 'is' expression (test/codegen/js_test.dart, line 624, col 24)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 627, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 629, col 9)
|
||||
[error] The name 'Event' is not defined and cannot be used in an 'is' expression (test/codegen/js_test.dart, line 629, col 25)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 632, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 634, col 9)
|
||||
[error] The name 'ImageData' is not defined and cannot be used in an 'is' expression (test/codegen/js_test.dart, line 634, col 24)
|
||||
[error] The function 'group' is not defined. (test/codegen/js_test.dart, line 639, col 5)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 641, col 7)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 644, col 9)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 649, col 7)
|
||||
[error] Undefined name 'window' (test/codegen/js_test.dart, line 650, col 24)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 652, col 9)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 657, col 7)
|
||||
[error] Undefined name 'document' (test/codegen/js_test.dart, line 658, col 24)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 660, col 9)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 665, col 7)
|
||||
[error] Undefined class 'Blob' (test/codegen/js_test.dart, line 667, col 28)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 669, col 9)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 674, col 7)
|
||||
[error] Undefined name 'document' (test/codegen/js_test.dart, line 675, col 24)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 677, col 9)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 682, col 7)
|
||||
[error] Undefined class 'CustomEvent' (test/codegen/js_test.dart, line 683, col 28)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 685, col 9)
|
||||
[error] The function 'test' is not defined. (test/codegen/js_test.dart, line 693, col 7)
|
||||
[error] Undefined class 'CanvasElement' (test/codegen/js_test.dart, line 694, col 9)
|
||||
[error] Undefined name 'document' (test/codegen/js_test.dart, line 694, col 32)
|
||||
[error] The name 'CanvasRenderingContext2D' is not a type and cannot be used in an 'as' expression (test/codegen/js_test.dart, line 695, col 46)
|
||||
[error] The function 'expect' is not defined. (test/codegen/js_test.dart, line 698, col 9)
|
|
@ -1,23 +0,0 @@
|
|||
dart_library.library('map_keys', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const math = dart_sdk.math;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const map_keys = Object.create(null);
|
||||
map_keys.main = function() {
|
||||
core.print(dart.map({'1': 2, '3': 4, '5': 6}));
|
||||
core.print(dart.map([1, 2, 3, 4, 5, 6]));
|
||||
core.print(dart.map({'1': 2, [dart.str`${dart.notNull(math.Random.new().nextInt(2)) + 2}`]: 4, '5': 6}));
|
||||
let x = '3';
|
||||
core.print(dart.map(['1', 2, x, 4, '5', 6]));
|
||||
core.print(dart.map(['1', 2, null, 4, '5', 6]));
|
||||
};
|
||||
dart.fn(map_keys.main);
|
||||
// Exports:
|
||||
exports.map_keys = map_keys;
|
||||
});
|
||||
|
||||
//# sourceMappingURL=map_keys.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"sourceRoot":"","sources":["../map_keys.dart"],"names":["print","x"],"mappings":";;;;;;;;;AAKA,kBAAI,WAAG;AAEL,IAAA,AAAAA,UAAK,CAAC,eAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;AAAC,AAElC,IAAA,AAAAA,UAAK,CAAC,UAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAAC,AAE5B,IAAA,AAAAA,UAAK,CAAC,eAAO,CAAC,GAAE,WAAC,aAAE,AAAA,iBAAY,SAAS,CAAC,CAAC,IAAG,CAAC,AAAC,EAAC,GAAE,CAAC,OAAO,CAAC,EAAE,CAAC;AAAC,AAC/D,YAAW,GAAG;AAAC,AAEf,IAAA,AAAAA,UAAK,CAAC,UAAE,GAAG,EAAE,CAAC,EAAEC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;AAAC,AAEhC,IAAA,AAAAD,UAAK,CAAC,UAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;AAAC,GAErC,AAAA;AAAA","file":"map_keys.js"}
|
|
@ -1,95 +0,0 @@
|
|||
dart_library.library('methods', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const methods = Object.create(null);
|
||||
const _c = Symbol('_c');
|
||||
methods.A = class A extends core.Object {
|
||||
new() {
|
||||
this[_c] = 3;
|
||||
}
|
||||
x() {
|
||||
return 42;
|
||||
}
|
||||
y(a) {
|
||||
return a;
|
||||
}
|
||||
z(b) {
|
||||
if (b === void 0) b = null;
|
||||
return dart.asInt(b);
|
||||
}
|
||||
zz(b) {
|
||||
if (b === void 0) b = 0;
|
||||
return b;
|
||||
}
|
||||
w(a, opts) {
|
||||
let b = opts && 'b' in opts ? opts.b : null;
|
||||
return dart.asInt(dart.notNull(a) + dart.notNull(b));
|
||||
}
|
||||
ww(a, opts) {
|
||||
let b = opts && 'b' in opts ? opts.b : 0;
|
||||
return dart.notNull(a) + dart.notNull(b);
|
||||
}
|
||||
clashWithObjectProperty(opts) {
|
||||
let constructor = opts && 'constructor' in opts ? opts.constructor : null;
|
||||
return constructor;
|
||||
}
|
||||
clashWithJsReservedName(opts) {
|
||||
let func = opts && 'function' in opts ? opts.function : null;
|
||||
return func;
|
||||
}
|
||||
get a() {
|
||||
return this.x();
|
||||
}
|
||||
set b(b) {}
|
||||
get c() {
|
||||
return this[_c];
|
||||
}
|
||||
set c(c) {
|
||||
this[_c] = c;
|
||||
}
|
||||
};
|
||||
dart.setSignature(methods.A, {
|
||||
methods: () => ({
|
||||
x: [core.int, []],
|
||||
y: [core.int, [core.int]],
|
||||
z: [core.int, [], [core.num]],
|
||||
zz: [core.int, [], [core.int]],
|
||||
w: [core.int, [core.int], {b: core.num}],
|
||||
ww: [core.int, [core.int], {b: core.int}],
|
||||
clashWithObjectProperty: [dart.dynamic, [], {constructor: dart.dynamic}],
|
||||
clashWithJsReservedName: [dart.dynamic, [], {function: dart.dynamic}]
|
||||
})
|
||||
});
|
||||
methods.Bar = class Bar extends core.Object {
|
||||
call(x) {
|
||||
return core.print(dart.str`hello from ${x}`);
|
||||
}
|
||||
};
|
||||
dart.setSignature(methods.Bar, {
|
||||
methods: () => ({call: [dart.dynamic, [dart.dynamic]]})
|
||||
});
|
||||
methods.Foo = class Foo extends core.Object {
|
||||
new() {
|
||||
this.bar = new methods.Bar();
|
||||
}
|
||||
};
|
||||
methods.test = function() {
|
||||
let f = new methods.Foo();
|
||||
dart.dsend(f, 'bar', "Bar's call method!");
|
||||
let a = new methods.A();
|
||||
let g = dart.bind(a, 'x');
|
||||
let aa = new methods.A();
|
||||
let h = dart.dload(aa, 'x');
|
||||
let ts = dart.bind(a, 'toString');
|
||||
let nsm = dart.bind(a, 'noSuchMethod');
|
||||
let c = dart.bind("", dartx.padLeft);
|
||||
let r = dart.bind(3.0, dartx.floor);
|
||||
};
|
||||
dart.fn(methods.test);
|
||||
// Exports:
|
||||
exports.methods = methods;
|
||||
});
|
|
@ -1,69 +0,0 @@
|
|||
dart_library.library('misc', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const misc = Object.create(null);
|
||||
misc._Uninitialized = class _Uninitialized extends core.Object {
|
||||
new() {
|
||||
}
|
||||
};
|
||||
dart.setSignature(misc._Uninitialized, {
|
||||
constructors: () => ({new: [misc._Uninitialized, []]})
|
||||
});
|
||||
misc.UNINITIALIZED = dart.const(new misc._Uninitialized());
|
||||
misc.Generic$ = dart.generic(T => {
|
||||
class Generic extends core.Object {
|
||||
get type() {
|
||||
return dart.wrapType(misc.Generic);
|
||||
}
|
||||
m() {
|
||||
return core.print(dart.wrapType(T));
|
||||
}
|
||||
}
|
||||
dart.setSignature(Generic, {
|
||||
methods: () => ({m: [dart.dynamic, []]})
|
||||
});
|
||||
return Generic;
|
||||
});
|
||||
misc.Generic = misc.Generic$();
|
||||
misc.Base = class Base extends core.Object {
|
||||
new() {
|
||||
this.x = 1;
|
||||
this.y = 2;
|
||||
}
|
||||
['=='](obj) {
|
||||
return dart.is(obj, misc.Base) && obj.x == this.x && obj.y == this.y;
|
||||
}
|
||||
};
|
||||
misc.Derived = class Derived extends core.Object {
|
||||
new() {
|
||||
this.z = 3;
|
||||
}
|
||||
['=='](obj) {
|
||||
return dart.is(obj, misc.Derived) && obj.z == this.z && super['=='](obj);
|
||||
}
|
||||
};
|
||||
misc._isWhitespace = function(ch) {
|
||||
return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
|
||||
};
|
||||
dart.fn(misc._isWhitespace, core.bool, [core.String]);
|
||||
misc.expr = 'foo';
|
||||
misc._escapeMap = dart.const(dart.map({'\n': '\\n', '\r': '\\r', '\f': '\\f', '\b': '\\b', '\t': '\\t', '\v': '\\v', '': '\\x7F', [dart.str`\${${misc.expr}}`]: ''}));
|
||||
misc.main = function() {
|
||||
core.print(dart.toString(1));
|
||||
core.print(dart.toString(1.0));
|
||||
core.print(dart.toString(1.1));
|
||||
let x = 42;
|
||||
core.print(dart.equals(x, dart.wrapType(dart.dynamic)));
|
||||
core.print(dart.equals(x, dart.wrapType(misc.Generic)));
|
||||
core.print(new (misc.Generic$(core.int))().type);
|
||||
core.print(dart.equals(new misc.Derived(), new misc.Derived()));
|
||||
new (misc.Generic$(core.int))().m();
|
||||
};
|
||||
dart.fn(misc.main);
|
||||
// Exports:
|
||||
exports.misc = misc;
|
||||
});
|
|
@ -1,60 +0,0 @@
|
|||
dart_library.library('names', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const names = Object.create(null);
|
||||
names.exports = 42;
|
||||
const _foo = Symbol('_foo');
|
||||
names.Foo = class Foo extends core.Object {
|
||||
[_foo]() {
|
||||
return 123;
|
||||
}
|
||||
};
|
||||
dart.setSignature(names.Foo, {
|
||||
methods: () => ({[_foo]: [dart.dynamic, []]})
|
||||
});
|
||||
names._foo = function() {
|
||||
return 456;
|
||||
};
|
||||
dart.fn(names._foo);
|
||||
names.Frame = class Frame extends core.Object {
|
||||
caller(arguments$) {
|
||||
this.arguments = arguments$;
|
||||
}
|
||||
static callee() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
dart.defineNamedConstructor(names.Frame, 'caller');
|
||||
dart.setSignature(names.Frame, {
|
||||
constructors: () => ({caller: [names.Frame, [core.List]]}),
|
||||
statics: () => ({callee: [dart.dynamic, []]}),
|
||||
names: ['callee']
|
||||
});
|
||||
names.Frame2 = class Frame2 extends core.Object {};
|
||||
dart.defineLazy(names.Frame2, {
|
||||
get caller() {
|
||||
return 100;
|
||||
},
|
||||
set caller(_) {},
|
||||
get arguments() {
|
||||
return 200;
|
||||
},
|
||||
set arguments(_) {}
|
||||
});
|
||||
names.main = function() {
|
||||
core.print(names.exports);
|
||||
core.print(new names.Foo()[_foo]());
|
||||
core.print(names._foo());
|
||||
core.print(new names.Frame.caller(dart.list([1, 2, 3], core.int)));
|
||||
let eval$ = names.Frame.callee;
|
||||
core.print(eval$);
|
||||
core.print(dart.notNull(names.Frame2.caller) + dart.notNull(names.Frame2.arguments));
|
||||
};
|
||||
dart.fn(names.main);
|
||||
// Exports:
|
||||
exports.names = names;
|
||||
});
|
|
@ -1,49 +0,0 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
const dart_sdk = require('dart_sdk');
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const node_modules = Object.create(null);
|
||||
node_modules.Callback = dart.typedef('Callback', () => dart.functionType(dart.void, [], {i: core.int}));
|
||||
node_modules.A = class A extends core.Object {};
|
||||
node_modules._A = class _A extends core.Object {};
|
||||
node_modules.B$ = dart.generic(T => {
|
||||
class B extends core.Object {}
|
||||
return B;
|
||||
});
|
||||
node_modules.B = node_modules.B$();
|
||||
node_modules._B$ = dart.generic(T => {
|
||||
class _B extends core.Object {}
|
||||
return _B;
|
||||
});
|
||||
node_modules._B = node_modules._B$();
|
||||
node_modules.f = function() {
|
||||
};
|
||||
dart.fn(node_modules.f);
|
||||
node_modules._f = function() {
|
||||
};
|
||||
dart.fn(node_modules._f);
|
||||
node_modules.constant = "abc";
|
||||
node_modules.finalConstant = "abc";
|
||||
dart.defineLazy(node_modules, {
|
||||
get lazy() {
|
||||
return dart.fn(() => {
|
||||
core.print('lazy');
|
||||
return "abc";
|
||||
}, core.String, [])();
|
||||
}
|
||||
});
|
||||
node_modules.mutable = "abc";
|
||||
dart.defineLazy(node_modules, {
|
||||
get lazyMutable() {
|
||||
return dart.fn(() => {
|
||||
core.print('lazyMutable');
|
||||
return "abc";
|
||||
}, core.String, [])();
|
||||
},
|
||||
set lazyMutable(_) {}
|
||||
});
|
||||
// Exports:
|
||||
exports.node_modules = node_modules;
|
||||
})();
|
|
@ -1,263 +0,0 @@
|
|||
dart_library.library('notnull', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const notnull = Object.create(null);
|
||||
notnull.intAssignments = function() {
|
||||
let i = 0;
|
||||
i = i & 1;
|
||||
i = (i | 1) >>> 0;
|
||||
i = (i ^ 1) >>> 0;
|
||||
i = i[dartx['>>']](1);
|
||||
i = i << 1 >>> 0;
|
||||
i = i - 1;
|
||||
i = i[dartx['%']](1);
|
||||
i = i + 1;
|
||||
let t = i;
|
||||
t == null ? i = 1 : t;
|
||||
i = i * 1;
|
||||
i = (i / 1)[dartx.truncate]();
|
||||
i++;
|
||||
--i;
|
||||
core.print(i + 1);
|
||||
let j = 1;
|
||||
j = i < 10 ? 1 : 2;
|
||||
core.print(j + 1);
|
||||
};
|
||||
dart.fn(notnull.intAssignments, dart.void, []);
|
||||
notnull.doubleAssignments = function() {
|
||||
let d = 0.0;
|
||||
d = d / 1;
|
||||
core.print(d + 1);
|
||||
};
|
||||
dart.fn(notnull.doubleAssignments, dart.void, []);
|
||||
notnull.boolAssignments = function() {
|
||||
let b = true;
|
||||
b != b;
|
||||
core.print(b);
|
||||
};
|
||||
dart.fn(notnull.boolAssignments, dart.void, []);
|
||||
notnull.increments = function() {
|
||||
let i = 1;
|
||||
core.print(++i);
|
||||
core.print(i++);
|
||||
core.print(--i);
|
||||
core.print(i--);
|
||||
let j = null;
|
||||
j = 1;
|
||||
core.print((j = dart.notNull(j) + 1));
|
||||
core.print((() => {
|
||||
let x = j;
|
||||
j = dart.notNull(x) + 1;
|
||||
return x;
|
||||
})());
|
||||
core.print((j = dart.notNull(j) - 1));
|
||||
core.print((() => {
|
||||
let x = j;
|
||||
j = dart.notNull(x) - 1;
|
||||
return x;
|
||||
})());
|
||||
};
|
||||
dart.fn(notnull.increments, dart.void, []);
|
||||
notnull.conditionals = function(cond) {
|
||||
if (cond === void 0) cond = null;
|
||||
let nullable = null;
|
||||
nullable = 1;
|
||||
let nonNullable = 1;
|
||||
let a = dart.notNull(cond) ? nullable : nullable;
|
||||
let b = dart.notNull(cond) ? nullable : nonNullable;
|
||||
let c = dart.notNull(cond) ? nonNullable : nonNullable;
|
||||
let d = dart.notNull(cond) ? nonNullable : nullable;
|
||||
core.print(dart.notNull(a) + dart.notNull(b) + c + dart.notNull(d));
|
||||
};
|
||||
dart.fn(notnull.conditionals, dart.void, [], [core.bool]);
|
||||
notnull.nullAwareOps = function() {
|
||||
let nullable = null;
|
||||
let nonNullable = 1;
|
||||
let a = (nullable != null ? nullable : nullable);
|
||||
let b = (nullable != null ? nullable : nonNullable);
|
||||
let c = nonNullable;
|
||||
let d = nonNullable;
|
||||
core.print(dart.notNull(a) + dart.notNull(b) + c + d);
|
||||
let s = "";
|
||||
core.print(dart.notNull(s[dartx.length]) + 1);
|
||||
};
|
||||
dart.fn(notnull.nullAwareOps, dart.void, []);
|
||||
notnull.nullableLocals = function(param) {
|
||||
core.print(dart.notNull(param) + 1);
|
||||
let i = null;
|
||||
i = 1;
|
||||
core.print(dart.notNull(i) + 1);
|
||||
let j = 1;
|
||||
j = i == 1 ? 1 : null;
|
||||
core.print(dart.notNull(j) + 1);
|
||||
};
|
||||
dart.fn(notnull.nullableLocals, dart.void, [core.int]);
|
||||
notnull.optParams = function(x, y) {
|
||||
if (x === void 0) x = null;
|
||||
if (y === void 0) y = 1;
|
||||
core.print(dart.notNull(x) + dart.notNull(y));
|
||||
};
|
||||
dart.fn(notnull.optParams, dart.void, [], [core.int, core.int]);
|
||||
notnull.namedParams = function(opts) {
|
||||
let x = opts && 'x' in opts ? opts.x : null;
|
||||
let y = opts && 'y' in opts ? opts.y : 1;
|
||||
core.print(dart.notNull(x) + dart.notNull(y));
|
||||
};
|
||||
dart.fn(notnull.namedParams, dart.void, [], {x: core.int, y: core.int});
|
||||
notnull.forLoops = function(length) {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
core.print(i + 1);
|
||||
}
|
||||
for (let i = 0; i < dart.notNull(length()); i++) {
|
||||
core.print(i + 1);
|
||||
}
|
||||
for (let i = 0, n = length(); i < dart.notNull(n); i++) {
|
||||
core.print(i + 1);
|
||||
}
|
||||
for (let i = 0, n = dart.notNull(length()) + 0; i < n; i++) {
|
||||
core.print(i + 1);
|
||||
}
|
||||
};
|
||||
dart.fn(notnull.forLoops, dart.void, [dart.functionType(core.int, [])]);
|
||||
notnull.nullableCycle = function() {
|
||||
let x = 1;
|
||||
let y = 2;
|
||||
let z = null;
|
||||
x = y;
|
||||
y = z;
|
||||
z = x;
|
||||
core.print(dart.notNull(x) + dart.notNull(y) + dart.notNull(z));
|
||||
let s = null;
|
||||
s = s;
|
||||
core.print(dart.notNull(s) + 1);
|
||||
};
|
||||
dart.fn(notnull.nullableCycle, dart.void, []);
|
||||
notnull.nonNullableCycle = function() {
|
||||
let x = 1;
|
||||
let y = 2;
|
||||
let z = 3;
|
||||
x = y;
|
||||
y = z;
|
||||
z = x;
|
||||
core.print(x + y + z);
|
||||
let s = 1;
|
||||
s = s;
|
||||
core.print(s + 1);
|
||||
};
|
||||
dart.fn(notnull.nonNullableCycle, dart.void, []);
|
||||
notnull.Foo = class Foo extends core.Object {
|
||||
new() {
|
||||
this.intField = null;
|
||||
this.varField = null;
|
||||
}
|
||||
f(o) {
|
||||
core.print(1 + dart.notNull(dart.as(this.varField, core.num)) + 2);
|
||||
while (dart.test(dart.dsend(this.varField, '<', 10))) {
|
||||
this.varField = dart.dsend(this.varField, '+', 1);
|
||||
}
|
||||
while (dart.test(dart.dsend(this.varField, '<', 10)))
|
||||
this.varField = dart.dsend(this.varField, '+', 1);
|
||||
core.print(1 + dart.notNull(this.intField) + 2);
|
||||
while (dart.notNull(this.intField) < 10) {
|
||||
this.intField = dart.notNull(this.intField) + 1;
|
||||
}
|
||||
while (dart.notNull(this.intField) < 10)
|
||||
this.intField = dart.notNull(this.intField) + 1;
|
||||
core.print(1 + dart.notNull(o.intField) + 2);
|
||||
while (dart.notNull(o.intField) < 10) {
|
||||
o.intField = dart.notNull(o.intField) + 1;
|
||||
}
|
||||
while (dart.notNull(o.intField) < 10)
|
||||
o.intField = dart.notNull(o.intField) + 1;
|
||||
}
|
||||
};
|
||||
dart.setSignature(notnull.Foo, {
|
||||
methods: () => ({f: [dart.dynamic, [notnull.Foo]]})
|
||||
});
|
||||
notnull._foo = function() {
|
||||
return 1;
|
||||
};
|
||||
dart.fn(notnull._foo, core.int, []);
|
||||
notnull.calls = function() {
|
||||
let a = 1;
|
||||
let b = 1;
|
||||
b = dart.as(dart.dcall(dart.fn(x => x), a), core.int);
|
||||
core.print(dart.notNull(b) + 1);
|
||||
let c = notnull._foo();
|
||||
core.print(dart.notNull(c) + 1);
|
||||
};
|
||||
dart.fn(notnull.calls);
|
||||
notnull.localEscapes = function() {
|
||||
let a = 1;
|
||||
let f = dart.fn(x => a = dart.as(x, core.int));
|
||||
let b = 1;
|
||||
function g(x) {
|
||||
return b = dart.as(x, core.int);
|
||||
}
|
||||
dart.fn(g);
|
||||
dart.dcall(f, 1);
|
||||
g(1);
|
||||
core.print(dart.notNull(a) + dart.notNull(b));
|
||||
};
|
||||
dart.fn(notnull.localEscapes);
|
||||
notnull.controlFlow = function() {
|
||||
for (let i = null, j = null;;) {
|
||||
i = j = 1;
|
||||
core.print(dart.notNull(i) + dart.notNull(j) + 1);
|
||||
break;
|
||||
}
|
||||
try {
|
||||
dart.throw(1);
|
||||
} catch (e) {
|
||||
core.print(dart.dsend(e, '+', 1));
|
||||
}
|
||||
|
||||
try {
|
||||
dart.dsend(null, 'foo');
|
||||
} catch (e) {
|
||||
let trace = dart.stackTrace(e);
|
||||
core.print(dart.str`${typeof e == 'string' ? e : dart.toString(e)} at ${trace}`);
|
||||
}
|
||||
|
||||
};
|
||||
dart.fn(notnull.controlFlow);
|
||||
notnull.cascadesOnNull = function() {
|
||||
let x = null;
|
||||
core.print(dart.hashCode(((() => {
|
||||
dart.toString(x);
|
||||
dart.runtimeType(x);
|
||||
return x;
|
||||
})())));
|
||||
let y = null;
|
||||
core.print(dart.hashCode(((() => {
|
||||
dart.toString(y);
|
||||
dart.runtimeType(y);
|
||||
return y;
|
||||
})())));
|
||||
};
|
||||
dart.fn(notnull.cascadesOnNull);
|
||||
notnull.main = function() {
|
||||
notnull.intAssignments();
|
||||
notnull.doubleAssignments();
|
||||
notnull.boolAssignments();
|
||||
notnull.nullableLocals(1);
|
||||
notnull.optParams(1, 2);
|
||||
notnull.namedParams({x: 1, y: 2});
|
||||
notnull.forLoops(dart.fn(() => 10, core.int, []));
|
||||
notnull.increments();
|
||||
notnull.conditionals(true);
|
||||
notnull.calls();
|
||||
notnull.localEscapes();
|
||||
notnull.controlFlow();
|
||||
notnull.cascadesOnNull();
|
||||
notnull.nullableCycle();
|
||||
notnull.nonNullableCycle();
|
||||
};
|
||||
dart.fn(notnull.main);
|
||||
// Exports:
|
||||
exports.notnull = notnull;
|
||||
});
|
|
@ -1,59 +0,0 @@
|
|||
dart_library.library('opassign', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const opassign = Object.create(null);
|
||||
dart.copyProperties(opassign, {
|
||||
get index() {
|
||||
core.print('called "index" getter');
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
dart.defineLazy(opassign, {
|
||||
get _foo() {
|
||||
return new opassign.Foo();
|
||||
}
|
||||
});
|
||||
dart.copyProperties(opassign, {
|
||||
get foo() {
|
||||
core.print('called "foo" getter');
|
||||
return opassign._foo;
|
||||
}
|
||||
});
|
||||
opassign.Foo = class Foo extends core.Object {
|
||||
new() {
|
||||
this.x = 100;
|
||||
}
|
||||
};
|
||||
opassign.main = function() {
|
||||
let f = dart.map([0, 40]);
|
||||
core.print('should only call "index" 2 times:');
|
||||
let i = dart.as(opassign.index, core.int);
|
||||
f[dartx.set](i, dart.notNull(f[dartx.get](i)) + 1);
|
||||
opassign.forcePostfix((() => {
|
||||
let i = dart.as(opassign.index, core.int), x = f[dartx.get](i);
|
||||
f[dartx.set](i, dart.notNull(x) + 1);
|
||||
return x;
|
||||
})());
|
||||
core.print('should only call "foo" 2 times:');
|
||||
let o = opassign.foo;
|
||||
dart.dput(o, 'x', dart.dsend(dart.dload(o, 'x'), '+', 1));
|
||||
opassign.forcePostfix((() => {
|
||||
let o = opassign.foo, x = dart.dload(o, 'x');
|
||||
dart.dput(o, 'x', dart.dsend(x, '+', 1));
|
||||
return x;
|
||||
})());
|
||||
core.print('op assign test, should only call "index" twice:');
|
||||
let i$ = dart.as(opassign.index, core.int);
|
||||
f[dartx.set](i$, dart.notNull(f[dartx.get](i$)) + dart.notNull(f[dartx.get](opassign.index)));
|
||||
};
|
||||
dart.fn(opassign.main);
|
||||
opassign.forcePostfix = function(x) {
|
||||
};
|
||||
dart.fn(opassign.forcePostfix);
|
||||
// Exports:
|
||||
exports.opassign = opassign;
|
||||
});
|
|
@ -1,17 +0,0 @@
|
|||
dart_library.library('script', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const script = Object.create(null);
|
||||
script.main = function(args) {
|
||||
let name = args[dartx.join](' ');
|
||||
if (name == '') name = 'world';
|
||||
core.print(dart.str`hello ${name}`);
|
||||
};
|
||||
dart.fn(script.main, dart.void, [core.List$(core.String)]);
|
||||
// Exports:
|
||||
exports.script = script;
|
||||
});
|
|
@ -1,129 +0,0 @@
|
|||
dart_library.library('sunflower', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const html = dart_sdk.html;
|
||||
const math = dart_sdk.math;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const sunflower = Object.create(null);
|
||||
const circle = Object.create(null);
|
||||
const painter = Object.create(null);
|
||||
sunflower.SEED_RADIUS = 2;
|
||||
sunflower.SCALE_FACTOR = 4;
|
||||
sunflower.MAX_D = 300;
|
||||
sunflower.centerX = sunflower.MAX_D / 2;
|
||||
sunflower.centerY = sunflower.centerX;
|
||||
sunflower.querySelector = function(selector) {
|
||||
return html.document[dartx.querySelector](selector);
|
||||
};
|
||||
dart.fn(sunflower.querySelector, html.Element, [core.String]);
|
||||
dart.defineLazy(sunflower, {
|
||||
get canvas() {
|
||||
return dart.as(sunflower.querySelector("#canvas"), html.CanvasElement);
|
||||
}
|
||||
});
|
||||
dart.defineLazy(sunflower, {
|
||||
get context() {
|
||||
return dart.as(sunflower.canvas[dartx.getContext]('2d'), html.CanvasRenderingContext2D);
|
||||
}
|
||||
});
|
||||
dart.defineLazy(sunflower, {
|
||||
get slider() {
|
||||
return dart.as(sunflower.querySelector("#slider"), html.InputElement);
|
||||
}
|
||||
});
|
||||
dart.defineLazy(sunflower, {
|
||||
get notes() {
|
||||
return sunflower.querySelector("#notes");
|
||||
}
|
||||
});
|
||||
dart.defineLazy(sunflower, {
|
||||
get PHI() {
|
||||
return (dart.notNull(math.sqrt(5)) + 1) / 2;
|
||||
}
|
||||
});
|
||||
sunflower.seeds = 0;
|
||||
sunflower.main = function() {
|
||||
sunflower.slider[dartx.addEventListener]('change', dart.fn(e => sunflower.draw(), dart.void, [html.Event]));
|
||||
sunflower.draw();
|
||||
};
|
||||
dart.fn(sunflower.main, dart.void, []);
|
||||
sunflower.draw = function() {
|
||||
sunflower.seeds = core.int.parse(sunflower.slider[dartx.value]);
|
||||
sunflower.context[dartx.clearRect](0, 0, sunflower.MAX_D, sunflower.MAX_D);
|
||||
for (let i = 0; i < dart.notNull(sunflower.seeds); i++) {
|
||||
let theta = i * painter.TAU / dart.notNull(sunflower.PHI);
|
||||
let r = dart.notNull(math.sqrt(i)) * sunflower.SCALE_FACTOR;
|
||||
let x = sunflower.centerX + r * dart.notNull(math.cos(theta));
|
||||
let y = sunflower.centerY - r * dart.notNull(math.sin(theta));
|
||||
new sunflower.SunflowerSeed(x, y, sunflower.SEED_RADIUS).draw(sunflower.context);
|
||||
}
|
||||
sunflower.notes[dartx.text] = dart.str`${sunflower.seeds} seeds`;
|
||||
};
|
||||
dart.fn(sunflower.draw, dart.void, []);
|
||||
circle.Circle = class Circle extends core.Object {
|
||||
new(x, y, radius) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.radius = radius;
|
||||
}
|
||||
};
|
||||
dart.setSignature(circle.Circle, {
|
||||
constructors: () => ({new: [circle.Circle, [core.num, core.num, core.num]]})
|
||||
});
|
||||
painter.CirclePainter = class CirclePainter extends core.Object {
|
||||
new() {
|
||||
this.color = painter.ORANGE;
|
||||
}
|
||||
draw(context) {
|
||||
context[dartx.beginPath]();
|
||||
context[dartx.lineWidth] = 2;
|
||||
context[dartx.fillStyle] = this.color;
|
||||
context[dartx.strokeStyle] = this.color;
|
||||
context[dartx.arc](this.x, this.y, this.radius, 0, painter.TAU, false);
|
||||
context[dartx.fill]();
|
||||
context[dartx.closePath]();
|
||||
context[dartx.stroke]();
|
||||
}
|
||||
};
|
||||
painter.CirclePainter[dart.implements] = () => [circle.Circle];
|
||||
dart.setSignature(painter.CirclePainter, {
|
||||
methods: () => ({draw: [dart.void, [html.CanvasRenderingContext2D]]})
|
||||
});
|
||||
sunflower.SunflowerSeed = class SunflowerSeed extends dart.mixin(circle.Circle, painter.CirclePainter) {
|
||||
new(x, y, radius, color) {
|
||||
if (color === void 0) color = null;
|
||||
super.new(x, y, radius);
|
||||
if (color != null) this.color = color;
|
||||
}
|
||||
};
|
||||
dart.setSignature(sunflower.SunflowerSeed, {
|
||||
constructors: () => ({new: [sunflower.SunflowerSeed, [core.num, core.num, core.num], [core.String]]})
|
||||
});
|
||||
painter.ORANGE = "orange";
|
||||
painter.RED = "red";
|
||||
painter.BLUE = "blue";
|
||||
painter.TAU = math.PI * 2;
|
||||
painter.querySelector = function(selector) {
|
||||
return html.document[dartx.querySelector](selector);
|
||||
};
|
||||
dart.fn(painter.querySelector, html.Element, [core.String]);
|
||||
dart.defineLazy(painter, {
|
||||
get canvas() {
|
||||
return dart.as(painter.querySelector("#canvas"), html.CanvasElement);
|
||||
}
|
||||
});
|
||||
dart.defineLazy(painter, {
|
||||
get context() {
|
||||
return dart.as(painter.canvas[dartx.getContext]('2d'), html.CanvasRenderingContext2D);
|
||||
}
|
||||
});
|
||||
// Exports:
|
||||
exports.sunflower = sunflower;
|
||||
exports.circle = circle;
|
||||
exports.painter = painter;
|
||||
});
|
||||
|
||||
//# sourceMappingURL=sunflower.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"sourceRoot":"","sources":["../../sunflower/sunflower.dart","../../sunflower/circle.dart","../../sunflower/painter.dart"],"names":["MAX_D","centerX","document","selector","querySelector","canvas","sqrt","slider","draw","seeds","int","context","i","TAU","PHI","SCALE_FACTOR","r","cos","theta","centerY","sin","x","y","SEED_RADIUS","notes","ORANGE","color","radius","PI"],"mappings":";;;;;;;;;;;;AAYM,0BAAc,CAAC;AAAA,AACf,2BAAe,CAAC;AAAA,AAChB,oBAAQ,GAAG;AAAA,AACX,sBAAU,AAAAA,eAAK,GAAG,CAAC,AAAA;AAAA,AACnB,sBAAUC,iBAAO;AAAA,AAEvB,4BAAqB,SAAC,QAAe,EAAE;UAAG,AAAAC,cAAQ,sBAAeC,QAAQ,CAAC;GAAC,AAAA;AAAA;AACrE;IAAA;YAAS,SAAA,AAAAC,uBAAa,CAAC,SAAS,CAAC,qBAAiB;KAAA;;AAClD;IAAA;YAAU,SAAA,AAAAC,gBAAM,mBAAY,IAAI,CAAC,gCAA4B;KAAA;;AAC7D;IAAA;YAAS,SAAA,AAAAD,uBAAa,CAAC,SAAS,CAAC,oBAAgB;KAAA;;AACjD;IAAA;YAAQ,AAAAA,wBAAa,CAAC,QAAQ,CAAC;KAAA;;AAE/B;IAAA;YAAM,EAAA,aAAC,AAAAE,SAAI,CAAC,CAAC,CAAC,IAAG,CAAC,AAAC,IAAG,CAAC,AAAA;KAAA;;AACzB,oBAAQ,CAAC;AAAA,AAEb,mBAAS,WAAG;AACV,IAAA,AAAAC,gBAAM,yBAAkB,QAAQ,EAAE,QAAA,AAAC,CAAC,IAAK,AAAAC,cAAI,EAAE,AAAA,0BAAA,CAAC;AAAC,AACjD,IAAA,AAAAA,cAAI,EAAE;AAAC,GACR,AAAA;AAAA;AAED,mBACS,WAAG;AACV,IAAA,AAAAC,eAAK,GAAG,AAAAC,QAAG,OAAO,AAAAH,gBAAM,aAAM,CAAC,AAAA;AAAC,AAChC,IAAA,AAAAI,iBAAO,kBAAW,CAAC,EAAE,CAAC,EAAEX,eAAK,EAAEA,eAAK,CAAC;AAAC,AACtC,SAAK,IAAI,IAAI,CAAC,AAAA,AAAA,EAAE,AAAAY,CAAC,gBAAGH,eAAK,CAAA,EAAE,AAAAG,CAAC,EAAE,EAAE;AAC9B,kBAAc,AAAA,AAAAA,CAAC,GAAGC,WAAG,AAAA,gBAAGC,aAAG,CAAA;AAAC,AAC5B,cAAU,aAAA,AAAAR,SAAI,CAACM,CAAC,CAAC,IAAGG,sBAAY,AAAA;AAAC,AACjC,cAAU,AAAAd,iBAAO,GAAG,AAAAe,CAAC,gBAAGC,AAAA,QAAG,CAACC,KAAK,CAAC,CAAA,AAAA;AAAC,AACnC,cAAU,AAAAC,iBAAO,GAAG,AAAAH,CAAC,gBAAG,AAAAI,QAAG,CAACF,KAAK,CAAC,CAAA,AAAA;AAAC,AACnC,MAAA,AAAA,4BAAkBG,CAAC,EAAEC,CAAC,EAAEC,qBAAW,CAAC,MAAMZ,iBAAO,CAAC;AAAC,KACpD;AAAA,AACD,IAAA,AAAA,AAAAa,eAAK,YAAK,GAAG,WAAC,eAAM,QAAO,AAAA;AAAC,GAC7B,AAAA;AAAA;;ICnCC,IAAO,CAAM,EAAE,CAAM,EAAE,MAAW,EAAlC;;;;AAAmC,AAAC,KAAA;;;;;;ICYtC;mBAEiBC,cAAM;KAevB;IAbE,KACU,OAAgC,EAAE;AAC1C,MAAAd,AACE,OADK,mBACQ;MADfA,AAEE,AAAA,OAFK,iBAEM,GAAG,CAAC,AAAA;MAFjBA,AAGE,AAAA,OAHK,iBAGM,GAAGe,UAAK,AAAA;MAHrBf,AAIE,AAAA,OAJK,mBAIQ,GAAGe,UAAK,AAAA;MAJvBf,AAKE,OALK,YAKCU,MAAC,EAAEC,MAAC,EAAEK,WAAM,EAAE,CAAC,EAAEd,WAAG,EAAE,KAAK,CAAC;MALpCF,AAME,OANK,cAMG;MANVA,AAOE,OAPK,mBAOQ;MAPfA,AAQE,OARK,gBAQK;AAAC,KACd,AAAA;;;;;;;IFYD,IAAc,CAAK,EAAE,CAAK,EAAE,MAAU,EAAG,KAAY,EAArD;;AACE,gBAAMU,CAAC,EAAEC,CAAC,EAAEK,MAAM;AAAC,AAAC,AACpB,UAAI,AAAAD,KAAK,IAAI,IAAI,AAAA,EAAE,AAAA,AAAA,AAAA,IAAI,MAAM,GAAGA,KAAK,AAAA;AAAC,AAAA,AACvC,KAAA;;;;;AExCG,mBAAS,QAAQ;AAAA,AACjB,gBAAM,KAAK;AAAA,AACX,iBAAO,MAAM;AAAA,AACb,gBAAM,AAAAE,OAAE,GAAG,CAAC,AAAA;AAAA,AAElB,0BAAqB,SAAC,QAAe,EAAE;UAAG,AAAA1B,cAAQ,sBAAeC,QAAQ,CAAC;GAAC,AAAA;AAAA;AAErE;IAAA;YAAS,SAAA,AAAAC,qBAAa,CAAC,SAAS,CAAC,qBAAiB;KAAA;;AAClD;IAAA;YAAU,SAAA,AAAAC,cAAM,mBAAY,IAAI,CAAC,gCAA4B;KAAA","file":"sunflower.js"}
|
|
@ -1,53 +0,0 @@
|
|||
dart_library.library('syncstar_syntax', null, /* Imports */[
|
||||
'dart_sdk',
|
||||
'expect'
|
||||
], function(exports, dart_sdk, expect) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const expect$ = expect.expect;
|
||||
const syncstar_syntax = Object.create(null);
|
||||
syncstar_syntax.foo = function() {
|
||||
return dart.syncStar(function*() {
|
||||
yield 1;
|
||||
yield* dart.list([2, 3], core.int);
|
||||
}, core.int);
|
||||
};
|
||||
dart.fn(syncstar_syntax.foo, core.Iterable$(core.int), []);
|
||||
syncstar_syntax.Class = class Class extends core.Object {
|
||||
bar() {
|
||||
return dart.syncStar(function*() {
|
||||
yield 1;
|
||||
yield* dart.list([2, 3], core.int);
|
||||
}, core.int);
|
||||
}
|
||||
static baz() {
|
||||
return dart.syncStar(function*() {
|
||||
yield 1;
|
||||
yield* dart.list([2, 3], core.int);
|
||||
}, core.int);
|
||||
}
|
||||
};
|
||||
dart.setSignature(syncstar_syntax.Class, {
|
||||
methods: () => ({bar: [core.Iterable$(core.int), []]}),
|
||||
statics: () => ({baz: [core.Iterable$(core.int), []]}),
|
||||
names: ['baz']
|
||||
});
|
||||
syncstar_syntax.main = function() {
|
||||
function qux() {
|
||||
return dart.syncStar(function*() {
|
||||
yield 1;
|
||||
yield* dart.list([2, 3], core.int);
|
||||
}, core.int);
|
||||
}
|
||||
dart.fn(qux, core.Iterable$(core.int), []);
|
||||
expect$.Expect.listEquals(dart.list([1, 2, 3], core.int), syncstar_syntax.foo()[dartx.toList]());
|
||||
expect$.Expect.listEquals(dart.list([1, 2, 3], core.int), new syncstar_syntax.Class().bar()[dartx.toList]());
|
||||
expect$.Expect.listEquals(dart.list([1, 2, 3], core.int), syncstar_syntax.Class.baz()[dartx.toList]());
|
||||
expect$.Expect.listEquals(dart.list([1, 2, 3], core.int), qux()[dartx.toList]());
|
||||
};
|
||||
dart.fn(syncstar_syntax.main);
|
||||
// Exports:
|
||||
exports.syncstar_syntax = syncstar_syntax;
|
||||
});
|
|
@ -1,50 +0,0 @@
|
|||
dart_library.library('temps', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const temps = Object.create(null);
|
||||
const _x = Symbol('_x');
|
||||
const __x = Symbol('__x');
|
||||
const _function = Symbol('_function');
|
||||
temps.FormalCollision = class FormalCollision extends core.Object {
|
||||
new(x, _x$, func) {
|
||||
this[_x] = x;
|
||||
this[__x] = _x$;
|
||||
this[_function] = func;
|
||||
}
|
||||
};
|
||||
dart.setSignature(temps.FormalCollision, {
|
||||
constructors: () => ({new: [temps.FormalCollision, [core.int, core.int, core.Function]]})
|
||||
});
|
||||
const _opt = Symbol('_opt');
|
||||
temps.OptionalArg = class OptionalArg extends core.Object {
|
||||
new(opt) {
|
||||
if (opt === void 0) opt = 123;
|
||||
this[_opt] = opt;
|
||||
this.opt = null;
|
||||
}
|
||||
named(opts) {
|
||||
let opt = opts && 'opt' in opts ? opts.opt : 456;
|
||||
this.opt = opt;
|
||||
this[_opt] = null;
|
||||
}
|
||||
};
|
||||
dart.defineNamedConstructor(temps.OptionalArg, 'named');
|
||||
dart.setSignature(temps.OptionalArg, {
|
||||
constructors: () => ({
|
||||
new: [temps.OptionalArg, [], [core.int]],
|
||||
named: [temps.OptionalArg, [], {opt: core.int}]
|
||||
})
|
||||
});
|
||||
temps.main = function() {
|
||||
core.print(new temps.FormalCollision(1, 2, dart.fn(x => x)));
|
||||
core.print(new temps.OptionalArg()[_opt]);
|
||||
core.print(new temps.OptionalArg.named()[_opt]);
|
||||
};
|
||||
dart.fn(temps.main);
|
||||
// Exports:
|
||||
exports.temps = temps;
|
||||
});
|
|
@ -1,77 +0,0 @@
|
|||
dart_library.library('try_catch', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const try_catch = Object.create(null);
|
||||
try_catch.foo = function() {
|
||||
try {
|
||||
dart.throw("hi there");
|
||||
} catch (e$) {
|
||||
if (dart.is(e$, core.String)) {
|
||||
let e = e$;
|
||||
let t = dart.stackTrace(e);
|
||||
} else {
|
||||
let e = e$;
|
||||
let t = dart.stackTrace(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
dart.fn(try_catch.foo);
|
||||
try_catch.bar = function() {
|
||||
try {
|
||||
dart.throw("hi there");
|
||||
} catch (e$) {
|
||||
let e = e$;
|
||||
let t = dart.stackTrace(e);
|
||||
}
|
||||
|
||||
};
|
||||
dart.fn(try_catch.bar);
|
||||
try_catch.baz = function() {
|
||||
try {
|
||||
dart.throw("finally only");
|
||||
} finally {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
dart.fn(try_catch.baz);
|
||||
try_catch.qux = function() {
|
||||
try {
|
||||
dart.throw("on only");
|
||||
} catch (e) {
|
||||
if (dart.is(e, core.String)) {
|
||||
let t = dart.stackTrace(e);
|
||||
throw e;
|
||||
} else
|
||||
throw e;
|
||||
}
|
||||
|
||||
};
|
||||
dart.fn(try_catch.qux);
|
||||
try_catch.wub = function() {
|
||||
try {
|
||||
dart.throw("on without exception parameter");
|
||||
} catch (e) {
|
||||
if (dart.is(e, core.String)) {
|
||||
} else
|
||||
throw e;
|
||||
}
|
||||
|
||||
};
|
||||
dart.fn(try_catch.wub);
|
||||
try_catch.main = function() {
|
||||
try_catch.foo();
|
||||
try_catch.bar();
|
||||
try_catch.baz();
|
||||
try_catch.qux();
|
||||
try_catch.wub();
|
||||
};
|
||||
dart.fn(try_catch.main);
|
||||
// Exports:
|
||||
exports.try_catch = try_catch;
|
||||
});
|
|
@ -1,21 +0,0 @@
|
|||
dart_library.library('varargs', null, /* Imports */[
|
||||
'dart_sdk'
|
||||
], function(exports, dart_sdk) {
|
||||
'use strict';
|
||||
const core = dart_sdk.core;
|
||||
const dart = dart_sdk.dart;
|
||||
const dartx = dart_sdk.dartx;
|
||||
const varargs = Object.create(null);
|
||||
varargs.varargsTest = function(x, ...others) {
|
||||
let args = [1, others];
|
||||
dart.dsend(x, 'call', ...args);
|
||||
};
|
||||
dart.fn(varargs.varargsTest);
|
||||
varargs.varargsTest2 = function(x, ...others) {
|
||||
let args = [1, others];
|
||||
dart.dsend(x, 'call', ...args);
|
||||
};
|
||||
dart.fn(varargs.varargsTest2);
|
||||
// Exports:
|
||||
exports.varargs = varargs;
|
||||
});
|
|
@ -1,11 +0,0 @@
|
|||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:collection';
|
||||
|
||||
class StringIterable extends IterableBase<String> {
|
||||
final Iterator<String> iterator = null;
|
||||
}
|
||||
|
||||
main() => new StringIterable();
|
|
@ -1,78 +0,0 @@
|
|||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library fieldtest;
|
||||
|
||||
class A {
|
||||
int x = 42;
|
||||
}
|
||||
|
||||
class B<T> {
|
||||
int x;
|
||||
num y;
|
||||
T z;
|
||||
}
|
||||
|
||||
int foo(A a) {
|
||||
print(a.x);
|
||||
return a.x;
|
||||
}
|
||||
|
||||
int bar(a) {
|
||||
print(a.x);
|
||||
return a.x;
|
||||
}
|
||||
|
||||
baz(A a) => a.x;
|
||||
|
||||
int compute() => 123;
|
||||
int y = compute() + 444;
|
||||
|
||||
String get q => 'life, ' + 'the universe ' + 'and everything';
|
||||
int get z => 42;
|
||||
void set z(value) {
|
||||
y = value;
|
||||
}
|
||||
|
||||
// Supported: use field to implement a getter
|
||||
abstract class BaseWithGetter {
|
||||
int get foo => 1;
|
||||
int get bar;
|
||||
}
|
||||
class Derived extends BaseWithGetter {
|
||||
int foo = 2;
|
||||
int bar = 3;
|
||||
}
|
||||
|
||||
class Generic<T> {
|
||||
foo(T t) => print(bar + (t as String));
|
||||
|
||||
static String bar = 'hello';
|
||||
}
|
||||
|
||||
class StaticFieldOrder1 {
|
||||
static const a = b + 1;
|
||||
static const c = d + 2;
|
||||
static const b = c + 3;
|
||||
static const d = 4;
|
||||
}
|
||||
class StaticFieldOrder2 {
|
||||
static const a = StaticFieldOrder2.b + 1;
|
||||
static const c = StaticFieldOrder2.d + 2;
|
||||
static const b = StaticFieldOrder2.c + 3;
|
||||
static const d = 4;
|
||||
}
|
||||
|
||||
enum MyEnum { Val1, Val2, Val3, Val4 }
|
||||
|
||||
void main() {
|
||||
var a = new A();
|
||||
foo(a);
|
||||
bar(a);
|
||||
print(baz(a));
|
||||
|
||||
print(new Generic<String>().foo(' world'));
|
||||
|
||||
print(MyEnum.values);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
List<Foo> bootstrap() {
|
||||
return <Foo>[new Foo()];
|
||||
}
|
||||
|
||||
typedef B A2B<A, B>(A x);
|
||||
|
||||
A2B<Foo, Foo> id(A2B<Foo, Foo> f) => f;
|
||||
|
||||
class Foo {
|
||||
}
|
||||
|
||||
void main() {
|
||||
print(bootstrap()[0]);
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
/// A simple unit test library for running tests in a browser.
|
||||
library unittest.html_config;
|
||||
|
||||
// void useHtmlConfiguration([bool isLayoutTest = false]) { }
|
|
@ -1,69 +0,0 @@
|
|||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library methods;
|
||||
|
||||
class A {
|
||||
int x() => 42;
|
||||
|
||||
int y(int a) {
|
||||
return a;
|
||||
}
|
||||
|
||||
int z([num b]) => b;
|
||||
|
||||
int zz([int b = 0]) => b;
|
||||
|
||||
int w(int a, {num b}) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
int ww(int a, {int b: 0}) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
clashWithObjectProperty({constructor}) => constructor;
|
||||
clashWithJsReservedName({function}) => function;
|
||||
|
||||
int get a => x();
|
||||
|
||||
void set b(int b) {}
|
||||
|
||||
int _c = 3;
|
||||
|
||||
int get c => _c;
|
||||
|
||||
void set c(int c) {
|
||||
_c = c;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar {
|
||||
call(x) => print('hello from $x');
|
||||
}
|
||||
class Foo {
|
||||
final Bar bar = new Bar();
|
||||
}
|
||||
|
||||
test() {
|
||||
// looks like a method but is actually f.bar.call(...)
|
||||
var f = new Foo();
|
||||
f.bar("Bar's call method!");
|
||||
|
||||
// Tear-off
|
||||
A a = new A();
|
||||
var g = a.x;
|
||||
|
||||
// Dynamic Tear-off
|
||||
dynamic aa = new A();
|
||||
var h = aa.x;
|
||||
|
||||
// Tear-off of object methods
|
||||
var ts = a.toString;
|
||||
var nsm = a.noSuchMethod;
|
||||
|
||||
// Tear-off extension methods
|
||||
var c = "".padLeft;
|
||||
var r = (3.0).floor;
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
|
||||
// Codegen dependency order test
|
||||
const UNINITIALIZED = const _Uninitialized();
|
||||
class _Uninitialized { const _Uninitialized(); }
|
||||
|
||||
class Generic<T> {
|
||||
Type get type => Generic;
|
||||
// type parameter type literals
|
||||
m() => print(T);
|
||||
}
|
||||
|
||||
// super ==
|
||||
// https://github.com/dart-lang/dev_compiler/issues/226
|
||||
class Base {
|
||||
int x = 1, y = 2;
|
||||
operator==(obj) {
|
||||
return obj is Base && obj.x == x && obj.y == y;
|
||||
}
|
||||
}
|
||||
class Derived {
|
||||
int z = 3;
|
||||
operator==(obj) {
|
||||
return obj is Derived && obj.z == z && super == obj;
|
||||
}
|
||||
}
|
||||
|
||||
// string escape tests
|
||||
// https://github.com/dart-lang/dev_compiler/issues/227
|
||||
bool _isWhitespace(String ch) =>
|
||||
ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
|
||||
|
||||
const expr = 'foo';
|
||||
const _escapeMap = const {
|
||||
'\n': r'\n',
|
||||
'\r': r'\r',
|
||||
'\f': r'\f',
|
||||
'\b': r'\b',
|
||||
'\t': r'\t',
|
||||
'\v': r'\v',
|
||||
'\x7F': r'\x7F', // delete
|
||||
'\${${expr}}': ''
|
||||
};
|
||||
|
||||
|
||||
main() {
|
||||
// Number literals in call expressions.
|
||||
print(1.toString());
|
||||
print(1.0.toString());
|
||||
print(1.1.toString());
|
||||
|
||||
// Type literals, #184
|
||||
dynamic x = 42;
|
||||
print(x == dynamic);
|
||||
print(x == Generic);
|
||||
|
||||
// Should be Generic<dynamic>
|
||||
print(new Generic<int>().type);
|
||||
|
||||
print(new Derived() == new Derived()); // true
|
||||
|
||||
new Generic<int>().m();
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
var exports = 42;
|
||||
|
||||
class Foo {
|
||||
_foo() => 123;
|
||||
}
|
||||
|
||||
_foo() => 456;
|
||||
|
||||
class Frame {
|
||||
final List arguments;
|
||||
Frame.caller(this.arguments);
|
||||
static callee() => null;
|
||||
}
|
||||
|
||||
|
||||
class Frame2 {
|
||||
static int caller = 100;
|
||||
static int arguments = 200;
|
||||
}
|
||||
|
||||
main() {
|
||||
print(exports);
|
||||
print(new Foo()._foo());
|
||||
print(_foo());
|
||||
print(new Frame.caller([1,2,3]));
|
||||
var eval = Frame.callee;
|
||||
print(eval);
|
||||
print(Frame2.caller + Frame2.arguments);
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Names test</title>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/dart" src="names.dart"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,237 +0,0 @@
|
|||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library notnull;
|
||||
|
||||
void intAssignments() {
|
||||
var i = 0;
|
||||
i &= 1;
|
||||
i |= 1;
|
||||
i ^= 1;
|
||||
i >>= 1;
|
||||
i <<= 1;
|
||||
i -= 1;
|
||||
i %= 1;
|
||||
i += 1;
|
||||
i ??= 1;
|
||||
i *= 1;
|
||||
i ~/= 1;
|
||||
i++;
|
||||
--i;
|
||||
print(i + 1);
|
||||
|
||||
int j = 1;
|
||||
j = i < 10 ? 1 : 2;
|
||||
print(j + 1);
|
||||
}
|
||||
|
||||
void doubleAssignments() {
|
||||
var d = 0.0;
|
||||
d /= 1;
|
||||
print(d + 1);
|
||||
}
|
||||
|
||||
void boolAssignments() {
|
||||
var b = true;
|
||||
b != b;
|
||||
print(b);
|
||||
}
|
||||
|
||||
void increments() {
|
||||
int i = 1;
|
||||
print(++i);
|
||||
print(i++);
|
||||
print(--i);
|
||||
print(i--);
|
||||
|
||||
int j;
|
||||
j = 1;
|
||||
print(++j);
|
||||
print(j++);
|
||||
print(--j);
|
||||
print(j--);
|
||||
}
|
||||
|
||||
void conditionals([bool cond]) {
|
||||
int nullable;
|
||||
nullable = 1;
|
||||
int nonNullable = 1;
|
||||
int a = cond ? nullable : nullable;
|
||||
int b = cond ? nullable : nonNullable;
|
||||
int c = cond ? nonNullable : nonNullable;
|
||||
int d = cond ? nonNullable : nullable;
|
||||
print(a + b + c + d);
|
||||
}
|
||||
|
||||
void nullAwareOps() {
|
||||
int nullable;
|
||||
int nonNullable = 1;
|
||||
int a = nullable ?? nullable;
|
||||
int b = nullable ?? nonNullable;
|
||||
int c = nonNullable ?? nonNullable;
|
||||
int d = nonNullable ?? nullable;
|
||||
print(a + b + c + d);
|
||||
|
||||
var s = "";
|
||||
print(s?.length + 1);
|
||||
}
|
||||
|
||||
void nullableLocals(int param) {
|
||||
print(param + 1);
|
||||
|
||||
int i;
|
||||
// We could detect that i is effectively non-nullable with flow analysis.
|
||||
i = 1;
|
||||
print(i + 1);
|
||||
|
||||
int j = 1;
|
||||
j = i == 1 ? 1 : null;
|
||||
print(j + 1);
|
||||
}
|
||||
|
||||
void optParams([int x, int y = 1]) {
|
||||
print(x + y);
|
||||
}
|
||||
|
||||
void namedParams({int x, int y: 1}) {
|
||||
print(x + y);
|
||||
}
|
||||
|
||||
void forLoops(int length()) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
print(i + 1);
|
||||
}
|
||||
for (int i = 0; i < length(); i++) {
|
||||
print(i + 1);
|
||||
}
|
||||
for (int i = 0, n = length(); i < n; i++) {
|
||||
print(i + 1);
|
||||
}
|
||||
// TODO(ochafik): Special-case `int + 0` to provide a cheap way to coerce
|
||||
// ints to notnull in the SDK (like asm.js's `x|0` pattern).
|
||||
for (int i = 0, n = length() + 0; i < n; i++) {
|
||||
print(i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void nullableCycle() {
|
||||
int x = 1;
|
||||
int y = 2;
|
||||
int z;
|
||||
x = y;
|
||||
y = z;
|
||||
z = x;
|
||||
print(x + y + z);
|
||||
|
||||
int s;
|
||||
s = s;
|
||||
print(s + 1);
|
||||
}
|
||||
|
||||
void nonNullableCycle() {
|
||||
int x = 1;
|
||||
int y = 2;
|
||||
int z = 3;
|
||||
x = y;
|
||||
y = z;
|
||||
z = x;
|
||||
print(x + y + z);
|
||||
|
||||
int s = 1;
|
||||
s = s;
|
||||
print(s + 1);
|
||||
}
|
||||
|
||||
class Foo {
|
||||
int intField;
|
||||
var varField;
|
||||
f(Foo o) {
|
||||
print(1 + varField + 2);
|
||||
while (varField < 10) varField++;
|
||||
while (varField < 10) varField = varField + 1;
|
||||
|
||||
print(1 + intField + 2);
|
||||
while (intField < 10) intField++;
|
||||
while (intField < 10) intField = intField + 1;
|
||||
|
||||
print(1 + o.intField + 2);
|
||||
while (o.intField < 10) o.intField++;
|
||||
while (o.intField < 10) o.intField = o.intField + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int _foo() => 1;
|
||||
calls() {
|
||||
int a = 1;
|
||||
int b = 1;
|
||||
b = ((x) => x)(a);
|
||||
print(b + 1);
|
||||
|
||||
int c = _foo();
|
||||
print(c + 1);
|
||||
}
|
||||
|
||||
localEscapes() {
|
||||
int a = 1;
|
||||
var f = (x) => a = x;
|
||||
|
||||
int b = 1;
|
||||
g(x) => b = x;
|
||||
|
||||
f(1);
|
||||
g(1);
|
||||
|
||||
print(a + b);
|
||||
}
|
||||
|
||||
controlFlow() {
|
||||
for (int i, j;;) {
|
||||
i = j = 1;
|
||||
print(i + j + 1);
|
||||
break;
|
||||
}
|
||||
try {
|
||||
throw 1;
|
||||
} catch (e) {
|
||||
print(e + 1);
|
||||
}
|
||||
try {
|
||||
(null as dynamic).foo();
|
||||
} catch (e, trace) {
|
||||
print('${(e is String) ? e : e.toString()} at $trace');
|
||||
}
|
||||
}
|
||||
|
||||
cascadesOnNull() {
|
||||
dynamic x = null;
|
||||
print((x
|
||||
..toString()
|
||||
..runtimeType)
|
||||
.hashCode);
|
||||
|
||||
Object y = null;
|
||||
print((y
|
||||
..toString()
|
||||
..runtimeType)
|
||||
.hashCode);
|
||||
}
|
||||
|
||||
main() {
|
||||
intAssignments();
|
||||
doubleAssignments();
|
||||
boolAssignments();
|
||||
nullableLocals(1);
|
||||
optParams(1, 2);
|
||||
namedParams(x: 1, y: 2);
|
||||
forLoops(() => 10);
|
||||
increments();
|
||||
conditionals(true);
|
||||
calls();
|
||||
localEscapes();
|
||||
controlFlow();
|
||||
cascadesOnNull();
|
||||
|
||||
nullableCycle();
|
||||
nonNullableCycle();
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
get index {
|
||||
print('called "index" getter');
|
||||
return 0;
|
||||
}
|
||||
|
||||
final _foo = new Foo();
|
||||
get foo {
|
||||
print('called "foo" getter');
|
||||
return _foo;
|
||||
}
|
||||
|
||||
class Foo { int x = 100; }
|
||||
|
||||
main() {
|
||||
var f = { 0: 40 };
|
||||
print('should only call "index" 2 times:');
|
||||
++f[index];
|
||||
forcePostfix(f[index]++);
|
||||
|
||||
print('should only call "foo" 2 times:');
|
||||
++foo.x;
|
||||
forcePostfix(foo.x++);
|
||||
|
||||
print('op assign test, should only call "index" twice:');
|
||||
f[index] += f[index];
|
||||
}
|
||||
|
||||
// Postfix generates as prefix if the value isn't used. This method prevents it.
|
||||
forcePostfix(x) {}
|
|
@ -1,34 +0,0 @@
|
|||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
Iterable<int> foo() sync* {
|
||||
yield 1;
|
||||
yield* [2, 3];
|
||||
}
|
||||
|
||||
class Class {
|
||||
Iterable<int> bar() sync* {
|
||||
yield 1;
|
||||
yield* [2, 3];
|
||||
}
|
||||
|
||||
static Iterable<int> baz() sync* {
|
||||
yield 1;
|
||||
yield* [2, 3];
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
Iterable<int> qux() sync* {
|
||||
yield 1;
|
||||
yield* [2, 3];
|
||||
}
|
||||
|
||||
Expect.listEquals([1, 2, 3], foo().toList());
|
||||
Expect.listEquals([1, 2, 3], new Class().bar().toList());
|
||||
Expect.listEquals([1, 2, 3], Class.baz().toList());
|
||||
Expect.listEquals([1, 2, 3], qux().toList());
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class FormalCollision {
|
||||
// These shouldn't collide (see issue #136)
|
||||
int _x, __x;
|
||||
// This shouldn't generate a keyword as an identifier.
|
||||
Function _function;
|
||||
FormalCollision(this._x, this.__x, this._function);
|
||||
}
|
||||
|
||||
class OptionalArg {
|
||||
int opt, _opt;
|
||||
OptionalArg([this._opt = 123]);
|
||||
OptionalArg.named({this.opt: 456});
|
||||
}
|
||||
|
||||
main() {
|
||||
print(new FormalCollision(1, 2, (x) => x));
|
||||
print(new OptionalArg()._opt);
|
||||
print(new OptionalArg.named()._opt);
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
foo() {
|
||||
try {
|
||||
throw "hi there";
|
||||
} on String catch (e, t) {
|
||||
} catch (e, t) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
bar() {
|
||||
try {
|
||||
throw "hi there";
|
||||
} catch (e, t) {
|
||||
} on String catch (e, t) {
|
||||
// unreachable
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
baz() {
|
||||
try {
|
||||
throw "finally only";
|
||||
} finally {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
qux() {
|
||||
try {
|
||||
throw "on only";
|
||||
} on String catch (e, t) {
|
||||
// unreachable
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
wub() {
|
||||
try {
|
||||
throw "on without exception parameter";
|
||||
} on String {
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
foo();
|
||||
bar();
|
||||
baz();
|
||||
qux();
|
||||
wub();
|
||||
}
|
|
@ -3,10 +3,15 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
/// Tests code generation.
|
||||
///
|
||||
/// Runs Dart Dev Compiler on all input in the `codegen` directory and checks
|
||||
/// that the output is what we expected.
|
||||
library dev_compiler.test.codegen_test;
|
||||
|
||||
// TODO(rnystrom): This doesn't actually run any tests any more. It just
|
||||
// compiles stuff. This should be changed to not use unittest and just be a
|
||||
// regular program that outputs files.
|
||||
|
||||
import 'dart:convert' show JSON;
|
||||
import 'dart:io' show Directory, File, Platform;
|
||||
import 'package:args/args.dart' show ArgParser, ArgResults;
|
||||
|
@ -24,7 +29,7 @@ import 'package:analyzer/src/generated/source.dart' show Source;
|
|||
import 'package:dev_compiler/src/analyzer/context.dart' show AnalyzerOptions;
|
||||
import 'package:dev_compiler/src/compiler/compiler.dart'
|
||||
show BuildUnit, CompilerOptions, ModuleCompiler;
|
||||
import 'testing.dart' show testDirectory;
|
||||
import 'testing.dart' show repoDirectory, testDirectory;
|
||||
import 'multitest.dart' show extractTestsFromMultitest, isMultiTest;
|
||||
import '../tool/build_sdk.dart' as build_sdk;
|
||||
import 'package:dev_compiler/src/compiler/compiler.dart';
|
||||
|
@ -32,12 +37,48 @@ import 'package:dev_compiler/src/compiler/compiler.dart';
|
|||
final ArgParser argParser = new ArgParser()
|
||||
..addOption('dart-sdk', help: 'Dart SDK Path', defaultsTo: null);
|
||||
|
||||
/// The `test/codegen` directory.
|
||||
final codegenDir = path.join(testDirectory, 'codegen');
|
||||
|
||||
/// The generated directory where tests, expanded multitests, and other test
|
||||
/// support libraries are copied to.
|
||||
///
|
||||
/// The tests sometimes import utility libraries using a relative path.
|
||||
/// Likewise, the multitests do too, and one multitest even imports its own
|
||||
/// non-expanded form (!). To make that simpler, we copy the entire test tree
|
||||
/// to a generated directory and expand that multitests in there too.
|
||||
final codegenTestDir = path.join(repoDirectory, 'gen', 'codegen_tests');
|
||||
|
||||
/// The generated directory where tests and packages compiled to JS are
|
||||
/// output.
|
||||
final codegenOutputDir = path.join(repoDirectory, 'gen', 'codegen_output');
|
||||
|
||||
// TODO(jmesserly): switch this to a .packages file.
|
||||
final packageUrlMappings = {
|
||||
'package:expect/expect.dart': path.join(codegenDir, 'expect.dart'),
|
||||
'package:async_helper/async_helper.dart':
|
||||
path.join(codegenDir, 'async_helper.dart'),
|
||||
'package:js/js.dart': path.join(codegenDir, 'packages', 'js', 'js.dart')
|
||||
};
|
||||
|
||||
final codeCoverage = Platform.environment.containsKey('COVERALLS_TOKEN');
|
||||
|
||||
main(arguments) {
|
||||
if (arguments == null) arguments = [];
|
||||
ArgResults args = argParser.parse(arguments);
|
||||
var filePattern = new RegExp(args.rest.length > 0 ? args.rest[0] : '.');
|
||||
|
||||
var expectDir = path.join(inputDir, 'expect');
|
||||
var sdkDir = path.join(repoDirectory, 'gen', 'patched_sdk');
|
||||
var sdkSummaryFile =
|
||||
path.join(testDirectory, '..', 'lib', 'runtime', 'dart_sdk.sum');
|
||||
var analyzerOptions = new AnalyzerOptions(
|
||||
customUrlMappings: packageUrlMappings,
|
||||
dartSdkSummaryPath: sdkSummaryFile);
|
||||
var compiler = new ModuleCompiler(analyzerOptions);
|
||||
|
||||
// Build packages tests depend on.
|
||||
_buildAllPackages(compiler);
|
||||
|
||||
var testDirs = [
|
||||
'language',
|
||||
'corelib',
|
||||
|
@ -47,105 +88,60 @@ main(arguments) {
|
|||
path.join('lib', 'typed_data')
|
||||
];
|
||||
|
||||
var multitests = expandMultiTests(testDirs, filePattern);
|
||||
|
||||
// Build packages tests depend on
|
||||
var sdkSummaryFile =
|
||||
path.join(testDirectory, '..', 'lib', 'runtime', 'dart_sdk.sum');
|
||||
var analyzerOptions = new AnalyzerOptions(
|
||||
customUrlMappings: packageUrlMappings,
|
||||
dartSdkSummaryPath: sdkSummaryFile);
|
||||
var compiler = new ModuleCompiler(analyzerOptions);
|
||||
|
||||
group('dartdevc package', () {
|
||||
_buildPackages(compiler, expectDir);
|
||||
|
||||
test('matcher', () {
|
||||
_buildPackage(compiler, expectDir, "matcher");
|
||||
});
|
||||
|
||||
test('unittest', () {
|
||||
// Only build files applicable to the web - html_*.dart and its
|
||||
// internal dependences.
|
||||
_buildPackage(compiler, expectDir, "unittest", packageFiles: [
|
||||
'unittest.dart',
|
||||
'html_config.dart',
|
||||
'html_individual_config.dart',
|
||||
'html_enhanced_config.dart'
|
||||
]);
|
||||
});
|
||||
|
||||
test('stack_trace', () {
|
||||
_buildPackage(compiler, expectDir, "stack_trace");
|
||||
});
|
||||
|
||||
test('path', () {
|
||||
_buildPackage(compiler, expectDir, "path");
|
||||
});
|
||||
});
|
||||
|
||||
test('dartdevc sunflower', () {
|
||||
_buildSunflower(compiler, expectDir);
|
||||
});
|
||||
// Copy all of the test files and expanded multitest files to
|
||||
// gen/codegen_tests. We'll compile from there.
|
||||
var testFiles = _setUpTests(testDirs, filePattern);
|
||||
|
||||
// Our default compiler options. Individual tests can override these.
|
||||
var defaultOptions = ['--no-source-map', '--no-summarize'];
|
||||
var compilerArgParser = CompilerOptions.addArguments(new ArgParser());
|
||||
|
||||
var allDirs = [null];
|
||||
allDirs.addAll(testDirs);
|
||||
for (var dir in allDirs) {
|
||||
if (codeCoverage && dir != null) continue;
|
||||
// Compile each test file to JS and put the result in gen/codegen_output.
|
||||
for (var testFile in testFiles) {
|
||||
var relativePath = path.relative(testFile, from: codegenTestDir);
|
||||
|
||||
group('dartdevc ' + path.join('test', 'codegen', dir), () {
|
||||
var outDir = new Directory(path.join(expectDir, dir));
|
||||
if (!outDir.existsSync()) outDir.createSync(recursive: true);
|
||||
// Only compile the top-level files for generating coverage.
|
||||
if (codeCoverage && path.dirname(relativePath) != ".") continue;
|
||||
|
||||
var baseDir = path.join(inputDir, dir);
|
||||
var testFiles = _findTests(baseDir, filePattern);
|
||||
for (var filePath in testFiles) {
|
||||
if (multitests.contains(filePath)) continue;
|
||||
var name = path.withoutExtension(relativePath);
|
||||
test('dartdevc $name', () {
|
||||
var outDir = path.join(codegenOutputDir, path.dirname(relativePath));
|
||||
_ensureDirectory(outDir);
|
||||
|
||||
var filename = path.basenameWithoutExtension(filePath);
|
||||
// Check if we need to use special compile options.
|
||||
var contents = new File(testFile).readAsStringSync();
|
||||
var match =
|
||||
new RegExp(r'// compile options: (.*)').matchAsPrefix(contents);
|
||||
|
||||
test('$filename.dart', () {
|
||||
// Check if we need to use special compile options.
|
||||
var contents = new File(filePath).readAsStringSync();
|
||||
var match =
|
||||
new RegExp(r'// compile options: (.*)').matchAsPrefix(contents);
|
||||
|
||||
var args = new List.from(defaultOptions);
|
||||
if (match != null) {
|
||||
args.addAll(match.group(1).split(' '));
|
||||
}
|
||||
var options =
|
||||
new CompilerOptions.fromArguments(compilerArgParser.parse(args));
|
||||
|
||||
// Collect any other files we've imported.
|
||||
var files = new Set<String>();
|
||||
_collectTransitiveImports(contents, files, from: filePath);
|
||||
var moduleName =
|
||||
path.withoutExtension(path.relative(filePath, from: inputDir));
|
||||
var unit = new BuildUnit(
|
||||
moduleName, baseDir, files.toList(), _moduleForLibrary);
|
||||
var module = compiler.compile(unit, options);
|
||||
_writeModule(path.join(outDir.path, filename), module);
|
||||
});
|
||||
var args = defaultOptions.toList();
|
||||
if (match != null) {
|
||||
args.addAll(match.group(1).split(' '));
|
||||
}
|
||||
var options =
|
||||
new CompilerOptions.fromArguments(compilerArgParser.parse(args));
|
||||
|
||||
// Collect any other files we've imported.
|
||||
var files = new Set<String>();
|
||||
_collectTransitiveImports(contents, files, from: testFile);
|
||||
var moduleName =
|
||||
path.withoutExtension(path.relative(testFile, from: codegenTestDir));
|
||||
var unit = new BuildUnit(moduleName, path.dirname(testFile),
|
||||
files.toList(), _moduleForLibrary);
|
||||
var module = compiler.compile(unit, options);
|
||||
_writeModule(
|
||||
path.join(outDir, path.basenameWithoutExtension(testFile)), module);
|
||||
});
|
||||
}
|
||||
|
||||
if (codeCoverage) {
|
||||
test('build_sdk code coverage', () {
|
||||
var generatedSdkDir =
|
||||
path.join(testDirectory, '..', 'tool', 'generated_sdk');
|
||||
return build_sdk.main(['--dart-sdk', generatedSdkDir, '-o', expectDir]);
|
||||
return build_sdk.main(['--dart-sdk', sdkDir, '-o', codegenOutputDir]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _writeModule(String outPath, JSModuleFile result) {
|
||||
new Directory(path.dirname(outPath)).createSync(recursive: true);
|
||||
_ensureDirectory(path.dirname(outPath));
|
||||
|
||||
String errors = result.errors.join('\n');
|
||||
if (errors.isNotEmpty && !errors.endsWith('\n')) errors += '\n';
|
||||
|
@ -177,8 +173,36 @@ void _writeModule(String outPath, JSModuleFile result) {
|
|||
}
|
||||
}
|
||||
|
||||
void _buildSunflower(ModuleCompiler compiler, String expectDir) {
|
||||
var baseDir = path.join(inputDir, 'sunflower');
|
||||
void _buildAllPackages(ModuleCompiler compiler) {
|
||||
group('dartdevc package', () {
|
||||
_buildPackages(compiler, codegenOutputDir);
|
||||
|
||||
var packages = ['matcher', 'path', 'stack_trace'];
|
||||
for (var package in packages) {
|
||||
test(package, () {
|
||||
_buildPackage(compiler, codegenOutputDir, package);
|
||||
});
|
||||
}
|
||||
|
||||
test('unittest', () {
|
||||
// Only build files applicable to the web - html_*.dart and its
|
||||
// internal dependences.
|
||||
_buildPackage(compiler, codegenOutputDir, "unittest", packageFiles: [
|
||||
'unittest.dart',
|
||||
'html_config.dart',
|
||||
'html_individual_config.dart',
|
||||
'html_enhanced_config.dart'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
test('dartdevc sunflower', () {
|
||||
_buildSunflower(compiler, codegenOutputDir);
|
||||
});
|
||||
}
|
||||
|
||||
void _buildSunflower(ModuleCompiler compiler, String outputDir) {
|
||||
var baseDir = path.join(codegenDir, 'sunflower');
|
||||
var files = ['sunflower', 'circle', 'painter']
|
||||
.map((f) => path.join(baseDir, '$f.dart'))
|
||||
.toList();
|
||||
|
@ -186,10 +210,10 @@ void _buildSunflower(ModuleCompiler compiler, String expectDir) {
|
|||
var options = new CompilerOptions(summarizeApi: false);
|
||||
|
||||
var built = compiler.compile(input, options);
|
||||
_writeModule(path.join(expectDir, 'sunflower', 'sunflower'), built);
|
||||
_writeModule(path.join(outputDir, 'sunflower', 'sunflower'), built);
|
||||
}
|
||||
|
||||
void _buildPackages(ModuleCompiler compiler, String expectDir) {
|
||||
void _buildPackages(ModuleCompiler compiler, String outputDir) {
|
||||
// Note: we don't summarize these, as we're going to rely on our in-memory
|
||||
// shared analysis context for caching, and `_moduleForLibrary` below
|
||||
// understands these are from other modules.
|
||||
|
@ -200,33 +224,33 @@ void _buildPackages(ModuleCompiler compiler, String expectDir) {
|
|||
var uriPath = uri.substring('package:'.length);
|
||||
var name = path.basenameWithoutExtension(uriPath);
|
||||
test(name, () {
|
||||
var input = new BuildUnit(name, inputDir, [uri], _moduleForLibrary);
|
||||
var input = new BuildUnit(name, codegenDir, [uri], _moduleForLibrary);
|
||||
var built = compiler.compile(input, options);
|
||||
|
||||
var outPath = path.join(expectDir, path.withoutExtension(uriPath));
|
||||
var outPath = path.join(outputDir, path.withoutExtension(uriPath));
|
||||
_writeModule(outPath, built);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _buildPackage(ModuleCompiler compiler, String expectDir, packageName,
|
||||
void _buildPackage(ModuleCompiler compiler, String outputDir, packageName,
|
||||
{List<String> packageFiles}) {
|
||||
var options = new CompilerOptions(sourceMap: false, summarizeApi: false);
|
||||
|
||||
var packageRoot = path.join(inputDir, 'packages');
|
||||
var packageRoot = path.join(codegenDir, 'packages');
|
||||
var packageInputDir = path.join(packageRoot, packageName);
|
||||
List<String> files;
|
||||
if (packageFiles != null) {
|
||||
// Only collect files transitively reachable from packageFiles
|
||||
// Only collect files transitively reachable from packageFiles.
|
||||
var reachable = new Set<String>();
|
||||
for (var f in packageFiles) {
|
||||
f = path.join(packageInputDir, f);
|
||||
_collectTransitiveImports(new File(f).readAsStringSync(), reachable,
|
||||
packageRoot: packageRoot, from: f);
|
||||
for (var file in packageFiles) {
|
||||
file = path.join(packageInputDir, file);
|
||||
_collectTransitiveImports(new File(file).readAsStringSync(), reachable,
|
||||
packageRoot: packageRoot, from: file);
|
||||
}
|
||||
files = reachable.toList();
|
||||
} else {
|
||||
// Collect all files in the packages directory
|
||||
// Collect all files in the packages directory.
|
||||
files = new Directory(packageInputDir)
|
||||
.listSync(recursive: true)
|
||||
.where((entry) => entry.path.endsWith('.dart'))
|
||||
|
@ -238,7 +262,7 @@ void _buildPackage(ModuleCompiler compiler, String expectDir, packageName,
|
|||
new BuildUnit(packageName, packageInputDir, files, _moduleForLibrary);
|
||||
var module = compiler.compile(unit, options);
|
||||
|
||||
var outPath = path.join(expectDir, packageName, packageName);
|
||||
var outPath = path.join(outputDir, packageName, packageName);
|
||||
_writeModule(outPath, module);
|
||||
}
|
||||
|
||||
|
@ -250,62 +274,79 @@ String _moduleForLibrary(Source source) {
|
|||
throw new Exception('Module not found for library "${source.fullName}"');
|
||||
}
|
||||
|
||||
/// Expands wacky multitests into a bunch of test files.
|
||||
///
|
||||
/// We'll compile each one as if it was an input.
|
||||
/// NOTE: this will write the individual test files to disk.
|
||||
Set<String> expandMultiTests(List testDirs, RegExp filePattern) {
|
||||
var multitests = new Set<String>();
|
||||
List<String> _setUpTests(List<String> testDirs, RegExp filePattern) {
|
||||
var testFiles = [];
|
||||
|
||||
for (var testDir in testDirs) {
|
||||
var fullDir = path.join(inputDir, testDir);
|
||||
var testFiles = _findTests(fullDir, filePattern);
|
||||
for (var file in _listFiles(path.join(codegenDir, testDir), filePattern,
|
||||
recursive: true)) {
|
||||
var relativePath = path.relative(file, from: codegenDir);
|
||||
var outputPath = path.join(codegenTestDir, relativePath);
|
||||
|
||||
for (var filePath in testFiles) {
|
||||
if (filePath.endsWith('_multi.dart')) continue;
|
||||
_ensureDirectory(path.dirname(outputPath));
|
||||
|
||||
var contents = new File(filePath).readAsStringSync();
|
||||
if (isMultiTest(contents)) {
|
||||
multitests.add(filePath);
|
||||
// Copy it over. We do this even for multitests because import_self_test
|
||||
// is a multitest, yet imports its own unexpanded form (!).
|
||||
new File(file).copySync(outputPath);
|
||||
|
||||
var tests = new Map<String, String>();
|
||||
var outcomes = new Map<String, Set<String>>();
|
||||
extractTestsFromMultitest(filePath, contents, tests, outcomes);
|
||||
if (file.endsWith("_test.dart")) {
|
||||
var contents = new File(file).readAsStringSync();
|
||||
|
||||
var filename = path.basenameWithoutExtension(filePath);
|
||||
tests.forEach((name, contents) {
|
||||
new File(path.join(fullDir, '${filename}_${name}_multi.dart'))
|
||||
.writeAsStringSync(contents);
|
||||
});
|
||||
if (isMultiTest(contents)) {
|
||||
// It's a multitest, so expand it and add all of the variants.
|
||||
var tests = <String, String>{};
|
||||
var outcomes = <String, Set<String>>{};
|
||||
extractTestsFromMultitest(file, contents, tests, outcomes);
|
||||
|
||||
var fileName = path.basenameWithoutExtension(file);
|
||||
var outputDir = path.dirname(outputPath);
|
||||
tests.forEach((name, contents) {
|
||||
var multiFile =
|
||||
path.join(outputDir, '${fileName}_${name}_multi.dart');
|
||||
testFiles.add(multiFile);
|
||||
|
||||
new File(multiFile).writeAsStringSync(contents);
|
||||
});
|
||||
} else {
|
||||
// It's a single test suite.
|
||||
testFiles.add(outputPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return multitests;
|
||||
|
||||
// Also include the other special files that live at the top level directory.
|
||||
for (var file in _listFiles(codegenDir, filePattern)) {
|
||||
var relativePath = path.relative(file, from: codegenDir);
|
||||
var outputPath = path.join(codegenTestDir, relativePath);
|
||||
|
||||
new File(file).copySync(outputPath);
|
||||
if (file.endsWith(".dart")) {
|
||||
testFiles.add(outputPath);
|
||||
}
|
||||
}
|
||||
|
||||
return testFiles;
|
||||
}
|
||||
|
||||
// TODO(jmesserly): switch this to a .packages file.
|
||||
final packageUrlMappings = {
|
||||
'package:expect/expect.dart': path.join(inputDir, 'expect.dart'),
|
||||
'package:async_helper/async_helper.dart':
|
||||
path.join(inputDir, 'async_helper.dart'),
|
||||
'package:js/js.dart': path.join(inputDir, 'packages', 'js', 'js.dart')
|
||||
};
|
||||
/// Recursively creates [dir] if it doesn't exist.
|
||||
void _ensureDirectory(String dir) {
|
||||
new Directory(dir).createSync(recursive: true);
|
||||
}
|
||||
|
||||
final codeCoverage = Platform.environment.containsKey('COVERALLS_TOKEN');
|
||||
/// Lists all of the files within [dir] that match [filePattern].
|
||||
Iterable<String> _listFiles(String dir, RegExp filePattern,
|
||||
{bool recursive: false}) {
|
||||
return new Directory(dir)
|
||||
.listSync(recursive: recursive, followLinks: false)
|
||||
.where((entry) {
|
||||
if (entry is! File) return false;
|
||||
|
||||
final inputDir = path.join(testDirectory, 'codegen');
|
||||
var filePath = entry.path;
|
||||
if (!filePattern.hasMatch(filePath)) return false;
|
||||
|
||||
Iterable<String> _findTests(String dir, RegExp filePattern) {
|
||||
var files = new Directory(dir)
|
||||
.listSync()
|
||||
.where((f) => f is File)
|
||||
.map((f) => f.path)
|
||||
.where((p) => p.endsWith('.dart') && filePattern.hasMatch(p));
|
||||
if (dir != inputDir) {
|
||||
files = files
|
||||
.where((p) => p.endsWith('_test.dart') || p.endsWith('_multi.dart'));
|
||||
}
|
||||
return files;
|
||||
return true;
|
||||
}).map((file) => file.path);
|
||||
}
|
||||
|
||||
/// Parse directives from [contents] and find the complete set of transitive
|
||||
|
|
|
@ -13,6 +13,9 @@ import 'package:path/path.dart' as path;
|
|||
final String testDirectory =
|
||||
path.dirname((reflectClass(_TestUtils).owner as LibraryMirror).uri.path);
|
||||
|
||||
/// The local path to the root directory of the dev_compiler repo.
|
||||
final String repoDirectory = path.dirname(testDirectory);
|
||||
|
||||
class _TestUtils {}
|
||||
|
||||
class TestUriResolver extends ResourceUriResolver {
|
||||
|
|
|
@ -10,7 +10,7 @@ This script combines:
|
|||
|
||||
and produces the merged SDK sources in:
|
||||
|
||||
tool/generated_sdk/...
|
||||
gen/patched_sdk/...
|
||||
|
||||
The result has all "external" keywords replaced with the @patch implementations.
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ set -e
|
|||
cd $( dirname "${BASH_SOURCE[0]}" )/..
|
||||
|
||||
echo "*** Patching SDK"
|
||||
dart -c tool/patch_sdk.dart tool/input_sdk tool/generated_sdk
|
||||
dart -c tool/patch_sdk.dart tool/input_sdk gen/patched_sdk
|
||||
|
||||
echo "*** Compiling SDK to JavaScript"
|
||||
|
||||
|
@ -17,6 +17,6 @@ echo "*** Compiling SDK to JavaScript"
|
|||
# into the compiler itself, so it can emit the correct import.
|
||||
#
|
||||
dart -c tool/build_sdk.dart \
|
||||
--dart-sdk tool/generated_sdk \
|
||||
--dart-sdk gen/patched_sdk \
|
||||
-o lib/runtime/dart_sdk.js \
|
||||
"$@" > tool/sdk_expected_errors.txt
|
||||
|
|
|
@ -20,15 +20,11 @@ void main(List<String> argv) {
|
|||
|
||||
var inputExample = path.join(toolDir, 'input_sdk');
|
||||
var outExample = path.relative(
|
||||
path.normalize(path.join(toolDir, '..', 'test', 'generated_sdk')));
|
||||
path.normalize(path.join('gen', 'patched_sdk')));
|
||||
|
||||
print('Usage: $self INPUT_DIR OUTPUT_DIR');
|
||||
print('For example:');
|
||||
print('\$ $self $inputExample $outExample');
|
||||
|
||||
inputExample = path.join(toolDir, 'min_sdk');
|
||||
outExample = path.join(toolDir, 'out', 'min_sdk');
|
||||
print('\$ $self $inputExample $outExample');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
dart -c tool/patch_sdk.dart tool/input_sdk tool/generated_sdk
|
||||
dart -c tool/patch_sdk.dart tool/input_sdk gen/patched_sdk
|
||||
|
|
|
@ -19,6 +19,14 @@ if [ -d test/codegen/expect ]; then
|
|||
rm -r test/codegen/expect || fail
|
||||
fi
|
||||
|
||||
if [ -d gen/codegen_input ]; then
|
||||
rm -r gen/codegen_input || fail
|
||||
fi
|
||||
|
||||
if [ -d gen/codegen_output ]; then
|
||||
rm -r gen/codegen_output || fail
|
||||
fi
|
||||
|
||||
# Make sure we don't run tests in code coverage mode.
|
||||
# this will cause us to generate files that are not part of the baseline
|
||||
# TODO(jmesserly): we should move diff into Dart code, so we don't need to
|
||||
|
|
Loading…
Reference in a new issue