├── .editorconfig ├── .gitattributes ├── .gitignore ├── .travis.yml ├── AUTHORS ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── build ├── build-parse-tree-transformer.js ├── build-parse-tree-type.js ├── build-parse-tree-visitor.js ├── build-parse-trees.js ├── build-unicode-tables.js ├── expand-js-template.js ├── minifier.js ├── parse-tree-transformer.header ├── parse-tree-visitor.header ├── prepublish.js ├── util.js └── versionInfo.js ├── demo ├── 1947 │ ├── app.js │ ├── index.html │ └── square.js ├── SourceMapMapping.js ├── SourceMapVisualizer.js ├── async-read-file.js ├── async.html ├── await.html ├── expressServer.js ├── generators.js ├── parallel-fibonacci.js ├── repl-module.js ├── repl.html ├── repl.js ├── replOptions.js ├── resources │ └── Observable.js └── transcode.js ├── example └── hello.html ├── gh-pages.gitignore ├── index.html ├── logo ├── tc.ai ├── tc.eps ├── tc.jpg ├── tc.png └── tc.svg ├── package.json ├── src ├── Compiler.js ├── HTMLImportTranscoder.js ├── Options.js ├── WebPageTranscoder.js ├── bootstrap.js ├── browser │ └── System.js ├── codegeneration │ ├── AlphaRenamer.js │ ├── AmdTransformer.js │ ├── AnnotationsTransformer.js │ ├── ArrayComprehensionTransformer.js │ ├── ArrowFunctionTransformer.js │ ├── AsyncGeneratorTransformPass.js │ ├── AsyncGeneratorTransformer.js │ ├── AsyncToGeneratorTransformer.js │ ├── BlockBindingTransformer.js │ ├── ClassTransformer.js │ ├── CloneTreeTransformer.js │ ├── ClosureModuleTransformer.js │ ├── CommonJsModuleTransformer.js │ ├── ComprehensionTransformer.js │ ├── DefaultParametersTransformer.js │ ├── DestructuringTransformer.js │ ├── ExplodeExpressionTransformer.js │ ├── ExponentiationTransformer.js │ ├── FindArguments.js │ ├── FindIdentifiers.js │ ├── FindInFunctionScope.js │ ├── FindThisOrArguments.js │ ├── FindVisitor.js │ ├── FnExtractAbruptCompletions.js │ ├── ForOfTransformer.js │ ├── ForOnTransformer.js │ ├── FromOptionsTransformer.js │ ├── GeneratorComprehensionTransformer.js │ ├── GeneratorTransformPass.js │ ├── HoistVariablesTransformer.js │ ├── ImportRuntimeTrait.js │ ├── ImportSimplifyingTransformer.js │ ├── InlineES6ModuleTransformer.js │ ├── InlineModuleTransformer.js │ ├── InnerForOnTransformer.js │ ├── InstantiateModuleTransformer.js │ ├── JsxTransformer.js │ ├── MakeStrictTransformer.js │ ├── MemberVariableConstructorTransformer.js │ ├── MemberVariableTransformer.js │ ├── ModuleTransformer.js │ ├── MultiTransformer.js │ ├── NumericLiteralTransformer.js │ ├── ObjectLiteralTransformer.js │ ├── ParameterTransformer.js │ ├── ParenTrait.js │ ├── ParseTreeFactory.js │ ├── PlaceholderParser.js │ ├── PrependStatements.js │ ├── ProperTailCallTransformer.js │ ├── PropertyNameShorthandTransformer.js │ ├── PureES6Transformer.js │ ├── RegularExpressionTransformer.js │ ├── RestParameterTransformer.js │ ├── RewriteTailCallsTransformer.js │ ├── RewriteTailExpressionsTransformer.js │ ├── ScopeTransformer.js │ ├── SkipFunctionsTransformerTrait.js │ ├── SpreadPropertiesTransformer.js │ ├── SpreadTransformer.js │ ├── SuperTransformer.js │ ├── SymbolTransformer.js │ ├── TempVarTransformer.js │ ├── TemplateLiteralTransformer.js │ ├── TypeToExpressionTransformer.js │ ├── TypeTransformer.js │ ├── UnicodeEscapeSequenceTransformer.js │ ├── UniqueIdentifierGenerator.js │ ├── alphaRenameThisAndArguments.js │ ├── assignmentOperatorToBinaryOperator.js │ ├── generator │ │ ├── AsyncTransformer.js │ │ ├── AwaitState.js │ │ ├── BreakContinueTransformer.js │ │ ├── BreakState.js │ │ ├── CPSTransformer.js │ │ ├── CatchState.js │ │ ├── ConditionalState.js │ │ ├── ContinueState.js │ │ ├── EndState.js │ │ ├── FallThroughState.js │ │ ├── FinallyFallThroughState.js │ │ ├── FinallyState.js │ │ ├── ForInTransformPass.js │ │ ├── GeneratorTransformer.js │ │ ├── ReturnState.js │ │ ├── State.js │ │ ├── StateAllocator.js │ │ ├── SwitchState.js │ │ ├── TryState.js │ │ └── YieldState.js │ ├── globalThis.js │ ├── module │ │ ├── AttachModuleNameTransformer.js │ │ ├── DirectExportVisitor.js │ │ ├── ExportListBuilder.js │ │ ├── ExportVisitor.js │ │ ├── ModuleSpecifierVisitor.js │ │ ├── ModuleSymbol.js │ │ ├── ModuleVisitor.js │ │ ├── ValidationVisitor.js │ │ └── createModuleEvaluationStatement.js │ └── scopeContainsThis.js ├── compiler-imports.js ├── loader │ ├── InlineLoaderCompiler.js │ ├── InternalLoader.js │ ├── Loader.js │ ├── LoaderCompiler.js │ ├── ModuleStore.js │ ├── ModuleStoreImpl.js │ ├── NodeTraceurLoader.js │ ├── TraceurLoader.js │ ├── loader-imports.js │ ├── system-map.js │ └── webLoader.js ├── node │ ├── NodeCompiler.js │ ├── NodeLoaderCompiler.js │ ├── System.js │ ├── api.js │ ├── command.js │ ├── compileAllJsFilesInDir.js │ ├── deferred.js │ ├── file-util.js │ ├── get-dependencies.js │ ├── interpreter.js │ ├── nodeLoader.js │ ├── recursiveModuleCompile.js │ ├── require.js │ ├── to-amd-compiler.js │ ├── to-closure-compiler.js │ ├── to-commonjs-compiler.js │ └── traceur.js ├── outputgeneration │ ├── ParseTreeMapWriter.js │ ├── ParseTreeWriter.js │ ├── SourceMapIntegration.js-template │ ├── TreeWriter.js │ ├── regexpuRewritePattern.js-template │ └── toSource.js ├── runtime │ ├── async.js │ ├── checkObjectCoercible.js │ ├── classes.js │ ├── destructuring.js │ ├── exportStar.js │ ├── frozen-data.js │ ├── generators.js │ ├── global-imports.js │ ├── has-native-symbols.js │ ├── jsx.js │ ├── modules │ │ ├── async.js │ │ ├── asyncWrap.js │ │ ├── call.js │ │ ├── construct.js │ │ ├── continuation.js │ │ ├── createAsyncGeneratorInstance.js │ │ ├── createClass.js │ │ ├── createDecoratedGenerator.js │ │ ├── createGeneratorInstance.js │ │ ├── createPrivateName.js │ │ ├── exportStar.js │ │ ├── generators.js │ │ ├── getTemplateObject.js │ │ ├── initAsyncGeneratorFunction.js │ │ ├── initGeneratorFunction.js │ │ ├── initTailRecursiveFunction.js │ │ ├── iteratorToArray.js │ │ ├── observeForEach.js │ │ ├── properTailCalls.js │ │ ├── schedule.js │ │ ├── spawn.js │ │ ├── spread.js │ │ ├── spreadProperties.js │ │ ├── superConstructor.js │ │ ├── superDescriptor.js │ │ ├── superGet.js │ │ ├── superSet.js │ │ ├── symbols.js │ │ └── typeof.js │ ├── new-unique-string.js │ ├── polyfills-imports.js │ ├── polyfills │ │ ├── Array.js │ │ ├── ArrayIterator.js │ │ ├── Map.js │ │ ├── Math.js │ │ ├── Number.js │ │ ├── Object.js │ │ ├── Promise.js │ │ ├── Set.js │ │ ├── String.js │ │ ├── StringIterator.js │ │ ├── WeakMap.js │ │ ├── WeakSet.js │ │ ├── assign.js │ │ ├── fround.js │ │ ├── polyfills.js │ │ └── utils.js │ ├── private-symbol.js │ ├── private-weak-map.js │ ├── private.js │ ├── properTailCalls.js │ ├── relativeRequire.js │ ├── runtime-modules.js │ ├── runtime.js │ ├── spawn.js │ ├── spread.js │ ├── symbols.js │ ├── template.js │ └── url.js ├── semantics │ ├── ConstChecker.js │ ├── ConstructorValidator.js │ ├── FreeVariableChecker.js │ ├── Scope.js │ ├── ScopeChainBuilder.js │ ├── ScopeChainBuilderWithReferences.js │ ├── ScopeReferences.js │ ├── ScopeVisitor.js │ ├── VariableBinder.js │ ├── bindingsInDestructuringPattern.js │ ├── isTreeStrict.js │ └── util.js ├── staticsemantics │ ├── PropName.js │ ├── isValidSimpleAssignmentTarget.js │ └── validateParameters.js ├── syntax │ ├── IdentifierToken.js │ ├── JsxIdentifierToken.js │ ├── KeywordToken.js │ ├── Keywords.js │ ├── LineNumberTable.js │ ├── LiteralToken.js │ ├── ParseTreeValidator.js │ ├── Parser.js │ ├── PredefinedName.js │ ├── Scanner.js │ ├── SourceFile.js │ ├── Token.js │ ├── TokenType.js │ ├── trees │ │ ├── ParseTree.js │ │ ├── StateMachine.js │ │ └── trees.json │ └── unicode-tables.js ├── traceur-import.js ├── traceur.js ├── util-imports.js └── util │ ├── CollectingErrorReporter.js │ ├── ErrorReporter.js │ ├── JSON.js │ ├── MutedErrorReporter.js │ ├── SourcePosition.js │ ├── SourceRange.js │ ├── StringMap.js │ ├── StringSet.js │ ├── SyntaxErrorReporter.js │ ├── assert.js │ ├── parseProlog.js │ └── url.js ├── test ├── amd │ ├── BasicImport.js │ ├── ImportEmptyImportClause.js │ ├── ImportNoImportClause.js │ ├── MultipleImports.js │ ├── NamedExports.js │ ├── NamedImports.js │ ├── NestedImport.js │ └── deps │ │ ├── bar.js │ │ ├── foo.js │ │ ├── object-for-side-effects.js │ │ ├── side-effect.js │ │ └── side-effect2.js ├── asserts.js ├── bench │ └── esprima-compare.patch ├── closure │ ├── BasicImport-expected.txt │ ├── BasicImport.js │ ├── ImportMulti-expected.txt │ ├── ImportMulti.js │ ├── ImportStar-expected.txt │ ├── ImportStar.js │ └── deps │ │ ├── export-default-expected.txt │ │ ├── export-default.js │ │ ├── export-named-expected.txt │ │ ├── export-named.js │ │ ├── foo-expected.txt │ │ └── foo.js ├── commonjs │ ├── BasicImport.js │ ├── ExportStar.js │ ├── ImportEmptyImportClause.js │ ├── ImportNoImportClause.js │ ├── MultipleImports.js │ ├── NamedImports.js │ ├── NestedImport.js │ ├── deps │ │ ├── bar.js │ │ ├── export-star.js │ │ ├── foo.js │ │ ├── object-for-side-effects.js │ │ ├── side-effect.js │ │ └── side-effect2.js │ └── node-require.js ├── feature │ ├── Annotations │ │ ├── AnnotatedFunctionTypedParam.js │ │ ├── AnnotatedTypedClass.js │ │ ├── AnnotatedTypedParam.js │ │ ├── Class.js │ │ ├── ClassConstructor.js │ │ ├── ClassGeneratorMethod.js │ │ ├── ClassInClass.js │ │ ├── ClassInsideObjectGetter.js │ │ ├── Constructor.js │ │ ├── ConstructorParam.js │ │ ├── Error_annotated_var.js │ │ ├── ExportedClass.js │ │ ├── ExportedFunction.js │ │ ├── FunctionInsideClassGetter.js │ │ ├── FunctionMultipleAnnotatedParameter.js │ │ ├── FunctionMultipleParameters.js │ │ ├── FunctionParameter.js │ │ ├── GeneratorFunction.js │ │ ├── GetAccessorStringName.js │ │ ├── MemberExpressionAnnotation.js │ │ ├── MethodParam.js │ │ ├── MultipleAnnotatedFunction.js │ │ ├── MultipleParameterTypes.js │ │ ├── NestedFunction.js │ │ ├── PropertyMethodStringName.js │ │ ├── SetterParam.js │ │ ├── SimpleFunction.js │ │ ├── StaticGetter.js │ │ ├── StaticMethod.js │ │ ├── StaticSetter.js │ │ ├── UnannotatedTypedClass.js │ │ ├── UnannotatedUntypedFunction.js │ │ └── resources │ │ │ ├── exported-classes.js │ │ │ ├── exported-default-class.js │ │ │ ├── exported-default-function.js │ │ │ ├── exported-functions.js │ │ │ └── setup.js │ ├── ArrayComprehension │ │ ├── ArgumentsInComprehension.js │ │ ├── Closure.js │ │ ├── Error_Disabled.js │ │ ├── Error_NotDefined.js │ │ ├── Simple.js │ │ └── ThisInComprehension.js │ ├── ArrayExtras │ │ ├── Fill.js │ │ ├── Find.script.js │ │ ├── FindIndex.js │ │ ├── From.js │ │ └── Of.js │ ├── ArrayIterator.js │ ├── ArrowFunctions │ │ ├── AlphaRename.script.js │ │ ├── AlphaRenameThisArguments.js │ │ ├── Arguments.js │ │ ├── ArrowFunctions.js │ │ ├── CoverInitializer.js │ │ ├── Error_CoverInitializer.js │ │ ├── Error_CoverInitializer2.js │ │ ├── Error_CoverInitializer3.js │ │ ├── Error_Disabled.js │ │ ├── Error_FreeVariableChecker.js │ │ ├── Error_InvalidFormalParameters.js │ │ ├── Error_LineTerminator.js │ │ ├── Error_Precedence.js │ │ ├── Error_Precedence2.js │ │ ├── Error_Precedence3.js │ │ ├── Error_SpreadNotLast.js │ │ ├── Error_SpreadOutsideFormals.js │ │ ├── FreeVariableChecker.js │ │ ├── InDerivedClassConstructor.js │ │ ├── Parens.js │ │ ├── Skip_Frozen.js │ │ ├── Skip_InitializerShorthand.js │ │ ├── Skip_SoftBind.js │ │ ├── SloppyArguments.script.js │ │ ├── ThisBindingInPropertyName.js │ │ └── ThisBindings.js │ ├── AsyncFunctions │ │ ├── AlphaRenaming.js │ │ ├── AsyncArrow.js │ │ ├── AsyncArrow2.js │ │ ├── AsyncArrowArguments.js │ │ ├── AsyncArrowThis.js │ │ ├── AsyncMethod.js │ │ ├── AsyncMethodObjectLiteral.js │ │ ├── AsyncSyntax.js │ │ ├── Basics.js │ │ ├── Complete.js │ │ ├── Empty.js │ │ ├── Error_AsyncArrow.js │ │ ├── Error_AsyncArrow2.js │ │ ├── Error_Disabled.js │ │ ├── Export.js │ │ ├── Finally.js │ │ ├── Finally2.js │ │ ├── PromiseCast.js │ │ ├── Prototype.js │ │ ├── Rethrow.js │ │ ├── Return.js │ │ ├── Throw.js │ │ ├── Timeout.js │ │ ├── Value.js │ │ ├── Yield.js │ │ └── resources │ │ │ └── async-function.js │ ├── AsyncFunctionsUsingGenerator │ │ ├── AlphaRenaming.js │ │ ├── AsyncArrow.js │ │ ├── AsyncArrow2.js │ │ ├── AsyncArrowArguments.js │ │ ├── AsyncArrowThis.js │ │ ├── AsyncMethod.js │ │ ├── AsyncMethodObjectLiteral.js │ │ ├── AsyncSyntax.js │ │ ├── Complete.js │ │ ├── Empty.js │ │ ├── Export.js │ │ ├── Finally.js │ │ ├── Finally2.js │ │ ├── PromiseCast.js │ │ ├── Prototype.js │ │ ├── Rethrow.js │ │ ├── Return.js │ │ ├── Throw.js │ │ ├── Timeout.js │ │ ├── Value.js │ │ ├── Yield.js │ │ └── resources │ │ │ └── async-function.js │ ├── AsyncGenerators │ │ ├── Array.js │ │ ├── AsyncGenerator.js │ │ ├── AsyncObservable.js │ │ ├── Demo.script.js │ │ ├── ForOn.js │ │ ├── ForOnBody.js │ │ ├── Method.js │ │ ├── Property.js │ │ ├── ReturnAsyncGenerator.js │ │ ├── ThisAndArguments.js │ │ ├── ThrowInAsyncGenerator.js │ │ ├── YieldFor.js │ │ ├── YieldForOn.script.js │ │ └── resources │ │ │ └── observable.js │ ├── AtScript │ │ └── AtScript.js │ ├── Classes │ │ ├── ClassMethodInheritance.js │ │ ├── ClassNameBinding.js │ │ ├── ClassNameInStack.js │ │ ├── Constructor.js │ │ ├── ConstructorChaining.js │ │ ├── ConstructorMember.js │ │ ├── DefaultConstructor.js │ │ ├── DeriveFromObject.js │ │ ├── EmptyClass.js │ │ ├── Error_Disabled.js │ │ ├── Error_GH1556.js │ │ ├── Error_NestedFunctionSuper.js │ │ ├── Error_NewSuper.js │ │ ├── Error_NewSuper2.js │ │ ├── Error_NoSuperInDerivedClass.js │ │ ├── Error_Super.js │ │ ├── Error_SuperAsTemplateTag.js │ │ ├── Error_SuperCallInNonDerived.js │ │ ├── Error_SuperNestedClass.js │ │ ├── Error_SuperPropertyOutsideMethod.js │ │ ├── ExtendCoverFormals.js │ │ ├── ExtendNonConstructableFunction.js │ │ ├── ExtendObject.js │ │ ├── ExtendStrange.js │ │ ├── FieldInheritance.js │ │ ├── FieldInitializers.js │ │ ├── FieldLookup.js │ │ ├── Fields.js │ │ ├── Getters.js │ │ ├── Inheritance.js │ │ ├── InheritanceFromMemberExpression.js │ │ ├── InheritanceFromNonclass.js │ │ ├── InheritanceNameBinding.js │ │ ├── Method.js │ │ ├── MethodInheritance.js │ │ ├── MethodLookup.js │ │ ├── NameBinding.js │ │ ├── NestedClassSuper.js │ │ ├── NestedClassSuperAnimal.js │ │ ├── NewClassExpression.js │ │ ├── NonEnum.js │ │ ├── OptionalParams.js │ │ ├── PropertyAccessors.js │ │ ├── PrototypeDescriptor.js │ │ ├── RestParams.js │ │ ├── SemiColon.js │ │ ├── SimpleSuper.js │ │ ├── Skip_DerivedButton.js │ │ ├── Skip_HTMLBlockquoteElement.js │ │ ├── Static.js │ │ ├── StaticSuper.js │ │ ├── StaticSuperNoExtends.js │ │ ├── StaticSymbol.js │ │ ├── Strict.js │ │ ├── SuperChaining.js │ │ ├── SuperChangeProto.js │ │ ├── SuperInArrow.js │ │ ├── SuperMissing.js │ │ ├── SuperNestedClass.js │ │ ├── SuperPostfix.js │ │ ├── SuperSet.js │ │ ├── SuperUnary.js │ │ ├── SuperWithoutExtends.js │ │ └── Types.js │ ├── Collections │ │ ├── Map.js │ │ ├── Set.js │ │ └── SetWithSymbols.js │ ├── ComputedPropertyNames │ │ ├── Class.js │ │ ├── ComputedPropertyNames.js │ │ ├── Error_Disabled.js │ │ └── Symbol.js │ ├── DefaultParameters │ │ ├── Error_SetAccessor.js │ │ ├── Simple.js │ │ └── Strict.js │ ├── Destructuring │ │ ├── Arguments.js │ │ ├── Array.js │ │ ├── ArrayPatternTrailingComma.js │ │ ├── ArrayPatternWithCoverInitializedName.js │ │ ├── ArrayPatternWithInitializer.js │ │ ├── ArrowFunction.js │ │ ├── Catch.js │ │ ├── Class.js │ │ ├── CoverInitializedName.js │ │ ├── CoverInitializer.js │ │ ├── CoverInitializerInForOf.script.js │ │ ├── DefaultParams.js │ │ ├── Empty.js │ │ ├── Error_Disabled.js │ │ ├── Error_ForInWithInitializer.js │ │ ├── Error_ForOfWithInitializer.js │ │ ├── Error_InvalidArrowRest.js │ │ ├── Error_InvalidCoverInitializedName.js │ │ ├── EvaluatesToRvalue.js │ │ ├── EvaluationOrder.js │ │ ├── ForInLoop.js │ │ ├── ForOfLoop.js │ │ ├── FunctionArrayPattern.js │ │ ├── FunctionObjectPattern.js │ │ ├── Initializer.js │ │ ├── InitializerObject.js │ │ ├── Method.js │ │ ├── MultipleCoverInitializersInArrowFunction.js │ │ ├── NestedScopeArguments.js │ │ ├── Object.js │ │ ├── Rest.js │ │ ├── RestIterator.js │ │ ├── ScopeThis.js │ │ ├── SetAccessor.js │ │ ├── Simplify.js │ │ ├── StrangeProperties.js │ │ ├── Strict.js │ │ ├── TopLevel.js │ │ ├── ValueTypes.js │ │ └── VarDecl.js │ ├── Exponentiation │ │ └── Basics.js │ ├── ForOf │ │ └── NewNoParens.js │ ├── FreeVariableChecker │ │ ├── Error_With.script.js │ │ ├── Typeof.js │ │ ├── WithBasic.script.js │ │ └── WithVarDecl.script.js │ ├── GeneratorComprehension │ │ ├── Error_Disabled.js │ │ ├── Error_NotDefined.js │ │ ├── Simple.js │ │ └── Skip_Closure.js │ ├── JSX │ │ ├── Attributes.js │ │ ├── AttributesWhitespace.js │ │ ├── Children.js │ │ ├── ChildrenWhitespace.js │ │ ├── Error_TagNameMismatch.js │ │ ├── OptionCustom.js │ │ ├── OptionDefault.js │ │ ├── SpreadAttributes.js │ │ ├── TagName.js │ │ └── ThisInPlaceHolder.js │ ├── Math │ │ ├── acosh.js │ │ ├── asinh.js │ │ ├── atanh.js │ │ ├── cbrt.js │ │ ├── clz32.js │ │ ├── cosh.js │ │ ├── expm1.js │ │ ├── fround.js │ │ ├── hypot.js │ │ ├── imul.js │ │ ├── log10.js │ │ ├── log1p.js │ │ ├── log2.js │ │ ├── sign.js │ │ ├── sinh.js │ │ ├── tanh.js │ │ └── trunc.js │ ├── MemberVariables │ │ ├── Error_ChildNoCtor.js │ │ ├── Error_ChildSuperNotFirst.js │ │ ├── Error_Disabled.js │ │ ├── Initializers.js │ │ ├── InitializersAndInheritance.js │ │ └── InitializersEvaluation.js │ ├── Modules │ │ ├── DefaultLiveBinding.js │ │ ├── EmptyNamedImport.js │ │ ├── Error_DuplicateImport.js │ │ ├── Error_ExportIdentifier.js │ │ ├── Error_ExportKeyword.js │ │ ├── Error_ExportKeyword2.js │ │ ├── Error_ExportStarConflict.js │ │ ├── Error_ExportStarDuplicateExport.js │ │ ├── Error_ImportDefault.js │ │ ├── Error_ImportStar.js │ │ ├── Error_ImportType.js │ │ ├── Error_ImportTypeNoDefault.js │ │ ├── Error_InvalidExport.js │ │ ├── Error_InvalidExport2.js │ │ ├── Error_InvalidExport3.js │ │ ├── Error_InvalidModuleDeclaration.js │ │ ├── Error_InvalidModuleDeclaration2.js │ │ ├── Error_MissingExport.js │ │ ├── ExportDestructuring.js │ │ ├── ExportForwardDefault.js │ │ ├── ExportStar.js │ │ ├── ExportStarAs.js │ │ ├── Exports.js │ │ ├── ImportAsExportAs.js │ │ ├── ImportBasic.js │ │ ├── ImportCircular.js │ │ ├── ImportDefault.js │ │ ├── ImportEmptyImportClause.js │ │ ├── ImportFromModule.js │ │ ├── ImportNoImportClause.js │ │ ├── ImportPair.js │ │ ├── ImportReExportDefault.js │ │ ├── ImportReExportDefaultAs.js │ │ ├── ImportType.js │ │ ├── ModuleDefault.js │ │ ├── ModuleName.js │ │ ├── ModuleObjectFromDestructuring.js │ │ ├── StaticMethod.js │ │ ├── ThisInModules.js │ │ └── resources │ │ │ ├── TestClass.js │ │ │ ├── a.js │ │ │ ├── a2.js │ │ │ ├── b.js │ │ │ ├── c.js │ │ │ ├── clockwise.js │ │ │ ├── d.js │ │ │ ├── default-and-named-type.js │ │ │ ├── default-and-named.js │ │ │ ├── default-class-expression.js │ │ │ ├── default-class.js │ │ │ ├── default-function-expression.js │ │ │ ├── default-function.js │ │ │ ├── default-live.js │ │ │ ├── default-name.js │ │ │ ├── default.js │ │ │ ├── export-conflict.js │ │ │ ├── export-destructuring.js │ │ │ ├── export-extended-keyword.js │ │ │ ├── export-forward-default-as.js │ │ │ ├── export-star-as.js │ │ │ ├── f.js │ │ │ ├── i.js │ │ │ ├── m.js │ │ │ ├── m2.js │ │ │ ├── m3.js │ │ │ ├── n.js │ │ │ ├── named-type.js │ │ │ ├── o.js │ │ │ ├── object-for-side-effects.js │ │ │ ├── p.js │ │ │ ├── re-export-default-as.js │ │ │ ├── re-export-default.js │ │ │ ├── side-effect.js │ │ │ ├── side-effect2.js │ │ │ └── x.js │ ├── Number │ │ ├── EPSILON.js │ │ ├── MAX_SAFE_INTEGER.js │ │ ├── MIN_SAFE_INTEGER.js │ │ ├── isFinite.js │ │ ├── isInteger.js │ │ ├── isNaN.js │ │ └── isSafeInteger.js │ ├── NumericLiteral │ │ ├── Error_Disabled.js │ │ ├── Error_NoBinaryDigits.js │ │ ├── Error_NoOctalDigits.js │ │ └── Simple.js │ ├── ObjectAssign.js │ ├── ObjectInitializerShorthand │ │ ├── Error_Disabled.js │ │ ├── Error_Keyword.js │ │ ├── Error_MissingVar.js │ │ ├── Error_StrictKeyword.js │ │ ├── Ok.js │ │ └── StrictKeyword.script.js │ ├── ObjectIs.js │ ├── ObjectMixin.js │ ├── PrependStatement.js │ ├── Promise.js │ ├── PromiseAll.js │ ├── PromiseResolve.js │ ├── PromiseThrowInResolve.js │ ├── ProperTailCalls │ │ ├── Call.js │ │ ├── Coroutine.js │ │ ├── Method.js │ │ ├── Native.js │ │ ├── New.js │ │ ├── Sum.js │ │ └── This.js │ ├── PropertyMethodAssignment │ │ ├── Error_Disabled.js │ │ ├── Error_NotNamed.js │ │ └── PropertyMethodAssignment.js │ ├── PureES6Transformer │ │ └── Basic.js │ ├── README │ ├── RegularExpression │ │ └── Simple.js │ ├── Rest │ │ ├── Error_NotLast.js │ │ ├── Error_SetAccessor.js │ │ ├── Simple.js │ │ └── Strict.js │ ├── Scope │ │ ├── BlockBinding10.js │ │ ├── BlockBinding11.js │ │ ├── BlockBinding2.js │ │ ├── BlockBinding3.js │ │ ├── BlockBinding4.js │ │ ├── BlockBinding5.js │ │ ├── BlockBinding6.js │ │ ├── BlockBinding7.js │ │ ├── BlockBinding8.js │ │ ├── BlockBinding9.js │ │ ├── BlockBindingHiddenOuterLet.js │ │ ├── BlockBindingSiblingRefenceError.js │ │ ├── DeconstructingBlockBinding.js │ │ ├── DeepNestedLet.js │ │ ├── DeepNestedLetConst.js │ │ ├── DeepNestedLetVar.js │ │ ├── DeepNestedLetVarNoInit.js │ │ ├── Error_ConstMissingInitializer.js │ │ ├── Error_Disabled.js │ │ ├── Error_Duplicate.js │ │ ├── Error_ForInWithInitializerConst.js │ │ ├── Error_ForInWithInitializerLet.js │ │ ├── Error_ForInWithInitializerVar.js │ │ ├── Error_ForOfWithInitializerConst.js │ │ ├── Error_ForOfWithInitializerLet.js │ │ ├── Error_ForOfWithInitializerVar.js │ │ ├── Error_ForWithoutInitializerConst.js │ │ ├── Error_FunctionExpressionInBlock.js │ │ ├── Error_FunctionExpressionNameShadowing.js │ │ ├── ForInInitializers.js │ │ ├── FunctionExpressionNameShadowing.js │ │ ├── FunctionInBlock.js │ │ ├── LetForInInitializers1.js │ │ ├── LetForInitializers1.js │ │ ├── LetInClass.js │ │ ├── LetInClosure.js │ │ ├── LetInFor.js │ │ ├── LetInForBreak.js │ │ ├── LetInForBreakInner.js │ │ ├── LetInForBreakNamed.js │ │ ├── LetInForContinue.js │ │ ├── LetInForContinueInner.js │ │ ├── LetInForContinueNamed.js │ │ ├── LetInGenerators.js │ │ ├── LetInProperties.js │ │ ├── LetInWhileLoop.js │ │ ├── LetInitializerFor1.js │ │ ├── LetInitializerFor2.js │ │ ├── LetInitializerFor3.js │ │ ├── LetInitializerForIn.js │ │ ├── LetNoInitializer.js │ │ ├── LetNoInitializerGlobal.js │ │ ├── LetReinitializeInLoop.js │ │ ├── LetWithFor.js │ │ ├── LetWithForIn.js │ │ ├── LetWithSwitch.js │ │ ├── LetWithSwitch2.js │ │ ├── NameBindingInFunction.js │ │ ├── NestedForLoops.js │ │ ├── NestedFunction1.js │ │ ├── NestedFunction2.js │ │ ├── NestedFunction3.js │ │ ├── NestedLet.js │ │ ├── NestedLetConflict.js │ │ ├── Regress1381.js │ │ ├── RenameFunctionBlock.js │ │ ├── SiblingScopes.js │ │ ├── TopLevelLet.js │ │ ├── TopLevelLetConst.js │ │ └── TopLevelLetVar.js │ ├── Spread │ │ ├── Array.js │ │ ├── Call.js │ │ ├── CallWithUndefined.js │ │ ├── Class.js │ │ ├── Error_Disabled.js │ │ ├── Iterators.js │ │ ├── MethodCall.js │ │ ├── MethodCallQuotedName.js │ │ ├── New.js │ │ ├── New2.js │ │ ├── NewBuiltin.js │ │ ├── NoIterator.js │ │ ├── NotAnObject.js │ │ ├── String.js │ │ └── Type.js │ ├── SpreadProperties │ │ ├── Getters.js │ │ ├── Setters.js │ │ ├── Simple.js │ │ ├── Super.js │ │ └── Symbols.js │ ├── StringExtras │ │ ├── CodePointAt.js │ │ ├── EndsWith.js │ │ ├── FromCodePoint.js │ │ ├── Includes.js │ │ ├── Repeat.js │ │ └── StartsWith.js │ ├── StringIterator.js │ ├── SuperObjectLiteral │ │ ├── Error_Super.js │ │ ├── SuperChaining.js │ │ ├── SuperChangeProto.js │ │ ├── SuperInArrow.js │ │ ├── SuperNestedObject.js │ │ ├── SuperPostfix.js │ │ ├── SuperSet.js │ │ ├── SuperUnary.js │ │ └── SuperWithoutProto.js │ ├── Symbol │ │ ├── GetOwnPropertySymbols.js │ │ ├── Inherited.js │ │ ├── Object.js │ │ ├── ObjectModel.script.js │ │ └── TransformationOff.js │ ├── Syntax │ │ ├── ArrayWithHoles.js │ │ ├── CaseClauseShouldBeStatementListItem.script.js │ │ ├── Empty.js │ │ ├── Error_Arguments.js │ │ ├── Error_DeclarationInDoWhileClass.js │ │ ├── Error_DeclarationInDoWhileConst.js │ │ ├── Error_DeclarationInDoWhileFunction.js │ │ ├── Error_DeclarationInDoWhileLet.js │ │ ├── Error_DeclarationInDoWhileLetOpenSquare.js │ │ ├── Error_DeclarationInElse.js │ │ ├── Error_DeclarationInFor.js │ │ ├── Error_DeclarationInForIn.js │ │ ├── Error_DeclarationInForOf.js │ │ ├── Error_DeclarationInIf.js │ │ ├── Error_DeclarationInWhile.js │ │ ├── Error_ForInLoopTooManyVariableDeclarations.js │ │ ├── Error_ForOfLoopTooManyVariableDeclarations.js │ │ ├── Error_FunctionParam.js │ │ ├── Error_IllegalReturn.js │ │ ├── Error_IllegalReturn.script.js │ │ ├── Error_IsValidSimpleAssignmentTarget.js │ │ ├── Error_MultipleDefault.js │ │ ├── Error_NoLineTerminatorPostfix.js │ │ ├── Error_ParamDuplicateCheck.js │ │ ├── Error_ParamDuplicateCheckNonSimple.js │ │ ├── Error_RegExpNotClosed.js │ │ ├── Error_StrictKeywordsInArguments.script.js │ │ ├── Error_StrictKeywordsInArgumentsPattern.js │ │ ├── Error_StrictKeywordsInPropertyDefinitionIdentifierReference.js │ │ ├── Error_StrictKeywordsInStrict.js │ │ ├── Error_UnicodeEscapeSequenceInName.js │ │ ├── Error_WithInClass.js │ │ ├── Error_WithInModule.js │ │ ├── Error_WithInStrictFunction.js │ │ ├── Error_WithInStrictProgram.js │ │ ├── Error_YieldStarNewLine.js │ │ ├── ExpressionValidation.js │ │ ├── ImplicitSemiColon.js │ │ ├── ImportFromTypo.js │ │ ├── InInBinding.js │ │ ├── IsValidSimpleAssignmentTarget.script.js │ │ ├── MultlineCommentIsNewLine.js │ │ ├── NoNewLineHereEndOfFile.script.js │ │ ├── NumberLiteralMemberExpression.js │ │ ├── ParamDuplicateCheckNonSimpleOk.js │ │ ├── ParamDuplicateCheckOk.js │ │ ├── RegularExpression.js │ │ ├── StrictKeywords.script.js │ │ ├── StrictKeywordsInPattern.script.js │ │ ├── StringEscapes.js │ │ ├── UnicodeEscapeSequenceInName.js │ │ ├── UseStrictEscapeSequence.script.js │ │ ├── UseStrictLineContinuation.script.js │ │ └── null.js │ ├── TempVarTransformer │ │ └── UseStrictDirective.script.js │ ├── TemplateLiterals │ │ ├── CallExpression.js │ │ ├── CommaExpression.js │ │ ├── Default.js │ │ ├── Error_Disabled.js │ │ ├── Error_InvalidSubstitution.js │ │ ├── Error_InvalidSubstitution2.js │ │ ├── Error_NotClosed.js │ │ ├── InBlock.js │ │ ├── InModule.js │ │ ├── MemberExpression.js │ │ ├── NewExpression.script.js │ │ ├── Strict.js │ │ ├── StringRaw.js │ │ ├── Tag.js │ │ ├── TemplateObjectCaching.js │ │ └── resources │ │ │ ├── f.js │ │ │ ├── m.js │ │ │ ├── n.js │ │ │ └── template-objects.js │ ├── TestRunner │ │ ├── RelativeUnixPath.js │ │ ├── RelativeWindowsPath.js │ │ ├── UnixPath.js │ │ └── WindowsPath.js │ ├── Tools │ │ └── FreeVariableChecker.js │ ├── Types │ │ ├── Error_FunctionType.js │ │ ├── Error_TypeAlias.js │ │ ├── Error_TypeArguments.js │ │ ├── Error_TypeArguments2.js │ │ ├── Error_TypeArguments3.js │ │ ├── Interface.js │ │ ├── TypeAlias.js │ │ ├── TypeAlias.script.js │ │ ├── TypeAnnotations.js │ │ └── TypeSyntax.js │ ├── UnicodeEscapeSequence │ │ ├── Error_CodePointTooHigh.js │ │ ├── Error_Disabled.js │ │ ├── Error_HexDigitExpected.js │ │ ├── Error_HexDigitExpected2.js │ │ ├── Error_HexDigitExpected3.js │ │ ├── Error_HexDigitExpected4.js │ │ └── Simple.js │ ├── WeakMap.js │ ├── WeakSet.js │ └── Yield │ │ ├── Arguments.js │ │ ├── BadIterable.js │ │ ├── BinaryOperator.js │ │ ├── Break.js │ │ ├── BreakForOf.js │ │ ├── CommaOperator.js │ │ ├── Continue.js │ │ ├── DefaultArguments.js │ │ ├── DoGenerator.js │ │ ├── DoWhileStatementWithYield.js │ │ ├── EmptyGenerator.js │ │ ├── Error_Disabled.js │ │ ├── Error_Disabled2.js │ │ ├── Error_MissingStar.script.js │ │ ├── Finally.js │ │ ├── ForEmptyGenerator.js │ │ ├── ForGenerator.js │ │ ├── ForInGenerator.js │ │ ├── ForInGenerator2.js │ │ ├── ForInGenerator3.js │ │ ├── ForLexicallyNestedGenerator.js │ │ ├── ForMissingParts.js │ │ ├── ForOfGenerator.js │ │ ├── ForOfIteratorException.js │ │ ├── ForStatement.js │ │ ├── FunctionDeclaration.js │ │ ├── GeneratorReturn.js │ │ ├── GeneratorSend.js │ │ ├── GeneratorThrow.js │ │ ├── GeneratorWithoutYieldOrReturn.js │ │ ├── Hoisting.js │ │ ├── HoistingBlockbinding.js │ │ ├── IfGenerator.js │ │ ├── IfStatementWithYield.js │ │ ├── LabelledBlockGenerator.js │ │ ├── LabelledBreakGenerator.js │ │ ├── MapFilterGenerator.js │ │ ├── ObjectModel.js │ │ ├── OverrideGenerator.js │ │ ├── ReturnCatch.js │ │ ├── ReturnGenerator.js │ │ ├── ReturnInFinally.js │ │ ├── ReturnYield.js │ │ ├── ReturnYieldFor.js │ │ ├── SequenceGenerator.js │ │ ├── SimpleGenerator.js │ │ ├── StatementTestGenerator.js │ │ ├── SwitchGenerator.js │ │ ├── SwitchStatementWithYield.js │ │ ├── This.js │ │ ├── ThrowInCatch.js │ │ ├── ThrowInIterator.js │ │ ├── Tree.js │ │ ├── Try.js │ │ ├── Try10.js │ │ ├── Try11.js │ │ ├── Try12.js │ │ ├── Try2.js │ │ ├── Try3.js │ │ ├── Try4.js │ │ ├── Try5.js │ │ ├── Try6.js │ │ ├── Try7.js │ │ ├── Try8.js │ │ ├── Try9.js │ │ ├── TryCatchGenerator.js │ │ ├── TryCatchYieldGenerator.js │ │ ├── TryFinallyGenerator.js │ │ ├── WhileGenerator.js │ │ ├── WhileStatementWithYield.js │ │ ├── YieldAssignThrow.js │ │ ├── YieldIdentifier.script.js │ │ ├── YieldInFinally.js │ │ ├── YieldNoExpression.js │ │ ├── YieldUndefinedGenerator.js │ │ ├── YieldYield.js │ │ └── tryFinallyFinallyGenerator.js ├── featureTestRunner.js ├── instantiate │ ├── b.js │ ├── circular1.js │ ├── circular2.js │ ├── circular_annotation1.js │ ├── circular_annotation2.js │ ├── export-default-class.js │ ├── export-default-fn.js │ ├── export-default.js │ ├── export-destructuring.js │ ├── export-forward-default.js │ ├── export-reassignment.js │ ├── export-star-as.js │ ├── export-star.js │ ├── export.js │ ├── generator.js │ ├── hoisting.js │ ├── inheritance.js │ ├── module-import.js │ ├── module-name.js │ ├── postfix-operator.js │ ├── rebinding.js │ ├── reexport-binding.js │ ├── reexport1.js │ └── shorthand.js ├── manual │ ├── WebPageTranscoderOptions.html │ └── browser_error.html ├── modular │ ├── BrowserTraceurTestRunner.js │ ├── Mocha6.js │ ├── MochaDependencies.js │ ├── NodeTraceurTestRunner.js │ ├── README.md │ └── TraceurTestRunner.js ├── node-amd-test.js ├── node-api-test.js ├── node-closure-test.js ├── node-commonjs-test.js ├── node-instantiate-test.js ├── node-promise-adapter.js ├── register-cjs-test-wrapper.js ├── runFeatureTests.js ├── runUnitTests.js ├── runtime.html ├── self-compile.html ├── unit │ ├── CompileOptions.js │ ├── Compiler.js │ ├── codegeneration │ │ ├── AmdTransformer.js │ │ ├── BlockBindingTransformer.js │ │ ├── ClassTransformer.js │ │ ├── DestructuringTransformer.js │ │ ├── ExplodeExpressionTransformer.js │ │ ├── HoistVariablesTransformer.js │ │ ├── ImportSimplifyingTransformer.js │ │ ├── InlineES6ModuleTransformer.js │ │ ├── InlineModuleTransformer.js │ │ ├── MemberVariableTransformer.js │ │ ├── ModuleTransformer.js │ │ ├── PlaceholderParser.js │ │ ├── PureES6Transformer.js │ │ ├── SourceMap.js │ │ ├── TempVarTransformerUseLet.js │ │ ├── TemplateLiteralTransformer.js │ │ ├── low_level_tests.js │ │ └── writer.js │ ├── node │ │ ├── api.js │ │ ├── generated-code-dependencies.js │ │ ├── require.js │ │ ├── resources │ │ │ ├── aDeeperModule.js │ │ │ ├── aNodeModule.js │ │ │ ├── async-function.js │ │ │ ├── checkRequire.js │ │ │ ├── class.js │ │ │ ├── compile-dir │ │ │ │ ├── dep.js │ │ │ │ └── file.js │ │ │ ├── export-default-class.js │ │ │ ├── export-default-function.js │ │ │ ├── export-default.js │ │ │ ├── generator.js │ │ │ ├── glob-normal.js │ │ │ ├── glob-pattern-a.js │ │ │ ├── glob-pattern-b.js │ │ │ ├── golden-amd │ │ │ │ ├── dep.js │ │ │ │ └── file.js │ │ │ ├── golden-cjs │ │ │ │ ├── dep.js │ │ │ │ └── file.js │ │ │ ├── iAmScript.js │ │ │ ├── iAmScriptAlso.es │ │ │ ├── import-another-x.js │ │ │ ├── import-export.js │ │ │ ├── import-x.js │ │ │ ├── let-x.js │ │ │ ├── module-global.js │ │ │ ├── only-export.js │ │ │ ├── reexport-x.js │ │ │ ├── register-module-bindings.js │ │ │ ├── scriptUsesModuleGlobal.js │ │ │ ├── subdir │ │ │ │ └── requireAndImport.js │ │ │ ├── syntax-error.js │ │ │ ├── testErrorForSourceMaps.js │ │ │ ├── testForRequireAndImport.js │ │ │ ├── test_tval.js │ │ │ └── x.js │ │ ├── traceur-interpreter.js │ │ └── tree-writer.js │ ├── runtime │ │ ├── Loader.js │ │ ├── LoaderIntegration.js │ │ ├── Object.js │ │ ├── System.js │ │ ├── loads │ │ │ ├── deperror.js │ │ │ └── main.js │ │ ├── resources │ │ │ ├── CallsThrowsError.js │ │ │ ├── ModuleEvaluationErrorStack.txt │ │ │ ├── call_loader.js │ │ │ ├── side-effect.js │ │ │ ├── test_a.js │ │ │ ├── test_b.js │ │ │ ├── test_c.js │ │ │ ├── test_module.js │ │ │ ├── test_script.js │ │ │ ├── test_source_map_module.js │ │ │ ├── throwsError.js │ │ │ ├── throwsError.output │ │ │ ├── throwsErrorES6.js │ │ │ └── traceur-runtime.js │ │ └── subdir │ │ │ ├── test_d.js │ │ │ └── test_e.js │ ├── semantics │ │ ├── ConstChecker.js │ │ ├── FreeVariableChecker.js │ │ ├── VariableBinder.js │ │ └── bindingsInDestructuringPattern.js │ ├── syntax │ │ ├── LineNumbers.js │ │ ├── LiteralToken.js │ │ ├── ParseTreeValidator.js │ │ ├── Token.js │ │ └── parser.js │ ├── system │ │ ├── Hello.js │ │ ├── ScriptTypeTextTraceur.html │ │ └── ScriptTypeTextTraceur.js │ ├── tools │ │ ├── HTMLImportTranscoder │ │ │ ├── HTMLImportScriptTraceur.js │ │ │ ├── basic │ │ │ │ ├── a.html │ │ │ │ ├── b.html │ │ │ │ └── index.html │ │ │ └── import-order │ │ │ │ ├── a.html │ │ │ │ ├── b.html │ │ │ │ ├── c.html │ │ │ │ ├── d.html │ │ │ │ ├── e.html │ │ │ │ ├── f.html │ │ │ │ ├── g.html │ │ │ │ ├── h.html │ │ │ │ └── index.html │ │ ├── SourceMapMapping.js │ │ └── get-dependencies.js │ ├── unitTestRunner.js │ └── util │ │ ├── ErrorReporter.js │ │ └── url.js ├── verify-compat.js └── wiki │ ├── .gitignore │ └── CompilingOffline │ ├── UsingCompiledFiles.html │ ├── deepDirectory │ └── src │ │ └── js │ │ ├── app.js │ │ └── greeter.js │ └── greeter.js ├── testRunner.html ├── third_party ├── CodeMirror-4.0.3 │ ├── .gitattributes │ ├── .gitignore │ ├── .travis.yml │ ├── AUTHORS │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── README.md │ ├── addon │ │ ├── comment │ │ │ ├── comment.js │ │ │ └── continuecomment.js │ │ ├── dialog │ │ │ ├── dialog.css │ │ │ └── dialog.js │ │ ├── display │ │ │ ├── fullscreen.css │ │ │ ├── fullscreen.js │ │ │ ├── placeholder.js │ │ │ └── rulers.js │ │ ├── edit │ │ │ ├── closebrackets.js │ │ │ ├── closetag.js │ │ │ ├── continuelist.js │ │ │ ├── matchbrackets.js │ │ │ ├── matchtags.js │ │ │ └── trailingspace.js │ │ ├── fold │ │ │ ├── brace-fold.js │ │ │ ├── comment-fold.js │ │ │ ├── foldcode.js │ │ │ ├── foldgutter.css │ │ │ ├── foldgutter.js │ │ │ ├── indent-fold.js │ │ │ ├── markdown-fold.js │ │ │ └── xml-fold.js │ │ ├── hint │ │ │ ├── anyword-hint.js │ │ │ ├── css-hint.js │ │ │ ├── html-hint.js │ │ │ ├── javascript-hint.js │ │ │ ├── python-hint.js │ │ │ ├── show-hint.css │ │ │ ├── show-hint.js │ │ │ ├── sql-hint.js │ │ │ └── xml-hint.js │ │ ├── lint │ │ │ ├── coffeescript-lint.js │ │ │ ├── css-lint.js │ │ │ ├── javascript-lint.js │ │ │ ├── json-lint.js │ │ │ ├── lint.css │ │ │ ├── lint.js │ │ │ └── yaml-lint.js │ │ ├── merge │ │ │ ├── dep │ │ │ │ └── diff_match_patch.js │ │ │ ├── merge.css │ │ │ └── merge.js │ │ ├── mode │ │ │ ├── loadmode.js │ │ │ ├── multiplex.js │ │ │ ├── multiplex_test.js │ │ │ └── overlay.js │ │ ├── runmode │ │ │ ├── colorize.js │ │ │ ├── runmode-standalone.js │ │ │ ├── runmode.js │ │ │ └── runmode.node.js │ │ ├── scroll │ │ │ └── scrollpastend.js │ │ ├── search │ │ │ ├── match-highlighter.js │ │ │ ├── search.js │ │ │ └── searchcursor.js │ │ ├── selection │ │ │ ├── active-line.js │ │ │ └── mark-selection.js │ │ ├── tern │ │ │ ├── tern.css │ │ │ ├── tern.js │ │ │ └── worker.js │ │ └── wrap │ │ │ └── hardwrap.js │ ├── bin │ │ ├── authors.sh │ │ ├── compress │ │ ├── lint │ │ ├── release │ │ └── source-highlight │ ├── bower.json │ ├── demo │ │ ├── activeline.html │ │ ├── anywordhint.html │ │ ├── bidi.html │ │ ├── btree.html │ │ ├── buffers.html │ │ ├── changemode.html │ │ ├── closebrackets.html │ │ ├── closetag.html │ │ ├── complete.html │ │ ├── emacs.html │ │ ├── folding.html │ │ ├── fullscreen.html │ │ ├── hardwrap.html │ │ ├── html5complete.html │ │ ├── indentwrap.html │ │ ├── lint.html │ │ ├── loadmode.html │ │ ├── marker.html │ │ ├── markselection.html │ │ ├── matchhighlighter.html │ │ ├── matchtags.html │ │ ├── merge.html │ │ ├── multiplex.html │ │ ├── mustache.html │ │ ├── placeholder.html │ │ ├── preview.html │ │ ├── resize.html │ │ ├── rulers.html │ │ ├── runmode.html │ │ ├── search.html │ │ ├── spanaffectswrapping_shim.html │ │ ├── sublime.html │ │ ├── tern.html │ │ ├── theme.html │ │ ├── trailingspace.html │ │ ├── variableheight.html │ │ ├── vim.html │ │ ├── visibletabs.html │ │ ├── widget.html │ │ └── xmlcomplete.html │ ├── doc │ │ ├── activebookmark.js │ │ ├── compress.html │ │ ├── docs.css │ │ ├── internals.html │ │ ├── logo.png │ │ ├── logo.svg │ │ ├── manual.html │ │ ├── realworld.html │ │ ├── releases.html │ │ ├── reporting.html │ │ ├── upgrade_v2.2.html │ │ ├── upgrade_v3.html │ │ └── upgrade_v4.html │ ├── index.html │ ├── keymap │ │ ├── emacs.js │ │ ├── sublime.js │ │ └── vim.js │ ├── lib │ │ ├── codemirror.css │ │ └── codemirror.js │ ├── mode │ │ ├── apl │ │ │ ├── apl.js │ │ │ └── index.html │ │ ├── asterisk │ │ │ ├── asterisk.js │ │ │ └── index.html │ │ ├── clike │ │ │ ├── clike.js │ │ │ ├── index.html │ │ │ └── scala.html │ │ ├── clojure │ │ │ ├── clojure.js │ │ │ └── index.html │ │ ├── cobol │ │ │ ├── cobol.js │ │ │ └── index.html │ │ ├── coffeescript │ │ │ ├── coffeescript.js │ │ │ └── index.html │ │ ├── commonlisp │ │ │ ├── commonlisp.js │ │ │ └── index.html │ │ ├── css │ │ │ ├── css.js │ │ │ ├── index.html │ │ │ ├── less.html │ │ │ ├── less_test.js │ │ │ ├── scss.html │ │ │ ├── scss_test.js │ │ │ └── test.js │ │ ├── d │ │ │ ├── d.js │ │ │ └── index.html │ │ ├── diff │ │ │ ├── diff.js │ │ │ └── index.html │ │ ├── dtd │ │ │ ├── dtd.js │ │ │ └── index.html │ │ ├── ecl │ │ │ ├── ecl.js │ │ │ └── index.html │ │ ├── eiffel │ │ │ ├── eiffel.js │ │ │ └── index.html │ │ ├── erlang │ │ │ ├── erlang.js │ │ │ └── index.html │ │ ├── fortran │ │ │ ├── fortran.js │ │ │ └── index.html │ │ ├── gas │ │ │ ├── gas.js │ │ │ └── index.html │ │ ├── gfm │ │ │ ├── gfm.js │ │ │ ├── index.html │ │ │ └── test.js │ │ ├── gherkin │ │ │ ├── gherkin.js │ │ │ └── index.html │ │ ├── go │ │ │ ├── go.js │ │ │ └── index.html │ │ ├── groovy │ │ │ ├── groovy.js │ │ │ └── index.html │ │ ├── haml │ │ │ ├── haml.js │ │ │ ├── index.html │ │ │ └── test.js │ │ ├── haskell │ │ │ ├── haskell.js │ │ │ └── index.html │ │ ├── haxe │ │ │ ├── haxe.js │ │ │ └── index.html │ │ ├── htmlembedded │ │ │ ├── htmlembedded.js │ │ │ └── index.html │ │ ├── htmlmixed │ │ │ ├── htmlmixed.js │ │ │ └── index.html │ │ ├── http │ │ │ ├── http.js │ │ │ └── index.html │ │ ├── index.html │ │ ├── jade │ │ │ ├── index.html │ │ │ └── jade.js │ │ ├── javascript │ │ │ ├── index.html │ │ │ ├── javascript.js │ │ │ ├── json-ld.html │ │ │ ├── test.js │ │ │ └── typescript.html │ │ ├── jinja2 │ │ │ ├── index.html │ │ │ └── jinja2.js │ │ ├── julia │ │ │ ├── index.html │ │ │ └── julia.js │ │ ├── livescript │ │ │ ├── index.html │ │ │ ├── livescript.js │ │ │ └── livescript.ls │ │ ├── lua │ │ │ ├── index.html │ │ │ └── lua.js │ │ ├── markdown │ │ │ ├── index.html │ │ │ ├── markdown.js │ │ │ └── test.js │ │ ├── meta.js │ │ ├── mirc │ │ │ ├── index.html │ │ │ └── mirc.js │ │ ├── mllike │ │ │ ├── index.html │ │ │ └── mllike.js │ │ ├── nginx │ │ │ ├── index.html │ │ │ └── nginx.js │ │ ├── ntriples │ │ │ ├── index.html │ │ │ └── ntriples.js │ │ ├── octave │ │ │ ├── index.html │ │ │ └── octave.js │ │ ├── pascal │ │ │ ├── index.html │ │ │ └── pascal.js │ │ ├── pegjs │ │ │ ├── index.html │ │ │ └── pegjs.js │ │ ├── perl │ │ │ ├── index.html │ │ │ └── perl.js │ │ ├── php │ │ │ ├── index.html │ │ │ └── php.js │ │ ├── pig │ │ │ ├── index.html │ │ │ └── pig.js │ │ ├── properties │ │ │ ├── index.html │ │ │ └── properties.js │ │ ├── puppet │ │ │ ├── index.html │ │ │ └── puppet.js │ │ ├── python │ │ │ ├── index.html │ │ │ └── python.js │ │ ├── q │ │ │ ├── index.html │ │ │ └── q.js │ │ ├── r │ │ │ ├── index.html │ │ │ └── r.js │ │ ├── rpm │ │ │ ├── changes │ │ │ │ └── index.html │ │ │ ├── index.html │ │ │ └── rpm.js │ │ ├── rst │ │ │ ├── index.html │ │ │ └── rst.js │ │ ├── ruby │ │ │ ├── index.html │ │ │ ├── ruby.js │ │ │ └── test.js │ │ ├── rust │ │ │ ├── index.html │ │ │ └── rust.js │ │ ├── sass │ │ │ ├── index.html │ │ │ └── sass.js │ │ ├── scheme │ │ │ ├── index.html │ │ │ └── scheme.js │ │ ├── shell │ │ │ ├── index.html │ │ │ └── shell.js │ │ ├── sieve │ │ │ ├── index.html │ │ │ └── sieve.js │ │ ├── smalltalk │ │ │ ├── index.html │ │ │ └── smalltalk.js │ │ ├── smarty │ │ │ ├── index.html │ │ │ └── smarty.js │ │ ├── smartymixed │ │ │ ├── index.html │ │ │ └── smartymixed.js │ │ ├── solr │ │ │ ├── index.html │ │ │ └── solr.js │ │ ├── sparql │ │ │ ├── index.html │ │ │ └── sparql.js │ │ ├── sql │ │ │ ├── index.html │ │ │ └── sql.js │ │ ├── stex │ │ │ ├── index.html │ │ │ ├── stex.js │ │ │ └── test.js │ │ ├── tcl │ │ │ ├── index.html │ │ │ └── tcl.js │ │ ├── tiddlywiki │ │ │ ├── index.html │ │ │ ├── tiddlywiki.css │ │ │ └── tiddlywiki.js │ │ ├── tiki │ │ │ ├── index.html │ │ │ ├── tiki.css │ │ │ └── tiki.js │ │ ├── toml │ │ │ ├── index.html │ │ │ └── toml.js │ │ ├── turtle │ │ │ ├── index.html │ │ │ └── turtle.js │ │ ├── vb │ │ │ ├── index.html │ │ │ └── vb.js │ │ ├── vbscript │ │ │ ├── index.html │ │ │ └── vbscript.js │ │ ├── velocity │ │ │ ├── index.html │ │ │ └── velocity.js │ │ ├── verilog │ │ │ ├── index.html │ │ │ └── verilog.js │ │ ├── xml │ │ │ ├── index.html │ │ │ └── xml.js │ │ ├── xquery │ │ │ ├── index.html │ │ │ ├── test.js │ │ │ └── xquery.js │ │ ├── yaml │ │ │ ├── index.html │ │ │ └── yaml.js │ │ └── z80 │ │ │ ├── index.html │ │ │ └── z80.js │ ├── package.json │ ├── test │ │ ├── comment_test.js │ │ ├── doc_test.js │ │ ├── driver.js │ │ ├── emacs_test.js │ │ ├── index.html │ │ ├── lint │ │ │ ├── acorn.js │ │ │ ├── lint.js │ │ │ └── walk.js │ │ ├── mode_test.css │ │ ├── mode_test.js │ │ ├── multi_test.js │ │ ├── phantom_driver.js │ │ ├── run.js │ │ ├── search_test.js │ │ ├── sublime_test.js │ │ ├── test.js │ │ └── vim_test.js │ └── theme │ │ ├── 3024-day.css │ │ ├── 3024-night.css │ │ ├── ambiance-mobile.css │ │ ├── ambiance.css │ │ ├── base16-dark.css │ │ ├── base16-light.css │ │ ├── blackboard.css │ │ ├── cobalt.css │ │ ├── eclipse.css │ │ ├── elegant.css │ │ ├── erlang-dark.css │ │ ├── lesser-dark.css │ │ ├── mbo.css │ │ ├── mdn-like.css │ │ ├── midnight.css │ │ ├── monokai.css │ │ ├── neat.css │ │ ├── night.css │ │ ├── paraiso-dark.css │ │ ├── paraiso-light.css │ │ ├── pastel-on-dark.css │ │ ├── rubyblue.css │ │ ├── solarized.css │ │ ├── the-matrix.css │ │ ├── tomorrow-night-eighties.css │ │ ├── twilight.css │ │ ├── vibrant-ink.css │ │ ├── xq-dark.css │ │ └── xq-light.css ├── README └── es6-module-loader │ ├── index.js │ ├── loader.js │ └── system.js ├── tools ├── find-unused-imports.js ├── findUnusedImports.js └── print-dependencies.js ├── traceur ├── traceur-build └── tval /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * eol=lf 2 | * text=auto 3 | *.png -text 4 | *.eps -text 5 | *.ai -text -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "stable" 4 | - "5" 5 | - "4" 6 | - "0.10" 7 | sudo: false 8 | -------------------------------------------------------------------------------- /demo/1947/app.js: -------------------------------------------------------------------------------- 1 | import {square} from './square.js' 2 | document.body.textContent = 'square(2) = ' + square(2); 3 | -------------------------------------------------------------------------------- /demo/1947/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/1947/square.js: -------------------------------------------------------------------------------- 1 | export function square(x) { 2 | return x*x; 3 | } 4 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /logo/tc.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/traceur-compiler/0b6b96fa1ed48d77ca6908bd52ea735a9ad8f32e/logo/tc.ai -------------------------------------------------------------------------------- /logo/tc.eps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/traceur-compiler/0b6b96fa1ed48d77ca6908bd52ea735a9ad8f32e/logo/tc.eps -------------------------------------------------------------------------------- /logo/tc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/traceur-compiler/0b6b96fa1ed48d77ca6908bd52ea735a9ad8f32e/logo/tc.jpg -------------------------------------------------------------------------------- /logo/tc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/traceur-compiler/0b6b96fa1ed48d77ca6908bd52ea735a9ad8f32e/logo/tc.png -------------------------------------------------------------------------------- /test/amd/BasicImport.js: -------------------------------------------------------------------------------- 1 | import {Foo} from './deps/foo.js'; 2 | 3 | assert.equal('Foo from foo.js', Foo); 4 | assert(typeof Bar === 'undefined'); 5 | -------------------------------------------------------------------------------- /test/amd/ImportEmptyImportClause.js: -------------------------------------------------------------------------------- 1 | // AMD executes the dependencies before executing the module. 2 | import {} from './deps/side-effect2.js'; 3 | import object from './deps/object-for-side-effects.js'; 4 | assert.equal(1, object.sideEffect); 5 | object.sideEffect = 0; 6 | -------------------------------------------------------------------------------- /test/amd/ImportNoImportClause.js: -------------------------------------------------------------------------------- 1 | // AMD executes the dependencies before executing the module. 2 | import './deps/side-effect'; 3 | import object from './deps/object-for-side-effects.js'; 4 | assert.equal(1, object.sideEffect); 5 | object.sideEffect = 0; 6 | -------------------------------------------------------------------------------- /test/amd/MultipleImports.js: -------------------------------------------------------------------------------- 1 | import {Foo, Bar, Baz} from './deps/foo.js'; 2 | 3 | assert.equal('Foo from foo.js', Foo); 4 | assert.equal('Bar from foo.js', Bar); 5 | assert.equal('Baz from foo.js', Baz); 6 | -------------------------------------------------------------------------------- /test/amd/NamedExports.js: -------------------------------------------------------------------------------- 1 | export var someExport = 'val'; 2 | -------------------------------------------------------------------------------- /test/amd/NamedImports.js: -------------------------------------------------------------------------------- 1 | import {Foo as f, Bar as b, Baz} from './deps/foo.js'; 2 | 3 | assert.equal('Foo from foo.js', f); 4 | assert.equal('Bar from foo.js', b); 5 | assert.equal('Baz from foo.js', Baz); 6 | -------------------------------------------------------------------------------- /test/amd/NestedImport.js: -------------------------------------------------------------------------------- 1 | import {Bar} from './deps/bar.js'; 2 | 3 | assert.equal('Bar from bar.js', Bar); 4 | -------------------------------------------------------------------------------- /test/amd/deps/bar.js: -------------------------------------------------------------------------------- 1 | import {Foo} from './foo.js'; 2 | 3 | export var Bar = 'Bar from bar.js'; 4 | 5 | assert.equal('Foo from foo.js', Foo); 6 | -------------------------------------------------------------------------------- /test/amd/deps/foo.js: -------------------------------------------------------------------------------- 1 | export var Foo = 'Foo from foo.js'; 2 | export var Bar = 'Bar from foo.js'; 3 | export var Baz = 'Baz from foo.js'; 4 | -------------------------------------------------------------------------------- /test/amd/deps/object-for-side-effects.js: -------------------------------------------------------------------------------- 1 | const object = {}; 2 | export {object as default}; 3 | -------------------------------------------------------------------------------- /test/amd/deps/side-effect.js: -------------------------------------------------------------------------------- 1 | import object from './object-for-side-effects.js'; 2 | object.sideEffect = 1; 3 | -------------------------------------------------------------------------------- /test/amd/deps/side-effect2.js: -------------------------------------------------------------------------------- 1 | import object from './object-for-side-effects.js'; 2 | object.sideEffect = 1; 3 | -------------------------------------------------------------------------------- /test/closure/BasicImport-expected.txt: -------------------------------------------------------------------------------- 1 | goog.module("test/closure/BasicImport.js"); 2 | var Foo = goog.require("./deps/foo").Foo; 3 | console.log(Foo); 4 | //# sourceURL=test/closure/BasicImport.js 5 | -------------------------------------------------------------------------------- /test/closure/BasicImport.js: -------------------------------------------------------------------------------- 1 | import {Foo} from './deps/foo'; 2 | 3 | console.log(Foo); 4 | -------------------------------------------------------------------------------- /test/closure/ImportMulti-expected.txt: -------------------------------------------------------------------------------- 1 | goog.module("test/closure/ImportMulti.js"); 2 | var $__0 = goog.require("./deps/foo"), 3 | Foo = $__0.Foo, 4 | Bar = $__0.Bar; 5 | console.log(Foo); 6 | //# sourceURL=test/closure/ImportMulti.js 7 | -------------------------------------------------------------------------------- /test/closure/ImportMulti.js: -------------------------------------------------------------------------------- 1 | import {Foo, Bar} from './deps/foo'; 2 | 3 | console.log(Foo); 4 | -------------------------------------------------------------------------------- /test/closure/ImportStar-expected.txt: -------------------------------------------------------------------------------- 1 | goog.module("test/closure/ImportStar.js"); 2 | var foo = goog.require("./deps/foo.js"); 3 | console.log(foo.Foo); 4 | //# sourceURL=test/closure/ImportStar.js 5 | -------------------------------------------------------------------------------- /test/closure/ImportStar.js: -------------------------------------------------------------------------------- 1 | import * as foo from './deps/foo.js'; 2 | 3 | console.log(foo.Foo); 4 | -------------------------------------------------------------------------------- /test/closure/deps/export-default-expected.txt: -------------------------------------------------------------------------------- 1 | goog.module("test/closure/deps/export-default.js"); 2 | var $__default = 'default from foo.js'; 3 | exports = {default: $__default}; 4 | //# sourceURL=test/closure/deps/export-default.js 5 | -------------------------------------------------------------------------------- /test/closure/deps/export-default.js: -------------------------------------------------------------------------------- 1 | export default 'default from foo.js'; 2 | -------------------------------------------------------------------------------- /test/closure/deps/export-named-expected.txt: -------------------------------------------------------------------------------- 1 | goog.module("test/closure/deps/export-named.js"); 2 | var $__test_47_closure_47_deps_47_foo_46_js__ = goog.require("./foo.js"); 3 | exports = {Foo: $__test_47_closure_47_deps_47_foo_46_js__.Foo}; 4 | //# sourceURL=test/closure/deps/export-named.js 5 | -------------------------------------------------------------------------------- /test/closure/deps/export-named.js: -------------------------------------------------------------------------------- 1 | export {Foo} from './foo.js'; 2 | -------------------------------------------------------------------------------- /test/closure/deps/foo-expected.txt: -------------------------------------------------------------------------------- 1 | goog.module("test/closure/deps/foo.js"); 2 | var Foo = 'Foo from foo.js'; 3 | exports = {Foo: Foo}; 4 | //# sourceURL=test/closure/deps/foo.js 5 | -------------------------------------------------------------------------------- /test/closure/deps/foo.js: -------------------------------------------------------------------------------- 1 | export var Foo = 'Foo from foo.js'; 2 | -------------------------------------------------------------------------------- /test/commonjs/BasicImport.js: -------------------------------------------------------------------------------- 1 | import {Foo} from './deps/foo.js'; 2 | 3 | assert.equal('Foo from foo.js', Foo); 4 | assert(typeof Bar === 'undefined'); 5 | -------------------------------------------------------------------------------- /test/commonjs/ExportStar.js: -------------------------------------------------------------------------------- 1 | import {Foo} from './deps/export-star.js'; 2 | 3 | assert.equal('Foo from foo.js', Foo); 4 | assert(typeof Bar === 'undefined'); 5 | -------------------------------------------------------------------------------- /test/commonjs/ImportEmptyImportClause.js: -------------------------------------------------------------------------------- 1 | import object from './deps/object-for-side-effects.js'; 2 | object.sideEffect = 1; 3 | import {} from './deps/side-effect2.js'; 4 | assert.equal(2, object.sideEffect); 5 | object.sideEffect = 1; 6 | -------------------------------------------------------------------------------- /test/commonjs/ImportNoImportClause.js: -------------------------------------------------------------------------------- 1 | import object from './deps/object-for-side-effects.js'; 2 | object.sideEffect = 1; 3 | import './deps/side-effect.js'; 4 | assert.equal(2, object.sideEffect); 5 | object.sideEffect = 1; 6 | -------------------------------------------------------------------------------- /test/commonjs/MultipleImports.js: -------------------------------------------------------------------------------- 1 | import {Foo, Bar, Baz} from './deps/foo.js'; 2 | 3 | assert.equal('Foo from foo.js', Foo); 4 | assert.equal('Bar from foo.js', Bar); 5 | assert.equal('Baz from foo.js', Baz); 6 | -------------------------------------------------------------------------------- /test/commonjs/NamedImports.js: -------------------------------------------------------------------------------- 1 | import {Foo as f, Bar as b, Baz} from './deps/foo.js'; 2 | 3 | assert.equal('Foo from foo.js', f); 4 | assert.equal('Bar from foo.js', b); 5 | assert.equal('Baz from foo.js', Baz); 6 | -------------------------------------------------------------------------------- /test/commonjs/NestedImport.js: -------------------------------------------------------------------------------- 1 | import {Bar} from './deps/bar.js'; 2 | 3 | assert.equal('Bar from bar.js', Bar); 4 | -------------------------------------------------------------------------------- /test/commonjs/deps/bar.js: -------------------------------------------------------------------------------- 1 | import {Foo} from './foo.js'; 2 | 3 | export var Bar = 'Bar from bar.js'; 4 | 5 | assert.equal('Foo from foo.js', Foo); 6 | -------------------------------------------------------------------------------- /test/commonjs/deps/export-star.js: -------------------------------------------------------------------------------- 1 | export * from './foo.js'; 2 | -------------------------------------------------------------------------------- /test/commonjs/deps/foo.js: -------------------------------------------------------------------------------- 1 | export var Foo = 'Foo from foo.js'; 2 | export var Bar = 'Bar from foo.js'; 3 | export var Baz = 'Baz from foo.js'; 4 | -------------------------------------------------------------------------------- /test/commonjs/deps/object-for-side-effects.js: -------------------------------------------------------------------------------- 1 | const object = {}; 2 | export {object as default}; 3 | -------------------------------------------------------------------------------- /test/commonjs/deps/side-effect.js: -------------------------------------------------------------------------------- 1 | import object from './object-for-side-effects.js'; 2 | object.sideEffect++; 3 | -------------------------------------------------------------------------------- /test/commonjs/deps/side-effect2.js: -------------------------------------------------------------------------------- 1 | import object from './object-for-side-effects.js'; 2 | object.sideEffect++; 3 | -------------------------------------------------------------------------------- /test/commonjs/node-require.js: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | import path from 'path'; 3 | 4 | var src = fs.readFileSync(path.resolve(__dirname, 'node-require.js'), 'utf8'); 5 | assert.isTrue( 6 | src.indexOf('fs ' + '= $__interopRequire("fs").default') !== -1); 7 | assert.isTrue( 8 | src.indexOf('path ' + '= $__interopRequire("path").default') !== -1); 9 | -------------------------------------------------------------------------------- /test/feature/Annotations/AnnotatedFunctionTypedParam.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations --types 2 | import { 3 | Anno, 4 | X 5 | } from './resources/setup.js'; 6 | 7 | @Anno 8 | function AnnotatedFnMultiParam(x:X, y) {} 9 | 10 | assert.deepEqual([[X], []], AnnotatedFnMultiParam.parameters); 11 | -------------------------------------------------------------------------------- /test/feature/Annotations/AnnotatedTypedParam.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations --types 2 | import { 3 | Anno, 4 | X 5 | } from './resources/setup.js'; 6 | 7 | function AnnotatedTypedParam(@Anno x:X) {} 8 | 9 | assert.deepEqual([[X, new Anno]], AnnotatedTypedParam.parameters); 10 | -------------------------------------------------------------------------------- /test/feature/Annotations/ClassConstructor.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import { 3 | Anno, 4 | Anno2 5 | } from './resources/setup.js'; 6 | 7 | @Anno 8 | class AnnotatedClassCtor { 9 | @Anno2 10 | constructor() {} 11 | } 12 | 13 | assert.deepEqual([new Anno, new Anno2], AnnotatedClassCtor.annotations); 14 | -------------------------------------------------------------------------------- /test/feature/Annotations/ClassGeneratorMethod.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import { 3 | Anno, 4 | Anno2 5 | } from './resources/setup.js'; 6 | 7 | class AnnotatedClass { 8 | @Anno 9 | *generate() {} 10 | 11 | @Anno2 12 | static *staticGenerate() {} 13 | } 14 | 15 | assert.deepEqual([new Anno], 16 | AnnotatedClass.prototype.generate.annotations); 17 | assert.deepEqual([new Anno2], 18 | AnnotatedClass.staticGenerate.annotations); 19 | -------------------------------------------------------------------------------- /test/feature/Annotations/ClassInsideObjectGetter.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import {Anno} from './resources/setup.js'; 3 | 4 | var object = { 5 | get foo() { 6 | class Foo { 7 | @Anno 8 | get b() {} 9 | } 10 | return Foo; 11 | } 12 | }; 13 | 14 | assert.deepEqual([new Anno], 15 | Object.getOwnPropertyDescriptor(object.foo.prototype, 'b').get.annotations); 16 | 17 | -------------------------------------------------------------------------------- /test/feature/Annotations/Constructor.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import {Anno2} from './resources/setup.js'; 3 | 4 | class AnnotatedCtor { 5 | @Anno2 6 | constructor() {} 7 | } 8 | 9 | assert.deepEqual([new Anno2], AnnotatedCtor.annotations); 10 | -------------------------------------------------------------------------------- /test/feature/Annotations/ConstructorParam.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import {Anno} from './resources/setup.js'; 3 | 4 | class CtorParam { 5 | constructor(@Anno x) {} 6 | } 7 | 8 | assert.deepEqual([[new Anno]], CtorParam.parameters); 9 | 10 | -------------------------------------------------------------------------------- /test/feature/Annotations/Error_annotated_var.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | // Error: :5:2: Unsupported annotated expression 3 | import {Anno} from './resources/setup.js'; 4 | 5 | @Anno 6 | var test = 1; 7 | -------------------------------------------------------------------------------- /test/feature/Annotations/FunctionInsideClassGetter.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import {Anno} from './resources/setup.js'; 3 | 4 | @Anno('Test') 5 | class Test { 6 | get annotatedFn() { 7 | @Anno('x') 8 | function x() {} 9 | return x; 10 | } 11 | } 12 | 13 | assert.deepEqual([new Anno('Test')], Test.annotations); 14 | assert.deepEqual([new Anno('x')], new Test().annotatedFn.annotations); 15 | -------------------------------------------------------------------------------- /test/feature/Annotations/FunctionMultipleAnnotatedParameter.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import { 3 | Anno, 4 | Anno2 5 | } from './resources/setup.js'; 6 | 7 | function MultipleAnnotations(@Anno('x') @Anno2('x') x) {} 8 | 9 | assert.deepEqual([[new Anno('x'), new Anno2('x')]], 10 | MultipleAnnotations.parameters); 11 | -------------------------------------------------------------------------------- /test/feature/Annotations/FunctionMultipleParameters.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import {Anno} from './resources/setup.js'; 3 | 4 | function MultipleParams(@Anno('x') x, @Anno('y') y) {} 5 | 6 | assert.deepEqual([[new Anno('x')], [new Anno('y')]], 7 | MultipleParams.parameters); 8 | -------------------------------------------------------------------------------- /test/feature/Annotations/FunctionParameter.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import {Anno} from './resources/setup.js'; 3 | 4 | function AnnotatedParam(@Anno('x') x) {} 5 | 6 | assert.deepEqual([[new Anno('x')]], AnnotatedParam.parameters); 7 | -------------------------------------------------------------------------------- /test/feature/Annotations/GeneratorFunction.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import {Anno} from './resources/setup.js'; 3 | 4 | @Anno 5 | function* generate() {} 6 | 7 | assert.deepEqual([new Anno], generate.annotations); 8 | -------------------------------------------------------------------------------- /test/feature/Annotations/MethodParam.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import {Anno} from './resources/setup.js'; 3 | 4 | class MethodParam { 5 | method(@Anno x) {} 6 | } 7 | 8 | assert.deepEqual([[new Anno]], MethodParam.prototype.method.parameters); 9 | 10 | -------------------------------------------------------------------------------- /test/feature/Annotations/MultipleAnnotatedFunction.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import { 3 | Anno, 4 | Anno2 5 | } from './resources/setup.js'; 6 | 7 | @Anno 8 | @Anno2('val') 9 | function Multi() {} 10 | 11 | assert.deepEqual([new Anno, new Anno2('val')], Multi.annotations); 12 | 13 | -------------------------------------------------------------------------------- /test/feature/Annotations/MultipleParameterTypes.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations --types 2 | import { 3 | Anno, 4 | X 5 | } from './resources/setup.js'; 6 | 7 | function MultiParamWithAnnotation(@Anno x:X, y) {} 8 | function MultiTypedParamsNoAnnotations(x:X, y:X) {} 9 | 10 | assert.deepEqual([[X, new Anno], []], MultiParamWithAnnotation.parameters); 11 | assert.deepEqual([[X], [X]], MultiTypedParamsNoAnnotations.parameters); 12 | -------------------------------------------------------------------------------- /test/feature/Annotations/NestedFunction.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations --types 2 | import { 3 | Anno, 4 | X 5 | } from './resources/setup.js'; 6 | 7 | function f(a = function() { 8 | // body of default param expression 9 | function g(@Anno x : X) {} 10 | return g; 11 | }) { 12 | return a(); 13 | } 14 | 15 | var nested = f(); 16 | assert.deepEqual([[X, new Anno]], nested.parameters); 17 | 18 | -------------------------------------------------------------------------------- /test/feature/Annotations/PropertyMethodStringName.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import {Anno} from './resources/setup.js'; 3 | 4 | class C { 5 | @Anno('x y z') 6 | "x y z"() { return 1; } 7 | @Anno('xyz') 8 | xyz() { return 1; } 9 | } 10 | 11 | assert.deepEqual([new Anno('x y z')], C.prototype['x y z'].annotations); 12 | assert.deepEqual([new Anno('xyz')], C.prototype.xyz.annotations); 13 | -------------------------------------------------------------------------------- /test/feature/Annotations/SetterParam.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import {Anno} from './resources/setup.js'; 3 | 4 | class SetterParam { 5 | set prop(@Anno x) {} 6 | } 7 | 8 | assert.deepEqual([[new Anno]], 9 | Object.getOwnPropertyDescriptor(SetterParam.prototype, 'prop'). 10 | set.parameters); 11 | -------------------------------------------------------------------------------- /test/feature/Annotations/SimpleFunction.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import {Anno} from './resources/setup.js'; 3 | 4 | @Anno 5 | function Simple() {} 6 | 7 | assert.deepEqual([new Anno], Simple.annotations); 8 | -------------------------------------------------------------------------------- /test/feature/Annotations/StaticGetter.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import {Anno} from './resources/setup.js'; 3 | 4 | class StaticGetter { 5 | @Anno 6 | static get prop() { return 'getter'; } 7 | } 8 | 9 | assert.deepEqual([new Anno], 10 | Object.getOwnPropertyDescriptor(StaticGetter, 'prop').get.annotations); 11 | -------------------------------------------------------------------------------- /test/feature/Annotations/StaticMethod.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import {Anno} from './resources/setup.js'; 3 | 4 | class StaticMethod { 5 | @Anno 6 | static method(@Anno x) {} 7 | } 8 | 9 | assert.deepEqual([new Anno], StaticMethod.method.annotations); 10 | assert.deepEqual([[new Anno]], StaticMethod.method.parameters); 11 | -------------------------------------------------------------------------------- /test/feature/Annotations/StaticSetter.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations 2 | import {Anno} from './resources/setup.js'; 3 | 4 | class StaticSetter { 5 | @Anno 6 | static set prop(@Anno x) {} 7 | } 8 | 9 | assert.deepEqual([new Anno], 10 | Object.getOwnPropertyDescriptor(StaticSetter, 'prop').set.annotations); 11 | assert.deepEqual([[new Anno]], 12 | Object.getOwnPropertyDescriptor(StaticSetter, 'prop').set.parameters); 13 | -------------------------------------------------------------------------------- /test/feature/Annotations/UnannotatedUntypedFunction.js: -------------------------------------------------------------------------------- 1 | function UnannotatedUntypedParams(x, y) {} 2 | 3 | assert(!UnannotatedUntypedParams.annotations); 4 | assert(!UnannotatedUntypedParams.parameters); 5 | -------------------------------------------------------------------------------- /test/feature/Annotations/resources/exported-classes.js: -------------------------------------------------------------------------------- 1 | import {Anno} from './setup.js'; 2 | 3 | @Anno 4 | export class ExportedAnnotatedClass { 5 | @Anno 6 | annotatedMethod() {} 7 | } 8 | 9 | export class ExportedUnannotatedClass { 10 | @Anno 11 | annotatedMethod() {} 12 | } 13 | -------------------------------------------------------------------------------- /test/feature/Annotations/resources/exported-default-class.js: -------------------------------------------------------------------------------- 1 | import {Anno} from './setup.js'; 2 | 3 | @Anno 4 | export default class { 5 | @Anno 6 | annotatedMethod() {} 7 | }; 8 | -------------------------------------------------------------------------------- /test/feature/Annotations/resources/exported-default-function.js: -------------------------------------------------------------------------------- 1 | import {Anno} from './setup.js'; 2 | 3 | @Anno 4 | export default function (@Anno x) {}; 5 | -------------------------------------------------------------------------------- /test/feature/Annotations/resources/exported-functions.js: -------------------------------------------------------------------------------- 1 | import {Anno} from './setup.js'; 2 | 3 | @Anno 4 | export function exportedAnnotated(@Anno x) { 5 | } 6 | 7 | export function exportedUnannotated(@Anno x) { 8 | } 9 | -------------------------------------------------------------------------------- /test/feature/Annotations/resources/setup.js: -------------------------------------------------------------------------------- 1 | export function X() {} 2 | X.toJSON = function () { return 'function X'; } 3 | 4 | export function Anno(value) { 5 | this.annotation = true; 6 | this.value = value; 7 | } 8 | 9 | export function Anno2(value) { 10 | this.annotation2 = true; 11 | this.value = value; 12 | } 13 | -------------------------------------------------------------------------------- /test/feature/ArrayComprehension/ArgumentsInComprehension.js: -------------------------------------------------------------------------------- 1 | // Options: --array-comprehension 2 | // https://github.com/google/traceur-compiler/issues/1086 3 | 4 | function f() { 5 | var a = [for (x of [1]) arguments[0]]; 6 | var b = [for (x of [1]) arguments[0]]; 7 | assert.deepEqual(a, [arguments[0]]); 8 | assert.deepEqual(a, [42]); 9 | assert.deepEqual(a, b); 10 | } 11 | 12 | f(42); 13 | -------------------------------------------------------------------------------- /test/feature/ArrayComprehension/Closure.js: -------------------------------------------------------------------------------- 1 | // Options: --array-comprehension --block-binding 2 | // Block binding is needed to get the right scoping semantics inside the arrow 3 | // function in the comprehension. 4 | 5 | var res = [for (x of [0, 1]) for (y of [2, 3]) () => [x, y]]; 6 | 7 | assert.equal(4, res.length); 8 | assert.deepEqual([0, 2], res[0]()); 9 | assert.deepEqual([0, 3], res[1]()); 10 | assert.deepEqual([1, 2], res[2]()); 11 | assert.deepEqual([1, 3], res[3]()); 12 | -------------------------------------------------------------------------------- /test/feature/ArrayComprehension/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Options: --array-comprehension=false 2 | // Error: :4:14: Unexpected reserved word for 3 | 4 | var array = [for (x of [0, 1, 2, 3, 4]) x]; 5 | -------------------------------------------------------------------------------- /test/feature/ArrayComprehension/Error_NotDefined.js: -------------------------------------------------------------------------------- 1 | // Options: --array-comprehension --free-variable-checker 2 | // Error: :5:1: notDefined is not defined 3 | 4 | var array = [for (notDefined of [0]) notDefined]; 5 | notDefined; 6 | -------------------------------------------------------------------------------- /test/feature/ArrayComprehension/ThisInComprehension.js: -------------------------------------------------------------------------------- 1 | // Options: --array-comprehension 2 | // https://github.com/google/traceur-compiler/issues/1086 3 | 4 | var object = {}; 5 | 6 | function f() { 7 | var a = [for (x of [1]) this]; 8 | var b = [for (x of [1]) this]; 9 | assert.deepEqual(a, [this]); 10 | assert.deepEqual(a, [object]); 11 | assert.deepEqual(a, b); 12 | } 13 | 14 | f.call(object); 15 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/AlphaRename.script.js: -------------------------------------------------------------------------------- 1 | var global = this; 2 | var self = {}; 3 | 4 | function outer() { 5 | var f = () => { 6 | assert.equal(this, self); 7 | 8 | var g = () => { 9 | assert.equal(this, self); 10 | }; 11 | g(); 12 | 13 | var h = function() { 14 | assert.equal(this, global); 15 | }; 16 | h(); 17 | }; 18 | 19 | f(); 20 | } 21 | 22 | outer.call(self); 23 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/Arguments.js: -------------------------------------------------------------------------------- 1 | function f() { 2 | var args = (() => arguments)(); 3 | assert.equal(args, arguments); 4 | } 5 | 6 | f(); 7 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/CoverInitializer.js: -------------------------------------------------------------------------------- 1 | // https://github.com/google/traceur-compiler/issues/478 2 | 3 | function f() { 4 | (1 ? ({a=0}) => {} : 1); 5 | } 6 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/Error_CoverInitializer.js: -------------------------------------------------------------------------------- 1 | // Error: :4:16: Unexpected token = 2 | 3 | function f() { 4 | ({a = (0, {a = 0})} = {}) 5 | } 6 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/Error_CoverInitializer2.js: -------------------------------------------------------------------------------- 1 | // Error: :3:5: Unexpected token = 2 | 3 | ({a = 0}); 4 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/Error_CoverInitializer3.js: -------------------------------------------------------------------------------- 1 | // Error: :3:18: Unexpected token = 2 | 3 | var f = ({x = {y = 1}) => 2; -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Options: --arrow-functions=false 2 | // Error: :4:21: Unexpected token > 3 | 4 | var identity = (x) => x; 5 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/Error_FreeVariableChecker.js: -------------------------------------------------------------------------------- 1 | // Options: --arrow-functions --free-variable-checker 2 | // Error: :3:35: missingIdentifier is not defined 3 | var identity = (identityParam) => missingIdentifier; 4 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/Error_InvalidFormalParameters.js: -------------------------------------------------------------------------------- 1 | // Error: :3:15: Unexpected token + 2 | 3 | var f = (a, b + 5) => a + b; 4 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/Error_LineTerminator.js: -------------------------------------------------------------------------------- 1 | // Error: :4:1: Unexpected token => 2 | 3 | x 4 | =>1 5 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/Error_Precedence.js: -------------------------------------------------------------------------------- 1 | // Error: :3:26: Semi-colon expected 2 | 3 | var identity = (x) => {x}.bind({}); 4 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/Error_Precedence2.js: -------------------------------------------------------------------------------- 1 | // Error: :4:11: Semi-colon expected 2 | // Error: :4:11: Unexpected token => 3 | 4 | (x) + (y) => y; 5 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/Error_Precedence3.js: -------------------------------------------------------------------------------- 1 | // Error: :4:9: Semi-colon expected 2 | // Error: :4:9: Unexpected token => 3 | 4 | (x) + y => y; 5 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/Error_SpreadNotLast.js: -------------------------------------------------------------------------------- 1 | // Error: :5:17: Unexpected token , 2 | // Error: :5:12: Unexpected token ... 3 | 4 | { 5 | let f = (...xs, x) => xs; 6 | } -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/Error_SpreadOutsideFormals.js: -------------------------------------------------------------------------------- 1 | // Error: :3:13: Unexpected token ... 2 | 3 | var f = (x, ...xs); 4 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/FreeVariableChecker.js: -------------------------------------------------------------------------------- 1 | var identity = (identityParam) => identityParam; 2 | assert.equal(1234, identity(1234)); 3 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/InDerivedClassConstructor.js: -------------------------------------------------------------------------------- 1 | class Base { 2 | bar() { 3 | return 1; 4 | } 5 | } 6 | 7 | class Derived extends Base { 8 | constructor() { 9 | super() 10 | this.foo = () => { 11 | return this.bar(); 12 | }; 13 | } 14 | bar() { 15 | return 2; 16 | } 17 | } 18 | 19 | let d = new Derived(); 20 | assert.equal(2, (0, d).foo()); 21 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/Parens.js: -------------------------------------------------------------------------------- 1 | class C { 2 | constructor() { 3 | } 4 | } 5 | 6 | class D extends C { 7 | constructor() { 8 | super(); 9 | this.x = { 10 | y: () => { 11 | return this; 12 | } 13 | }; 14 | } 15 | } 16 | 17 | var o = new D(); 18 | assert.equal(typeof o.x.y, 'function'); 19 | assert.equal(o.x.y(), o); 20 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/Skip_SoftBind.js: -------------------------------------------------------------------------------- 1 | // Skip. Not implemented. 2 | 3 | // TODO: needs soft bind and ??= implemented 4 | 5 | // A special form based on the default operator proposal 6 | const self_default_bound = (this ??= self, a, b) -> { 7 | this.c = a * b; 8 | } 9 | self_default_bound(6, 7); 10 | assert(self.c === 42); 11 | 12 | self_default_bound.call(other, 8, 9); 13 | assert(other.c === 72); 14 | assert(self.c === 42); 15 | -------------------------------------------------------------------------------- /test/feature/ArrowFunctions/ThisBindingInPropertyName.js: -------------------------------------------------------------------------------- 1 | var obj = { 2 | name: 'x', 3 | method() { 4 | var f = (x) => ({[this.name]: x}); 5 | 6 | var o = f(1); 7 | assert.equal(1, o.x); 8 | 9 | this.name = 2; 10 | o = f(3); 11 | assert.equal(3, o[2]); 12 | } 13 | }; 14 | 15 | obj.method(); 16 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/AsyncArrow.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | // Async. 3 | 4 | var f = async () => 1; 5 | 6 | f().then((result) => { 7 | assert.equal(result, 1); 8 | done(); 9 | }).catch(done); 10 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/AsyncArrow2.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | // Async. 3 | 4 | var f = async x => x; 5 | 6 | f(1).then((result) => { 7 | assert.equal(result, 1); 8 | done(); 9 | }).catch(done); 10 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/AsyncArrowArguments.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | // Async. 3 | 4 | function g() { 5 | var f = async (x = arguments) => [x, arguments]; 6 | 7 | f().then((result) => { 8 | assert.equal(result[0][0], 1); 9 | assert.equal(result[1][0], 1); 10 | assert.equal(result[0][1], 2); 11 | assert.equal(result[1][1], 2); 12 | done(); 13 | }).catch(done); 14 | } 15 | 16 | g(1, 2); 17 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/AsyncArrowThis.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | // Async. 3 | 4 | function g() { 5 | var f = async (x = this) => [x, this]; 6 | var p = {}; 7 | f.call(p).then((result) => { 8 | assert.equal(result[0], o); 9 | assert.equal(result[1], o); 10 | done(); 11 | }).catch(done); 12 | } 13 | 14 | var o = {}; 15 | g.call(o); 16 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/AsyncMethodObjectLiteral.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | // Async. 3 | 4 | function asyncTimeout(ms) { 5 | return new Promise((resolve) => { 6 | setTimeout(resolve, ms); 7 | }); 8 | } 9 | 10 | var object = { 11 | async test() { 12 | var x = 0; 13 | await asyncTimeout(1); 14 | assert.equal(1, ++x); 15 | await asyncTimeout(1); 16 | assert.equal(2, ++x); 17 | done(); 18 | } 19 | } 20 | 21 | object.test(); 22 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/AsyncSyntax.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | 3 | var async; 4 | async 5 | function f() { 6 | return async + async; 7 | } 8 | 9 | async = 1; 10 | assert.equal(async, 1); 11 | assert.equal(f(), 2); 12 | 13 | async = async 14 | function g() { 15 | 16 | } 17 | 18 | assert.equal(async, 1); 19 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/Complete.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | // Async. 3 | 4 | function asyncComplete() { 5 | return new Promise((resolve) => { 6 | resolve('complete'); 7 | }); 8 | } 9 | 10 | // ---------------------------------------------------------------------------- 11 | 12 | (async function() { 13 | var value = await asyncComplete(); 14 | assert.equal('complete', value); 15 | done(); 16 | })(); 17 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/Empty.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | // Async. 3 | 4 | async function empty() { 5 | } 6 | 7 | empty().then((v) => { 8 | assert.isUndefined(v); 9 | done(); 10 | }); -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/Error_AsyncArrow.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | // Error: :7:5: Semi-colon expected 3 | // Error: :7:5: Unexpected token => 4 | 5 | var async = () => 1; 6 | var x = async 7 | (y) => y; 8 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/Error_AsyncArrow2.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | // Error: :6:1: Unexpected token => 3 | 4 | var async = () => 1; 5 | var x = async (y) 6 | => y; 7 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Disabled by default. 2 | // Error: :13:21: Semi-colon expected 3 | 4 | function asyncComplete() { 5 | return new Promise((resolve) => { 6 | resolve('complete'); 7 | }); 8 | } 9 | 10 | // ---------------------------------------------------------------------------- 11 | 12 | (async function() { 13 | var value = async asyncComplete(); 14 | assert.equal('complete', value); 15 | })(); 16 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/Finally2.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | // Async. 3 | 4 | var finallyVisited = false; 5 | var resolve; 6 | 7 | async function test() { 8 | try { 9 | await new Promise((r) => { 10 | resolve = r; 11 | }); 12 | } finally { 13 | finallyVisited = true; 14 | } 15 | assert.isTrue(finallyVisited); 16 | done(); 17 | } 18 | 19 | test(); 20 | assert.isFalse(finallyVisited); 21 | resolve(); 22 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/PromiseCast.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | // Async. 3 | 4 | async function f() { 5 | var x = await 1; 6 | assert.equal(x, 1); 7 | x = await undefined; 8 | assert.equal(x, undefined); 9 | done(); 10 | } 11 | 12 | f(); 13 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/Prototype.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | 3 | async function f() { 4 | } 5 | 6 | assert.equal(Object.getPrototypeOf(f), Function.prototype); 7 | assert.instanceOf(f(), Promise); 8 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/Rethrow.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | // Async. 3 | 4 | async function rethrow(x) { 5 | 1; 6 | throw x; 7 | 2; 8 | } 9 | 10 | rethrow(2).catch((err) => { 11 | assert.equal(err, 2) 12 | done(); 13 | }); 14 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/Return.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | // Async. 3 | 4 | async function ret(x) { 5 | if (x > 1) 6 | return x - 2; 7 | return x + 3; 8 | } 9 | 10 | (async function() { 11 | var v = await ret(4); 12 | assert.equal(v, 2); 13 | v = await ret(0); 14 | assert.equal(v, 3); 15 | done(); 16 | })(); 17 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/Yield.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions 2 | // Async. 3 | 4 | function asyncYield() { 5 | return asyncTimeout(0); 6 | } 7 | 8 | function asyncTimeout(ms) { 9 | return new Promise((resolve) => { 10 | setTimeout(resolve, ms); 11 | }); 12 | } 13 | 14 | (async function() { 15 | await asyncYield(); 16 | done(); 17 | })(); 18 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctions/resources/async-function.js: -------------------------------------------------------------------------------- 1 | export async function asyncFunction() { 2 | return 1; 3 | } 4 | 5 | export default async function() { 6 | return 2; 7 | }; 8 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctionsUsingGenerator/AsyncArrow.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions --generators=parse 2 | // Skip !function*() {} 3 | // Async. 4 | 5 | var f = async () => 1; 6 | 7 | f().then((result) => { 8 | assert.equal(result, 1); 9 | done(); 10 | }).catch(done); 11 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctionsUsingGenerator/AsyncArrow2.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions --generators=parse 2 | // Skip !function*() {} 3 | // Async. 4 | 5 | var f = async x => x; 6 | 7 | f(1).then((result) => { 8 | assert.equal(result, 1); 9 | done(); 10 | }).catch(done); 11 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctionsUsingGenerator/AsyncArrowThis.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions --generators=parse 2 | // Skip !function*() {} 3 | // Async. 4 | 5 | function g() { 6 | var f = async (x = this) => [x, this]; 7 | var p = {}; 8 | f.call(p).then((result) => { 9 | assert.equal(result[0], o); 10 | assert.equal(result[1], o); 11 | done(); 12 | }).catch(done); 13 | } 14 | 15 | var o = {}; 16 | g.call(o); 17 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctionsUsingGenerator/AsyncSyntax.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions --generators=parse 2 | // Skip !function*() {} 3 | 4 | var async; 5 | async 6 | function f() { 7 | return async + async; 8 | } 9 | 10 | async = 1; 11 | assert.equal(async, 1); 12 | assert.equal(f(), 2); 13 | 14 | async = async 15 | function g() { 16 | 17 | } 18 | 19 | assert.equal(async, 1); 20 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctionsUsingGenerator/Empty.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions --generators=parse 2 | // Skip !function*() {} 3 | // Async. 4 | 5 | async function empty() { 6 | } 7 | 8 | empty().then((v) => { 9 | assert.isUndefined(v); 10 | done(); 11 | }); -------------------------------------------------------------------------------- /test/feature/AsyncFunctionsUsingGenerator/PromiseCast.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions --generators=parse 2 | // Skip !function*() {} 3 | // Async. 4 | 5 | async function f() { 6 | var x = await 1; 7 | assert.equal(x, 1); 8 | x = await undefined; 9 | assert.equal(x, undefined); 10 | done(); 11 | } 12 | 13 | f(); 14 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctionsUsingGenerator/Prototype.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions --generators=parse 2 | // Skip !function*() {} 3 | 4 | async function f() { 5 | } 6 | 7 | assert.equal(Object.getPrototypeOf(f), Function.prototype); 8 | assert.instanceOf(f(), Promise); 9 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctionsUsingGenerator/Rethrow.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions --generators=parse 2 | // Skip !function*() {} 3 | // Async. 4 | 5 | async function rethrow(x) { 6 | 1; 7 | throw x; 8 | 2; 9 | } 10 | 11 | rethrow(2).catch((err) => { 12 | assert.equal(err, 2) 13 | done(); 14 | }); 15 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctionsUsingGenerator/Return.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions --generators=parse 2 | // Skip !function*() {} 3 | // Async. 4 | 5 | async function ret(x) { 6 | if (x > 1) 7 | return x - 2; 8 | return x + 3; 9 | } 10 | 11 | (async function() { 12 | var v = await ret(4); 13 | assert.equal(v, 2); 14 | v = await ret(0); 15 | assert.equal(v, 3); 16 | done(); 17 | })(); 18 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctionsUsingGenerator/Yield.js: -------------------------------------------------------------------------------- 1 | // Options: --async-functions --generators=parse 2 | // Skip !function*() {} 3 | // Async. 4 | 5 | function asyncYield() { 6 | return asyncTimeout(0); 7 | } 8 | 9 | function asyncTimeout(ms) { 10 | return new Promise((resolve) => { 11 | setTimeout(resolve, ms); 12 | }); 13 | } 14 | 15 | (async function() { 16 | await asyncYield(); 17 | done(); 18 | })(); 19 | -------------------------------------------------------------------------------- /test/feature/AsyncFunctionsUsingGenerator/resources/async-function.js: -------------------------------------------------------------------------------- 1 | export async function asyncFunction() { 2 | return 1; 3 | } 4 | 5 | export default async function() { 6 | return 2; 7 | }; 8 | -------------------------------------------------------------------------------- /test/feature/AsyncGenerators/Array.js: -------------------------------------------------------------------------------- 1 | // Options: --for-on --async-functions 2 | // Async. 3 | 4 | (async function() { 5 | const list = []; 6 | const g = [1, 2, 3]; 7 | for (var i on g) { 8 | list.push(i); 9 | } 10 | assert.deepEqual(list, [1, 2, 3]); 11 | 12 | done(); 13 | })().catch(done); 14 | 15 | -------------------------------------------------------------------------------- /test/feature/AsyncGenerators/AsyncGenerator.js: -------------------------------------------------------------------------------- 1 | // Options: --async-generators --for-on --async-functions 2 | // Async. 3 | 4 | async function* f() { 5 | yield 1; 6 | } 7 | 8 | (async function() { 9 | var list = []; 10 | var g = f(); 11 | for (var i on g) { 12 | list.push(i); 13 | } 14 | assert.deepEqual(list, [1]); 15 | 16 | done(); 17 | })().catch(done); 18 | 19 | -------------------------------------------------------------------------------- /test/feature/AsyncGenerators/ForOnBody.js: -------------------------------------------------------------------------------- 1 | // Options: --async-generators --for-on --async-functions 2 | // Async. 3 | 4 | async function* x() { 5 | } 6 | 7 | async function y() { 8 | for (let a on x()) 9 | break; 10 | } 11 | 12 | y() 13 | 14 | done(); 15 | -------------------------------------------------------------------------------- /test/feature/AsyncGenerators/Method.js: -------------------------------------------------------------------------------- 1 | // Options: --async-generators --for-on --async-functions 2 | // Async. 3 | 4 | class C { 5 | static async* f() { 6 | yield 1; 7 | } 8 | } 9 | 10 | (async function() { 11 | var list = []; 12 | var g = C.f(); 13 | for (var i on g) { 14 | list.push(i); 15 | } 16 | assert.deepEqual(list, [1]); 17 | 18 | done(); 19 | })().catch(done); 20 | 21 | -------------------------------------------------------------------------------- /test/feature/AsyncGenerators/Property.js: -------------------------------------------------------------------------------- 1 | // Options: --async-generators --for-on --async-functions 2 | // Async. 3 | 4 | var C = { 5 | async* f() { 6 | yield 1; 7 | } 8 | }; 9 | 10 | (async function() { 11 | var list = []; 12 | var g = C.f(); 13 | for (var i on g) { 14 | list.push(i); 15 | } 16 | assert.deepEqual(list, [1]); 17 | 18 | done(); 19 | })().catch(done); 20 | 21 | -------------------------------------------------------------------------------- /test/feature/AsyncGenerators/ReturnAsyncGenerator.js: -------------------------------------------------------------------------------- 1 | // Options: --async-generators --for-on --async-functions 2 | // Async. 3 | 4 | async function* f() { 5 | yield 1; 6 | yield 2; 7 | yield 3; 8 | } 9 | 10 | 11 | (async function() { 12 | var list = []; 13 | var g = f(); 14 | for (var i on g) { 15 | if (i === 2) { 16 | break; 17 | } 18 | list.push(i); 19 | } 20 | assert.deepEqual(list, [1]); 21 | 22 | done(); 23 | })().catch(done); 24 | 25 | -------------------------------------------------------------------------------- /test/feature/AsyncGenerators/ThisAndArguments.js: -------------------------------------------------------------------------------- 1 | // Options: --async-generators --for-on --async-functions 2 | // Async. 3 | 4 | async function* f(a) { 5 | yield this[0]; 6 | yield arguments[0]; 7 | } 8 | 9 | (async function() { 10 | var list = []; 11 | var g = f.call([1], 2); 12 | for (var i on g) { 13 | list.push(i); 14 | } 15 | assert.deepEqual(list, [1, 2]); 16 | 17 | done(); 18 | })().catch(done); 19 | 20 | -------------------------------------------------------------------------------- /test/feature/AsyncGenerators/YieldForOn.script.js: -------------------------------------------------------------------------------- 1 | // Options: --async-generators --for-on --async-functions 2 | // Async. 3 | 4 | async function* f() { 5 | yield 1; 6 | yield 2; 7 | } 8 | 9 | async function* g() { 10 | for (i on f()) { 11 | yield 2 * i; 12 | } 13 | } 14 | 15 | (async function() { 16 | var list = []; 17 | for (var i on g()) { 18 | list.push(i); 19 | } 20 | assert.deepEqual(list, [2, 4]); 21 | 22 | done(); 23 | })().catch(done); 24 | 25 | -------------------------------------------------------------------------------- /test/feature/AtScript/AtScript.js: -------------------------------------------------------------------------------- 1 | // Options: --atscript 2 | 3 | class Inject {} 4 | class Bar {} 5 | 6 | @Inject 7 | class Foo { 8 | static id: number; 9 | name: string; 10 | 11 | constructor(bar: Bar) {} 12 | } 13 | 14 | var foo = new Foo(new Bar()); 15 | 16 | assert.deepEqual([new Inject], Foo.annotations); 17 | assert.deepEqual([[Bar]], Foo.parameters); 18 | -------------------------------------------------------------------------------- /test/feature/Classes/DeriveFromObject.js: -------------------------------------------------------------------------------- 1 | class DerivedFromObject extends Object { 2 | } 3 | 4 | // ---------------------------------------------------------------------------- 5 | 6 | // TODO(rnystrom): No tests for this? 7 | -------------------------------------------------------------------------------- /test/feature/Classes/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Options: --classes=false 2 | // Error: :4:1: Unexpected reserved word 3 | 4 | class C {} 5 | -------------------------------------------------------------------------------- /test/feature/Classes/Error_GH1556.js: -------------------------------------------------------------------------------- 1 | // Error: :5:19: Unexpected token = 2 | 3 | // extends LeftHandSideExpression 4 | // see https://github.com/google/traceur-compiler/issues/1556 5 | class A extends B = C {} 6 | -------------------------------------------------------------------------------- /test/feature/Classes/Error_NewSuper.js: -------------------------------------------------------------------------------- 1 | // Error: :5:14: Unexpected token ( 2 | 3 | class C { 4 | m() { 5 | new super(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/feature/Classes/Error_NewSuper2.js: -------------------------------------------------------------------------------- 1 | // Error: :6:3: Unexpected token } 2 | 3 | class C { 4 | m() { 5 | new super 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/feature/Classes/Error_NoSuperInDerivedClass.js: -------------------------------------------------------------------------------- 1 | // Error: :6:3: Derived constructor must call super() 2 | 3 | class B {} 4 | 5 | class C extends B { 6 | constructor() { 7 | // no super call 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/feature/Classes/Error_Super.js: -------------------------------------------------------------------------------- 1 | // Error: :7:17: Unexpected token ; 2 | 3 | class A {} 4 | 5 | class ImproperSuper extends A { 6 | method() { 7 | return super; 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /test/feature/Classes/Error_SuperAsTemplateTag.js: -------------------------------------------------------------------------------- 1 | // Error: :7:18: Unexpected token ` 2 | 3 | class A {} 4 | 5 | class ImproperSuper extends A { 6 | method() { 7 | return super ``; 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /test/feature/Classes/Error_SuperCallInNonDerived.js: -------------------------------------------------------------------------------- 1 | // Error: :5:5: super call is only allowed in derived constructor 2 | 3 | class C { 4 | constructor() { 5 | super(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/feature/Classes/Error_SuperNestedClass.js: -------------------------------------------------------------------------------- 1 | // Error: :12:5: 'this' is not allowed before super() 2 | 3 | class Animal {} 4 | 5 | class Roo extends Animal { 6 | constructor() { 7 | class Koala extends Animal { 8 | constructor() { 9 | super(); 10 | } 11 | } 12 | this.a = new Koala; 13 | super(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/feature/Classes/Error_SuperPropertyOutsideMethod.js: -------------------------------------------------------------------------------- 1 | // Error: :6:3: super is only allowed in methods 2 | // Error: :9:15: super is only allowed in methods 3 | // Error: :10:17: super is only allowed in methods 4 | 5 | function f() { 6 | super.x; 7 | } 8 | 9 | var g = () => super.y; 10 | var h = () => { super.z; } 11 | -------------------------------------------------------------------------------- /test/feature/Classes/ExtendCoverFormals.js: -------------------------------------------------------------------------------- 1 | class C {} 2 | 3 | var x = 1; 4 | var y = C; 5 | class D extends (x, y) { 6 | 7 | } 8 | 9 | assert.instanceOf(new D(), C); 10 | assert.instanceOf(new D(), D); 11 | -------------------------------------------------------------------------------- /test/feature/Classes/ExtendNonConstructableFunction.js: -------------------------------------------------------------------------------- 1 | 2 | assert.throw(function() { 3 | class C extends Math {} 4 | }, 'Super expression must either be null or a function'); 5 | 6 | assert.throw(function() { 7 | function f() {} 8 | // prototype needs to be an Object or null. 9 | f.prototype = 42; 10 | class C extends f {} 11 | }, 'super prototype must be an Object or null'); 12 | -------------------------------------------------------------------------------- /test/feature/Classes/ExtendObject.js: -------------------------------------------------------------------------------- 1 | // Can no longer extend objects. 2 | assert.throw(function() { 3 | class C extends {} {} 4 | }, TypeError); 5 | -------------------------------------------------------------------------------- /test/feature/Classes/Fields.js: -------------------------------------------------------------------------------- 1 | class Point { 2 | constructor() { 3 | this.x = 0; 4 | this.y = 0; 5 | } 6 | } 7 | 8 | // ---------------------------------------------------------------------------- 9 | 10 | var p = new Point(); 11 | 12 | var keys = []; 13 | for (var key in p) { 14 | keys.push(key); 15 | } 16 | 17 | assert.isTrue(keys.indexOf('x') !== -1); 18 | assert.isTrue(keys.indexOf('y') !== -1); 19 | assert.isTrue(keys.indexOf('constructor') === -1); 20 | -------------------------------------------------------------------------------- /test/feature/Classes/Inheritance.js: -------------------------------------------------------------------------------- 1 | class SimpleBase {} 2 | class SimpleDerived extends SimpleBase {} 3 | 4 | // ---------------------------------------------------------------------------- 5 | 6 | var derived = new SimpleDerived(); 7 | assert.isTrue(derived instanceof SimpleDerived); 8 | assert.isTrue(derived instanceof SimpleBase); 9 | assert.isTrue(derived instanceof Object); 10 | -------------------------------------------------------------------------------- /test/feature/Classes/InheritanceNameBinding.js: -------------------------------------------------------------------------------- 1 | class NameBindingBase {} 2 | 3 | class NameBindingDerived extends NameBindingBase { 4 | getX() { return this.x; } 5 | } 6 | 7 | // ---------------------------------------------------------------------------- 8 | 9 | var derived = new NameBindingDerived(); 10 | derived.x = 12; 11 | assert.equal(12, derived.getX()); 12 | -------------------------------------------------------------------------------- /test/feature/Classes/NewClassExpression.js: -------------------------------------------------------------------------------- 1 | 2 | assert.equal((new class { 3 | get x() { 4 | return 'x'; 5 | } 6 | getX() { 7 | return this.x; 8 | } 9 | }).getX(), 'x'); 10 | 11 | assert.equal(new class { 12 | get y() { 13 | return 'y'; 14 | } 15 | getY() { 16 | return this.y; 17 | } 18 | }().getY(), 'y'); 19 | -------------------------------------------------------------------------------- /test/feature/Classes/PrototypeDescriptor.js: -------------------------------------------------------------------------------- 1 | class C {} 2 | 3 | var descr = Object.getOwnPropertyDescriptor(C, 'prototype'); 4 | assert.isFalse(descr.enumerable); 5 | assert.isFalse(descr.configurable); 6 | assert.isFalse(descr.writable); 7 | assert.equal(descr.value, C.prototype); 8 | -------------------------------------------------------------------------------- /test/feature/Classes/RestParams.js: -------------------------------------------------------------------------------- 1 | class RestParams { 2 | constructor(...rest) { 3 | this.rest = rest; 4 | } 5 | instanceMethod(...rest) { 6 | return rest; 7 | } 8 | } 9 | 10 | // ---------------------------------------------------------------------------- 11 | 12 | var obj = new RestParams(0, 1, 2); 13 | assert.deepEqual([0, 1, 2], obj.rest); 14 | assert.deepEqual([3, 4, 5], obj.instanceMethod(3, 4, 5)); 15 | 16 | -------------------------------------------------------------------------------- /test/feature/Classes/SemiColon.js: -------------------------------------------------------------------------------- 1 | class SemiColon { 2 | ; 3 | } -------------------------------------------------------------------------------- /test/feature/Classes/StaticSymbol.js: -------------------------------------------------------------------------------- 1 | var sym = Symbol(); 2 | class C { 3 | static [sym]() { 4 | return 42; 5 | } 6 | } 7 | assert.equal(C[sym](), 42); 8 | -------------------------------------------------------------------------------- /test/feature/Classes/SuperChangeProto.js: -------------------------------------------------------------------------------- 1 | var log = ''; 2 | 3 | class Base { 4 | p() { log += '[Base]'; } 5 | } 6 | 7 | class OtherBase { 8 | p() { log += '[OtherBase]'; } 9 | } 10 | class Derived extends Base { 11 | p() { 12 | log += '[Derived]'; 13 | super.p(); 14 | Derived.prototype.__proto__ = OtherBase.prototype; 15 | super.p(); 16 | } 17 | } 18 | 19 | new Derived().p(); 20 | assert.equal(log, '[Derived][Base][OtherBase]'); 21 | -------------------------------------------------------------------------------- /test/feature/Classes/SuperInArrow.js: -------------------------------------------------------------------------------- 1 | var x; 2 | 3 | class B { 4 | m(v) { 5 | x = v; 6 | } 7 | } 8 | 9 | class D extends B { 10 | n(x) { 11 | var f = (x) => { 12 | super.m(x); 13 | }; 14 | f(x); 15 | } 16 | } 17 | 18 | new D().n(42); 19 | assert.equal(x, 42); 20 | -------------------------------------------------------------------------------- /test/feature/Classes/SuperNestedClass.js: -------------------------------------------------------------------------------- 1 | class Animal { 2 | constructor(name) { 3 | this.name = name; 4 | } 5 | } 6 | 7 | class Roo extends Animal { 8 | constructor() { 9 | class Koala extends (super('R'), Animal) { 10 | constructor() { 11 | super('K'); 12 | } 13 | } 14 | this.a = new Koala; 15 | } 16 | } 17 | 18 | 19 | var r = new Roo(); 20 | assert.equal('R', r.name); 21 | assert.equal('K', r.a.name); 22 | -------------------------------------------------------------------------------- /test/feature/Classes/SuperPostfix.js: -------------------------------------------------------------------------------- 1 | class B { 2 | constructor() { 3 | this._x = 0; 4 | } 5 | get x() { 6 | return this._x; 7 | } 8 | set x(x) { 9 | this._x = x; 10 | } 11 | } 12 | 13 | class C extends B { 14 | m() { 15 | assert.equal(this.x, 0); 16 | assert.equal(super.x++, 0); 17 | assert.equal(this.x, 1); 18 | assert.equal(super.x--, 1); 19 | assert.equal(this.x, 0); 20 | } 21 | } 22 | 23 | new C().m(); 24 | -------------------------------------------------------------------------------- /test/feature/Classes/SuperWithoutExtends.js: -------------------------------------------------------------------------------- 1 | class C { 2 | constructor() { 3 | this.x = true; 4 | } 5 | static m() { 6 | return super.hasOwnProperty('m'); 7 | } 8 | 9 | m() { 10 | return super.hasOwnProperty('x'); 11 | } 12 | } 13 | 14 | assert.isTrue(new C().m()); 15 | assert.isTrue(C.m()); 16 | -------------------------------------------------------------------------------- /test/feature/Collections/SetWithSymbols.js: -------------------------------------------------------------------------------- 1 | var s = new Set(['Banana', 'Orange', 'Apple', 'Mango', 'Apple', 'Apple']); 2 | assert.equal(s.size, 4); 3 | -------------------------------------------------------------------------------- /test/feature/ComputedPropertyNames/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Options: --computed-property-names=false 2 | // Error: :5:3: Unexpected token [ 3 | 4 | var object = { 5 | [1]: 2 6 | }; 7 | -------------------------------------------------------------------------------- /test/feature/ComputedPropertyNames/Symbol.js: -------------------------------------------------------------------------------- 1 | var s = Symbol(); 2 | 3 | var object = { 4 | [s]: 42 5 | }; 6 | 7 | assert.equal(object[s], 42); 8 | -------------------------------------------------------------------------------- /test/feature/DefaultParameters/Error_SetAccessor.js: -------------------------------------------------------------------------------- 1 | // Error: :5:15: Unexpected token = 2 | 3 | var object = { 4 | // Default parameters are not allowed on setters. 5 | set x(value = 42) {} 6 | } -------------------------------------------------------------------------------- /test/feature/DefaultParameters/Strict.js: -------------------------------------------------------------------------------- 1 | function f(a = 1) { 2 | 'use strict'; 3 | return this; 4 | } 5 | 6 | assert.isUndefined(f()); 7 | -------------------------------------------------------------------------------- /test/feature/Destructuring/Arguments.js: -------------------------------------------------------------------------------- 1 | function destructureArguments(x, y) { 2 | [arguments[0], [arguments[1]]] = [1, [2]] 3 | return x + y; 4 | } 5 | 6 | // ---------------------------------------------------------------------------- 7 | 8 | assert.equal(3, destructureArguments(1, 2)); 9 | -------------------------------------------------------------------------------- /test/feature/Destructuring/ArrayPatternTrailingComma.js: -------------------------------------------------------------------------------- 1 | var [a, b, , ] = [0, 1, , ]; 2 | assert.equal(a, 0); 3 | assert.equal(b, 1); 4 | 5 | var c, d; 6 | [c, d, , ] = [0, 1, , ]; 7 | assert.equal(c, 0); 8 | assert.equal(d, 1); 9 | -------------------------------------------------------------------------------- /test/feature/Destructuring/ArrayPatternWithCoverInitializedName.js: -------------------------------------------------------------------------------- 1 | var x, y; 2 | [x, {y = 1}] = [0, {}]; 3 | 4 | assert.equal(x, 0); 5 | assert.equal(y, 1); 6 | -------------------------------------------------------------------------------- /test/feature/Destructuring/ArrayPatternWithInitializer.js: -------------------------------------------------------------------------------- 1 | // https://github.com/google/traceur-compiler/issues/969 2 | 3 | var x; 4 | [x = 1] = []; 5 | assert.equal(x, 1); 6 | -------------------------------------------------------------------------------- /test/feature/Destructuring/CoverInitializedName.js: -------------------------------------------------------------------------------- 1 | // https://github.com/google/traceur-compiler/issues/183 2 | 3 | var f = ({x = 42}) => x; 4 | assert.equal(f({}), 42); 5 | -------------------------------------------------------------------------------- /test/feature/Destructuring/CoverInitializer.js: -------------------------------------------------------------------------------- 1 | // https://github.com/google/traceur-compiler/issues/1015 2 | 3 | var x, y; 4 | ({x = 1, y = 2} = {}); 5 | assert.equal(x, 1); 6 | assert.equal(y, 2); 7 | 8 | ({x: {x = 3}} = {x: {}}); 9 | assert.equal(x, 3); 10 | -------------------------------------------------------------------------------- /test/feature/Destructuring/CoverInitializerInForOf.script.js: -------------------------------------------------------------------------------- 1 | // https://github.com/google/traceur-compiler/issues/836 2 | 3 | var count = 0; 4 | for ({a = 0} of [{}]) { 5 | count++; 6 | assert.equal(a, 0); 7 | } 8 | 9 | assert.equal(count, 1); 10 | -------------------------------------------------------------------------------- /test/feature/Destructuring/DefaultParams.js: -------------------------------------------------------------------------------- 1 | function f([x] = [1], {y} = {y: 2}) { 2 | return x + y; 3 | } 4 | 5 | assert.equal(3, f()); -------------------------------------------------------------------------------- /test/feature/Destructuring/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Options: --destructuring=false 2 | // Error: 4:5: Unexpected token [ 3 | 4 | var [x, y] = [0, 1]; 5 | -------------------------------------------------------------------------------- /test/feature/Destructuring/Error_ForInWithInitializer.js: -------------------------------------------------------------------------------- 1 | // Error: :3:19: Unexpected token in 2 | 3 | for (var {k} = {} in {}) { 4 | } 5 | -------------------------------------------------------------------------------- /test/feature/Destructuring/Error_ForOfWithInitializer.js: -------------------------------------------------------------------------------- 1 | // Error: :3:19: Unexpected token of 2 | 3 | for (var {k} = {} of []) { 4 | } 5 | -------------------------------------------------------------------------------- /test/feature/Destructuring/Error_InvalidArrowRest.js: -------------------------------------------------------------------------------- 1 | // Error: :3:16: Unexpected token , 2 | 3 | var f = ([...xs, ys]) => xs; 4 | -------------------------------------------------------------------------------- /test/feature/Destructuring/Error_InvalidCoverInitializedName.js: -------------------------------------------------------------------------------- 1 | // Error: :3:5: Unexpected token = 2 | 3 | ({x = 42}); 4 | -------------------------------------------------------------------------------- /test/feature/Destructuring/EvaluatesToRvalue.js: -------------------------------------------------------------------------------- 1 | function destructEvaluatesToRvalue() { 2 | var a; 3 | return [a] = [1, 2, 3]; 4 | } 5 | 6 | // ---------------------------------------------------------------------------- 7 | 8 | var result = destructEvaluatesToRvalue(); 9 | assert.deepEqual([1, 2, 3], result); 10 | -------------------------------------------------------------------------------- /test/feature/Destructuring/EvaluationOrder.js: -------------------------------------------------------------------------------- 1 | function destructEvaluationOrder() { 2 | var a; 3 | [a, a, a] = [1, 2, 3, 4]; 4 | return a; 5 | } 6 | 7 | // ---------------------------------------------------------------------------- 8 | 9 | var result = destructEvaluationOrder(); 10 | assert.equal(3, result); 11 | -------------------------------------------------------------------------------- /test/feature/Destructuring/FunctionArrayPattern.js: -------------------------------------------------------------------------------- 1 | function f([a, b, ...c], d) { 2 | return [a, b, c, d]; 3 | } 4 | assert.deepEqual([1, 2, [3, 4], 5], f([1, 2, 3, 4], 5)); 5 | 6 | function g([, a]) { 7 | return a; 8 | } 9 | assert.equal(g([0, 1]), 1); 10 | 11 | function h([, [, a]]) { 12 | return a; 13 | } 14 | assert.equal(h([0, [1, 2]]), 2); 15 | -------------------------------------------------------------------------------- /test/feature/Destructuring/FunctionObjectPattern.js: -------------------------------------------------------------------------------- 1 | function f({a, b: {c}}, d) { 2 | return [a, c, d]; 3 | } 4 | 5 | assert.deepEqual([1, 2, 3], f({a: 1, b: {c: 2}}, 3)); -------------------------------------------------------------------------------- /test/feature/Destructuring/InitializerObject.js: -------------------------------------------------------------------------------- 1 | var x, z; 2 | 3 | ({x = {y: 1}} = {}); 4 | assert.deepEqual(x, {y: 1}); 5 | 6 | ({x = {y: {z = 2} = {}}} = {}); 7 | assert.equal(z, 2); 8 | assert.deepEqual(x, {y: {}}); 9 | 10 | ({x = {y: {z = 3} = {z: 4}}} = {}); 11 | assert.equal(z, 4); 12 | assert.deepEqual(x, {y: {z: 4}}); 13 | -------------------------------------------------------------------------------- /test/feature/Destructuring/Method.js: -------------------------------------------------------------------------------- 1 | function MyError(s) { 2 | this.message = new String(s); 3 | this.name = 'Error'; 4 | } 5 | 6 | var object = { 7 | method({message: [head, ...tail], name}) { 8 | assert.equal('a', head); 9 | assert.deepEqual(['b', 'c'], tail); 10 | assert.equal('Error', name); 11 | } 12 | }; 13 | 14 | object.method(new MyError('abc')); 15 | -------------------------------------------------------------------------------- /test/feature/Destructuring/MultipleCoverInitializersInArrowFunction.js: -------------------------------------------------------------------------------- 1 | // https://github.com/google/traceur-compiler/issues/838 2 | 3 | var f = ({a = 0}, {b = 1}) => ({a, b}); 4 | assert.deepEqual(f({}, {}), {a: 0, b: 1}); 5 | -------------------------------------------------------------------------------- /test/feature/Destructuring/NestedScopeArguments.js: -------------------------------------------------------------------------------- 1 | // Destructuring bind alpha-renames 'arguments'; this ensures that 2 | // renaming doesn't rename in nested scopes. 3 | function destructNestedScopeArguments(x) { 4 | [(function () { return arguments[1]; })(null, x)[0]] = [42]; 5 | } 6 | 7 | // ---------------------------------------------------------------------------- 8 | 9 | var result = []; 10 | destructNestedScopeArguments(result); 11 | assert.equal(42, result[0]); 12 | -------------------------------------------------------------------------------- /test/feature/Destructuring/ScopeThis.js: -------------------------------------------------------------------------------- 1 | function destructScopeThis() { 2 | var x; 3 | var o = { 4 | f: function() { 5 | [this.x] = [1]; 6 | } 7 | }; 8 | o.f(); 9 | return { 10 | x: x, 11 | o_x: o.x 12 | }; 13 | } 14 | 15 | // ---------------------------------------------------------------------------- 16 | 17 | var result = destructScopeThis(); 18 | assert.isUndefined(result.x); 19 | assert.equal(1, result.o_x); 20 | -------------------------------------------------------------------------------- /test/feature/Destructuring/SetAccessor.js: -------------------------------------------------------------------------------- 1 | function MyError(s) { 2 | this.message = new String(s); 3 | this.name = 'Error'; 4 | } 5 | 6 | var object = { 7 | set x({message: [head, ...tail], name}) { 8 | assert.equal('a', head); 9 | assert.deepEqual(['b', 'c'], tail); 10 | assert.equal('Error', name); 11 | } 12 | }; 13 | 14 | object.x = new MyError('abc'); 15 | -------------------------------------------------------------------------------- /test/feature/Destructuring/StrangeProperties.js: -------------------------------------------------------------------------------- 1 | var x, y; 2 | 3 | ({if: x = 1, else: y} = {else: 2}); 4 | assert.equal(x, 1); 5 | assert.equal(y, 2); 6 | 7 | ({'': x = 3, ' ': y} = {' ': 4}); 8 | assert.equal(x, 3); 9 | assert.equal(y, 4); 10 | 11 | ({true: x = 5, false: y} = {false: 6}); 12 | assert.equal(x, 5); 13 | assert.equal(y, 6); 14 | 15 | ({0: x = 7, 1: y} = {1: 8}); 16 | assert.equal(x, 7); 17 | assert.equal(y, 8); 18 | -------------------------------------------------------------------------------- /test/feature/Destructuring/Strict.js: -------------------------------------------------------------------------------- 1 | function f({x}) { 2 | 'use strict'; 3 | return this; 4 | } 5 | 6 | assert.isUndefined(f({x: 42})); -------------------------------------------------------------------------------- /test/feature/Destructuring/TopLevel.js: -------------------------------------------------------------------------------- 1 | var a, b, c, d; 2 | [a, [b, c], d] = ['hello', [',', 'junk'], ['world']]; 3 | 4 | // ---------------------------------------------------------------------------- 5 | 6 | assert.equal('hello', a); 7 | assert.equal(',', b); 8 | assert.equal('junk', c); 9 | assert.deepEqual(['world'], d); 10 | -------------------------------------------------------------------------------- /test/feature/ForOf/NewNoParens.js: -------------------------------------------------------------------------------- 1 | function C() {} 2 | C.prototype[Symbol.iterator] = function() { 3 | var n = 0; 4 | return { 5 | next() { 6 | return {value: n++, done: n > 3}; 7 | } 8 | }; 9 | }; 10 | 11 | var s = ''; 12 | for (var x of new C()) { 13 | s += x; 14 | } 15 | assert.equal(s, '012'); 16 | 17 | s = ''; 18 | for (var x of new C) { 19 | s += x; 20 | } 21 | assert.equal(s, '012'); 22 | -------------------------------------------------------------------------------- /test/feature/FreeVariableChecker/Error_With.script.js: -------------------------------------------------------------------------------- 1 | // Options: --free-variable-checker 2 | // Error: :8:9: missingVarWith is not defined 3 | 4 | var o = {}; 5 | with (o) { 6 | missingVarWith = 42; 7 | } 8 | var x = missingVarWith * 2; 9 | -------------------------------------------------------------------------------- /test/feature/FreeVariableChecker/Typeof.js: -------------------------------------------------------------------------------- 1 | function f() { 2 | if (typeof x1) 3 | x1; 4 | } 5 | 6 | function g() { 7 | typeof x2; 8 | x2; 9 | } 10 | -------------------------------------------------------------------------------- /test/feature/FreeVariableChecker/WithBasic.script.js: -------------------------------------------------------------------------------- 1 | var o = { 2 | unicorns: 42, 3 | fairyGodmothers: 3 4 | }; 5 | 6 | with (o) { 7 | x = 42; 8 | y = x * x; 9 | 10 | bubbles = 1000; 11 | fairyGodmotherBubbles = bubbles * fairyGodmothers; 12 | unicorns = bubbles * fairyGodmothers - (fairyGodmotherBubbles - unicorns); 13 | } 14 | -------------------------------------------------------------------------------- /test/feature/GeneratorComprehension/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Options: --generator-comprehension=false 2 | // Error: :4:13: Unexpected reserved word for 3 | 4 | var iter = (for (x of [0, 1, 2, 3, 4]) x); 5 | -------------------------------------------------------------------------------- /test/feature/GeneratorComprehension/Error_NotDefined.js: -------------------------------------------------------------------------------- 1 | // Options: --generator-comprehension --free-variable-checker 2 | // Error: :5:1: notDefined is not defined 3 | 4 | var iter = (for (notDefined of [0]) notDefined); 5 | notDefined; 6 | -------------------------------------------------------------------------------- /test/feature/JSX/OptionCustom.js: -------------------------------------------------------------------------------- 1 | // Options: --jsx=a.b 2 | 3 | let a = { 4 | b(n, p) { 5 | assert.equal('p', n); 6 | assert.equal(p, null); 7 | } 8 | }; 9 |

; 10 | -------------------------------------------------------------------------------- /test/feature/JSX/OptionDefault.js: -------------------------------------------------------------------------------- 1 | // Options: --jsx 2 | 3 | let React = { 4 | createElement(n, p) { 5 | assert.equal('p', n); 6 | assert.equal(p, null); 7 | } 8 | }; 9 |

; 10 | -------------------------------------------------------------------------------- /test/feature/Math/acosh.js: -------------------------------------------------------------------------------- 1 | import {acosh} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testAcosh(acosh) { 4 | assert.equal(0, acosh(1)); 5 | } 6 | 7 | testAcosh(acosh); 8 | testAcosh(Math.acosh); 9 | -------------------------------------------------------------------------------- /test/feature/Math/asinh.js: -------------------------------------------------------------------------------- 1 | import {asinh} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testAsinh(asinh) { 4 | assert.equal(0, asinh(0)); 5 | } 6 | 7 | testAsinh(asinh); 8 | testAsinh(Math.asinh); 9 | -------------------------------------------------------------------------------- /test/feature/Math/atanh.js: -------------------------------------------------------------------------------- 1 | import {atanh} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testAtanh(atanh) { 4 | assert.equal(0, atanh(0)); 5 | } 6 | 7 | testAtanh(atanh); 8 | testAtanh(Math.atanh); 9 | -------------------------------------------------------------------------------- /test/feature/Math/cbrt.js: -------------------------------------------------------------------------------- 1 | import {cbrt} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testCbrt(cbrt) { 4 | assert.equal(0, cbrt(0)); 5 | } 6 | 7 | testCbrt(cbrt); 8 | testCbrt(Math.cbrt); 9 | -------------------------------------------------------------------------------- /test/feature/Math/clz32.js: -------------------------------------------------------------------------------- 1 | import {clz32} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testClz32(clz32) { 4 | [NaN, Infinity, -Infinity, 0, -0, 'abc', 'Infinity', '-Infinity', {}].forEach( 5 | (x) => assert.equal(32, clz32(x))); 6 | } 7 | 8 | testClz32(clz32); 9 | testClz32(Math.clz32); 10 | -------------------------------------------------------------------------------- /test/feature/Math/cosh.js: -------------------------------------------------------------------------------- 1 | import {cosh} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testCosh(cosh) { 4 | assert.equal(Infinity, cosh(-Infinity)); 5 | assert.equal(Infinity, cosh(Infinity)); 6 | assert.equal(1, cosh(0)); 7 | assert.equal(1, cosh(-0)); 8 | } 9 | 10 | testCosh(cosh); 11 | testCosh(Math.cosh); 12 | -------------------------------------------------------------------------------- /test/feature/Math/expm1.js: -------------------------------------------------------------------------------- 1 | import {expm1} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testExpm1(expm1) { 4 | assert.equal(Infinity, expm1(Infinity)); 5 | assert.equal(-1, expm1(-Infinity)); 6 | } 7 | 8 | testExpm1(expm1); 9 | testExpm1(Math.expm1); 10 | -------------------------------------------------------------------------------- /test/feature/Math/hypot.js: -------------------------------------------------------------------------------- 1 | import {hypot} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testHypot(hypot) { 4 | assert.equal(1, hypot(1)); 5 | assert.equal(Math.PI, hypot(Math.PI)); 6 | } 7 | 8 | testHypot(hypot); 9 | testHypot(Math.hypot); 10 | -------------------------------------------------------------------------------- /test/feature/Math/imul.js: -------------------------------------------------------------------------------- 1 | import {imul} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testImul(imul) { 4 | assert.equal(8, imul(2, 4)); 5 | } 6 | 7 | testImul(imul); 8 | testImul(Math.imul); 9 | -------------------------------------------------------------------------------- /test/feature/Math/log10.js: -------------------------------------------------------------------------------- 1 | import {log10} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testLog10(log10) { 4 | assert.equal(1, log10(10)); 5 | assert.equal(2, log10(100)); 6 | } 7 | 8 | testLog10(log10); 9 | testLog10(Math.log10); 10 | -------------------------------------------------------------------------------- /test/feature/Math/log1p.js: -------------------------------------------------------------------------------- 1 | import {log1p} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testLog1p(log1p) { 4 | assert.equal(0, log1p(0)); 5 | } 6 | 7 | // testLog1p(log1p); 8 | testLog1p(Math.log1p); 9 | -------------------------------------------------------------------------------- /test/feature/Math/log2.js: -------------------------------------------------------------------------------- 1 | import {log2} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testLog2(log2) { 4 | assert.equal(1, log2(2)); 5 | assert.equal(2, log2(4)); 6 | } 7 | 8 | testLog2(log2); 9 | testLog2(Math.log2); 10 | -------------------------------------------------------------------------------- /test/feature/Math/sign.js: -------------------------------------------------------------------------------- 1 | import {sign} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testSign(sign) { 4 | assert.equal(1, sign(1)); 5 | assert.equal(-1, sign(-1)); 6 | assert.equal(0, sign(0)); 7 | assert.equal(-0, sign(-0)); 8 | } 9 | 10 | testSign(sign); 11 | testSign(Math.sign); 12 | -------------------------------------------------------------------------------- /test/feature/Math/sinh.js: -------------------------------------------------------------------------------- 1 | import {sinh} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testSinh(sinh) { 4 | assert.equal(0, sinh(0)); 5 | assert.equal(-0, sinh(-0)); 6 | assert.equal(Infinity, sinh(Infinity)); 7 | assert.equal(-Infinity, sinh(-Infinity)); 8 | } 9 | 10 | testSinh(sinh); 11 | testSinh(Math.sinh); 12 | -------------------------------------------------------------------------------- /test/feature/Math/tanh.js: -------------------------------------------------------------------------------- 1 | import {tanh} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testTanh(tanh) { 4 | assert.equal(0, tanh(0)); 5 | assert.equal(-0, tanh(-0)); 6 | assert.equal(1, tanh(Infinity)); 7 | assert.equal(-1, tanh(-Infinity)); 8 | } 9 | 10 | testTanh(tanh); 11 | testTanh(Math.tanh); 12 | -------------------------------------------------------------------------------- /test/feature/Math/trunc.js: -------------------------------------------------------------------------------- 1 | import {trunc} from '../../../src/runtime/polyfills/Math.js'; 2 | 3 | function testTrunc(trunc) { 4 | assert.equal(0, trunc(0)); 5 | assert.equal(-0, trunc(-0)); 6 | assert.equal(Infinity, trunc(Infinity)); 7 | assert.equal(-Infinity, trunc(-Infinity)); 8 | assert.equal(42, trunc(42)); 9 | assert.equal(2, trunc(2.5)); 10 | assert.equal(-2, trunc(-2.5)); 11 | } 12 | 13 | testTrunc(trunc); 14 | testTrunc(Math.trunc); 15 | -------------------------------------------------------------------------------- /test/feature/MemberVariables/Error_ChildNoCtor.js: -------------------------------------------------------------------------------- 1 | // Options: --member-variables --types 2 | // Error: :8:3: Derived constructor must call super() 3 | 4 | class A { 5 | } 6 | 7 | class C extends A { 8 | constructor() { 9 | // "super()" is required in derived class 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/feature/MemberVariables/Error_ChildSuperNotFirst.js: -------------------------------------------------------------------------------- 1 | // Options: --member-variables --types 2 | // Error: :10:5: 'this' is not allowed before super() 3 | 4 | class A { 5 | } 6 | 7 | class C extends A { 8 | shouldFail: boolean = true; 9 | constructor() { 10 | this.value = 5; 11 | // super() should be first when a derived class contains initialized 12 | // instance variable 13 | super(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/feature/MemberVariables/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Error: :4:4: Unexpected token : 2 | 3 | class C { 4 | x: number; 5 | } 6 | -------------------------------------------------------------------------------- /test/feature/MemberVariables/InitializersEvaluation.js: -------------------------------------------------------------------------------- 1 | // Options: --member-variables --types 2 | 3 | var globalValue = 0; 4 | 5 | class A { 6 | instanceValue: number = globalValue; 7 | } 8 | 9 | var a0 = new A(); 10 | globalValue++; 11 | var a1 = new A(); 12 | 13 | assert.equal(a0.instanceValue, 0); 14 | assert.equal(a1.instanceValue, 1); 15 | -------------------------------------------------------------------------------- /test/feature/Modules/DefaultLiveBinding.js: -------------------------------------------------------------------------------- 1 | import * as m from './resources/default-live.js'; 2 | 3 | assert.equal(m.default(), 1); 4 | m.changeDefault(); 5 | assert.equal(m.default, 2); 6 | -------------------------------------------------------------------------------- /test/feature/Modules/EmptyNamedImport.js: -------------------------------------------------------------------------------- 1 | import {} from './resources/m.js'; 2 | -------------------------------------------------------------------------------- /test/feature/Modules/Error_ExportIdentifier.js: -------------------------------------------------------------------------------- 1 | // Error: :4:8: Unexpected token x 2 | // Error: :5:8: Unexpected token y 3 | 4 | export x; 5 | export y = z; 6 | -------------------------------------------------------------------------------- /test/feature/Modules/Error_ExportKeyword.js: -------------------------------------------------------------------------------- 1 | // Error: :3:9: Unexpected token if 2 | 3 | export {if}; 4 | -------------------------------------------------------------------------------- /test/feature/Modules/Error_ExportKeyword2.js: -------------------------------------------------------------------------------- 1 | // Error: :3:9: Unexpected token if 2 | 3 | export {if as x}; 4 | -------------------------------------------------------------------------------- /test/feature/Modules/Error_ExportStarConflict.js: -------------------------------------------------------------------------------- 1 | // Error: test/feature/Modules/resources/export-conflict.js:2:8: Duplicate export. 'a' was previously exported at test/feature/Modules/resources/export-conflict.js:1:12 2 | 3 | import {a} from './resources/export-conflict.js'; 4 | -------------------------------------------------------------------------------- /test/feature/Modules/Error_ExportStarDuplicateExport.js: -------------------------------------------------------------------------------- 1 | // Error: test/feature/Modules/Error_ExportStarDuplicateExport.js:4:8: Duplicate export. 'a' was previously exported at test/feature/Modules/Error_ExportStarDuplicateExport.js:3:8 2 | 3 | export * from './resources/a.js'; 4 | export * from './resources/a2.js'; 5 | 6 | assert.equal(1, 2); 7 | -------------------------------------------------------------------------------- /test/feature/Modules/Error_ImportDefault.js: -------------------------------------------------------------------------------- 1 | // Error: test/feature/Modules/Error_ImportDefault.js:3:8: 'default' is not exported by 'test/feature/Modules/resources/a.js' 2 | 3 | import error from './resources/a.js'; 4 | -------------------------------------------------------------------------------- /test/feature/Modules/Error_ImportStar.js: -------------------------------------------------------------------------------- 1 | // Error: :3:10: Unexpected token from 2 | 3 | import * from './resources/m.js'; 4 | assert.equal(3, a + b); 5 | -------------------------------------------------------------------------------- /test/feature/Modules/Error_ImportType.js: -------------------------------------------------------------------------------- 1 | // Options: --types 2 | // Error: :4:14: 'missing' is not exported by 'test/feature/Modules/resources/default-and-named-type.js' 3 | 4 | import type {missing} from './resources/default-and-named-type.js'; 5 | -------------------------------------------------------------------------------- /test/feature/Modules/Error_ImportTypeNoDefault.js: -------------------------------------------------------------------------------- 1 | // Options: --types 2 | // Error: :4:13: 'default' is not exported by 'test/feature/Modules/resources/named-type.js' 3 | 4 | import type missing from './resources/named-type.js'; 5 | -------------------------------------------------------------------------------- /test/feature/Modules/Error_InvalidExport.js: -------------------------------------------------------------------------------- 1 | // Error: :3:9: 'c' is not exported by 'test/feature/Modules/resources/a.js' 2 | 3 | export {c} from './resources/a.js'; 4 | -------------------------------------------------------------------------------- /test/feature/Modules/Error_InvalidExport2.js: -------------------------------------------------------------------------------- 1 | // Error: :3:9: 'c' is not exported by 'test/feature/Modules/resources/a.js' 2 | 3 | export {c as d} from './resources/a.js'; 4 | -------------------------------------------------------------------------------- /test/feature/Modules/Error_InvalidExport3.js: -------------------------------------------------------------------------------- 1 | // Error: test/feature/Modules/Error_InvalidExport3.js:3:9: 'c' is not exported by 'test/feature/Modules/resources/b.js' 2 | 3 | export {c as d} from './resources/b.js'; 4 | -------------------------------------------------------------------------------- /test/feature/Modules/Error_InvalidModuleDeclaration.js: -------------------------------------------------------------------------------- 1 | // Error: 'test/feature/Modules/resources/no_such_file.js' 2 | // Error: Specified as ./resources/no_such_file.js. 3 | // Error: Imported by test/feature/Modules/Error_InvalidModuleDeclaration.js. 4 | // Error: Normalizes to test/feature/Modules/resources/no_such_file.js 5 | // Error: locate resolved against base 6 | 7 | import * as b from './resources/no_such_file.js'; 8 | -------------------------------------------------------------------------------- /test/feature/Modules/Error_InvalidModuleDeclaration2.js: -------------------------------------------------------------------------------- 1 | // Error: 3:38: Unexpected token . 2 | 3 | import * as b from './resources/a.js'.c; -------------------------------------------------------------------------------- /test/feature/Modules/Error_MissingExport.js: -------------------------------------------------------------------------------- 1 | // Error: :5:12: 'y' is not exported by 'test/feature/Modules/resources/x.js' 2 | // Error: :5:15: 'z' is not exported by 'test/feature/Modules/resources/x.js' 3 | // Error: :6:9: 'w' is not exported by 'test/feature/Modules/resources/x.js' 4 | 5 | import {x, y, z} from './resources/x.js'; 6 | import {w} from './resources/x.js'; 7 | 8 | -------------------------------------------------------------------------------- /test/feature/Modules/ExportDestructuring.js: -------------------------------------------------------------------------------- 1 | import {x, y} from './resources/export-destructuring.js'; 2 | 3 | assert.equal(x, 1); 4 | assert.equal(y, 2); 5 | -------------------------------------------------------------------------------- /test/feature/Modules/ExportForwardDefault.js: -------------------------------------------------------------------------------- 1 | // Options: --export-from-extended 2 | 3 | import {a, b, default as C} from './resources/export-forward-default-as.js'; 4 | import {new as n} from './resources/export-extended-keyword.js'; 5 | 6 | assert.equal(42, a); 7 | assert.equal(123, b()); 8 | assert.equal('m', new C().m()); 9 | assert.equal('default', n); 10 | -------------------------------------------------------------------------------- /test/feature/Modules/ExportStar.js: -------------------------------------------------------------------------------- 1 | import * as o from './resources/o.js'; 2 | 3 | assert.equal(1, o.a); 4 | assert.equal(2, o.b); 5 | assert.equal(3, o.c); 6 | assert.equal(4, o.d); 7 | assert.equal(undefined, o.default); -------------------------------------------------------------------------------- /test/feature/Modules/ExportStarAs.js: -------------------------------------------------------------------------------- 1 | import {a, b} from './resources/export-star-as.js'; 2 | 3 | assert.equal(1, a.a); 4 | assert.equal(2, a.b); 5 | assert.equal(3, b.c); 6 | assert.equal(4, b.d); 7 | -------------------------------------------------------------------------------- /test/feature/Modules/Exports.js: -------------------------------------------------------------------------------- 1 | import * as a from './resources/i.js'; 2 | 3 | (function() { 4 | 'use strict'; 5 | assert.equal(0, a.i); 6 | a.inc(); 7 | assert.equal(1, a.i); 8 | 9 | assert.throws(function() { 10 | a.i = 2; 11 | }, TypeError); 12 | })(); 13 | 14 | assert.equal(1, a.i); 15 | 16 | import * as d from './resources/d.js'; 17 | assert.equal('A', d.a); 18 | -------------------------------------------------------------------------------- /test/feature/Modules/ImportAsExportAs.js: -------------------------------------------------------------------------------- 1 | import * as m from './resources/m3.js'; 2 | assert.equal(m.x, 'z'); 3 | -------------------------------------------------------------------------------- /test/feature/Modules/ImportBasic.js: -------------------------------------------------------------------------------- 1 | import {p} from './resources/p.js'; 2 | assert.equal('P', p); 3 | assert(typeof q === 'undefined'); 4 | -------------------------------------------------------------------------------- /test/feature/Modules/ImportCircular.js: -------------------------------------------------------------------------------- 1 | // Error: Unsupported circular dependency between test/feature/Modules/ImportCircular.js and test/feature/Modules/resources/clockwise.js 2 | 3 | import {clockwise} from './resources/clockwise.js'; 4 | export function counterclockwise() { 5 | return clockwise(); 6 | } 7 | -------------------------------------------------------------------------------- /test/feature/Modules/ImportEmptyImportClause.js: -------------------------------------------------------------------------------- 1 | import object from './resources/object-for-side-effects.js'; 2 | object.sideEffect = 1; 3 | import {} from './resources/side-effect2.js'; 4 | assert.equal(2, object.sideEffect); 5 | object.sideEffect = 1; 6 | -------------------------------------------------------------------------------- /test/feature/Modules/ImportNoImportClause.js: -------------------------------------------------------------------------------- 1 | import object from './resources/object-for-side-effects.js'; 2 | object.sideEffect = 1; 3 | import './resources/side-effect.js'; 4 | assert.equal(2, object.sideEffect); 5 | object.sideEffect = 1; 6 | -------------------------------------------------------------------------------- /test/feature/Modules/ImportPair.js: -------------------------------------------------------------------------------- 1 | import def, * as m from './resources/default-and-named.js'; 2 | import def2, {x} from './resources/default-and-named.js'; 3 | import def3, {x as y} from './resources/default-and-named.js'; 4 | 5 | assert.equal(def, 'default'); 6 | assert.equal(def2, 'default'); 7 | assert.equal(def3, 'default'); 8 | 9 | assert.equal(x, 'x'); 10 | assert.equal(y, 'x'); 11 | -------------------------------------------------------------------------------- /test/feature/Modules/ImportReExportDefault.js: -------------------------------------------------------------------------------- 1 | import x from './resources/re-export-default.js'; 2 | assert.equal(x, 42); 3 | -------------------------------------------------------------------------------- /test/feature/Modules/ImportReExportDefaultAs.js: -------------------------------------------------------------------------------- 1 | import {x} from './resources/re-export-default-as.js'; 2 | assert.equal(x, 42); 3 | -------------------------------------------------------------------------------- /test/feature/Modules/ImportType.js: -------------------------------------------------------------------------------- 1 | // Options: --types 2 | 3 | import type {y} from './resources/named-type.js'; 4 | import type def, {x} from './resources/default-and-named-type.js'; 5 | -------------------------------------------------------------------------------- /test/feature/Modules/ModuleDefault.js: -------------------------------------------------------------------------------- 1 | import * as m from './resources/default.js'; 2 | 3 | assert.equal(m.default, 42); 4 | -------------------------------------------------------------------------------- /test/feature/Modules/ModuleName.js: -------------------------------------------------------------------------------- 1 | var re = /([^\s']+?)(?=test(?:[\/\\])feature(?:[\/\\]))/g; 2 | 3 | assert.equal(__moduleName.replace(re, ''), 'test/feature/Modules/ModuleName.js'); 4 | -------------------------------------------------------------------------------- /test/feature/Modules/ModuleObjectFromDestructuring.js: -------------------------------------------------------------------------------- 1 | import * as m from './resources/export-destructuring.js'; 2 | 3 | assert.deepEqual(['x', 'y'], Object.keys(m).sort()); 4 | -------------------------------------------------------------------------------- /test/feature/Modules/StaticMethod.js: -------------------------------------------------------------------------------- 1 | import {TestClass} from './resources/TestClass.js'; 2 | assert.equal(TestClass.method(), 42); 3 | -------------------------------------------------------------------------------- /test/feature/Modules/ThisInModules.js: -------------------------------------------------------------------------------- 1 | var topLevelThis = this; 2 | 3 | import * as m from './resources/f.js'; 4 | assert.equal(topLevelThis, m.f()); 5 | assert.equal(undefined, topLevelThis); 6 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/TestClass.js: -------------------------------------------------------------------------------- 1 | export class TestClass { 2 | static method() { 3 | return 42; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/a.js: -------------------------------------------------------------------------------- 1 | export var a = 'A'; 2 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/a2.js: -------------------------------------------------------------------------------- 1 | export var a = 'A2'; 2 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/b.js: -------------------------------------------------------------------------------- 1 | import * as c from './c.js'; 2 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/c.js: -------------------------------------------------------------------------------- 1 | export var c = 'C'; 2 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/clockwise.js: -------------------------------------------------------------------------------- 1 | import {counterclockwise} from '../ImportCircular.js'; 2 | export function clockwise() { 3 | return 'The circle is complete'; 4 | } 5 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/d.js: -------------------------------------------------------------------------------- 1 | export * from './a.js'; 2 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/default-and-named-type.js: -------------------------------------------------------------------------------- 1 | type T = string; 2 | export default T; 3 | export type x = number; 4 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/default-and-named.js: -------------------------------------------------------------------------------- 1 | export default 'default'; 2 | export var x = 'x'; 3 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/default-class-expression.js: -------------------------------------------------------------------------------- 1 | export default class { 2 | n() { 3 | return 'n'; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/default-class.js: -------------------------------------------------------------------------------- 1 | import {assert} from '../../../asserts.js'; 2 | 3 | export default class C { 4 | m() { 5 | return 'm'; 6 | } 7 | } 8 | 9 | assert.instanceOf(C, Function); 10 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/default-function-expression.js: -------------------------------------------------------------------------------- 1 | export default function() { 2 | return 456; 3 | } 4 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/default-function.js: -------------------------------------------------------------------------------- 1 | import {assert} from '../../../asserts.js'; 2 | 3 | export default function f() { 4 | return 123; 5 | } 6 | 7 | assert.instanceOf(f, Function); 8 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/default-live.js: -------------------------------------------------------------------------------- 1 | export default function f() { 2 | return 1; 3 | } 4 | 5 | export function changeDefault() { 6 | f = 2; 7 | } 8 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/default-name.js: -------------------------------------------------------------------------------- 1 | var p = 4; 2 | export {p as default}; 3 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/default.js: -------------------------------------------------------------------------------- 1 | export default 42; 2 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/export-conflict.js: -------------------------------------------------------------------------------- 1 | export var a = 'a'; 2 | export * from './a.js'; // also exports a 3 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/export-destructuring.js: -------------------------------------------------------------------------------- 1 | export var {x, y = 2} = {x: 1}; 2 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/export-extended-keyword.js: -------------------------------------------------------------------------------- 1 | export new from './default-and-named.js'; 2 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/export-forward-default-as.js: -------------------------------------------------------------------------------- 1 | export a from './default.js'; 2 | export b from './default-function.js'; 3 | export default from './default-class.js'; 4 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/export-star-as.js: -------------------------------------------------------------------------------- 1 | export * as a from './m.js'; 2 | export * as b from './n.js'; 3 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/f.js: -------------------------------------------------------------------------------- 1 | export var f = () => this; 2 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/i.js: -------------------------------------------------------------------------------- 1 | export var i = 0; 2 | export function inc() { 3 | i++; 4 | } 5 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/m.js: -------------------------------------------------------------------------------- 1 | export var a = 1; 2 | export var b = 2; 3 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/m2.js: -------------------------------------------------------------------------------- 1 | var z = 'z'; 2 | export {z as var}; 3 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/m3.js: -------------------------------------------------------------------------------- 1 | import {var as x} from './m2.js'; 2 | export {x}; 3 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/n.js: -------------------------------------------------------------------------------- 1 | export var c = 3; 2 | export var d = 4; 3 | export default 5; 4 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/named-type.js: -------------------------------------------------------------------------------- 1 | export type y = number; 2 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/o.js: -------------------------------------------------------------------------------- 1 | export * from './m.js'; 2 | export * from './n.js'; 3 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/object-for-side-effects.js: -------------------------------------------------------------------------------- 1 | const object = {}; 2 | export {object as default}; 3 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/p.js: -------------------------------------------------------------------------------- 1 | export var p = 'P'; 2 | export var q = 'Q'; 3 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/re-export-default-as.js: -------------------------------------------------------------------------------- 1 | export {default as x} from './default.js'; 2 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/re-export-default.js: -------------------------------------------------------------------------------- 1 | export {default} from './default.js'; 2 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/side-effect.js: -------------------------------------------------------------------------------- 1 | import object from './object-for-side-effects.js'; 2 | object.sideEffect++; 3 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/side-effect2.js: -------------------------------------------------------------------------------- 1 | import object from './object-for-side-effects.js'; 2 | object.sideEffect++; 3 | -------------------------------------------------------------------------------- /test/feature/Modules/resources/x.js: -------------------------------------------------------------------------------- 1 | export var x = 'X'; 2 | -------------------------------------------------------------------------------- /test/feature/Number/EPSILON.js: -------------------------------------------------------------------------------- 1 | import {EPSILON} from '../../../src/runtime/polyfills/Number.js'; 2 | 3 | function testEpsilon(epsilon) { 4 | assert.equal(epsilon, Math.pow(2, -52)); 5 | assert.equal(1 + epsilon - 1, epsilon); 6 | assert.equal(1 + epsilon / 2 - 1, 0); 7 | } 8 | 9 | testEpsilon(EPSILON); 10 | testEpsilon(Number.EPSILON); 11 | -------------------------------------------------------------------------------- /test/feature/Number/MAX_SAFE_INTEGER.js: -------------------------------------------------------------------------------- 1 | import {MAX_SAFE_INTEGER} from '../../../src/runtime/polyfills/Number.js'; 2 | 3 | assert.equal(MAX_SAFE_INTEGER, Math.pow(2, 53) - 1); 4 | assert.equal(Number.MAX_SAFE_INTEGER, Math.pow(2, 53) - 1); 5 | -------------------------------------------------------------------------------- /test/feature/Number/MIN_SAFE_INTEGER.js: -------------------------------------------------------------------------------- 1 | import {MIN_SAFE_INTEGER} from '../../../src/runtime/polyfills/Number.js'; 2 | 3 | assert.equal(MIN_SAFE_INTEGER, -Math.pow(2, 53) + 1); 4 | assert.equal(Number.MIN_SAFE_INTEGER, -Math.pow(2, 53) + 1); 5 | -------------------------------------------------------------------------------- /test/feature/NumericLiteral/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Options: --numeric-literals=false 2 | // Error: :4:2: Semi-colon expected 3 | 4 | 0b11; 5 | -------------------------------------------------------------------------------- /test/feature/NumericLiteral/Error_NoBinaryDigits.js: -------------------------------------------------------------------------------- 1 | // Options: --numeric-literals 2 | // Error: :4:1: Binary Integer Literal must contain at least one digit 3 | 4 | 0b; 5 | -------------------------------------------------------------------------------- /test/feature/NumericLiteral/Error_NoOctalDigits.js: -------------------------------------------------------------------------------- 1 | // Options: --numeric-literals 2 | // Error: :4:1: Octal Integer Literal must contain at least one digit 3 | 4 | 0o; 5 | -------------------------------------------------------------------------------- /test/feature/ObjectInitializerShorthand/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Options: --property-name-shorthand=false 2 | // Error: :5:16: Unexpected token x 3 | 4 | var x = 42; 5 | var object = {x}; 6 | -------------------------------------------------------------------------------- /test/feature/ObjectInitializerShorthand/Error_Keyword.js: -------------------------------------------------------------------------------- 1 | // Error: :3:18: Unexpected token var 2 | 3 | var object = {var}; 4 | -------------------------------------------------------------------------------- /test/feature/ObjectInitializerShorthand/Error_MissingVar.js: -------------------------------------------------------------------------------- 1 | // Error: missingVarObjectInitializerShorthand is not defined 2 | 3 | var object = {missingVarObjectInitializerShorthand}; 4 | -------------------------------------------------------------------------------- /test/feature/ObjectInitializerShorthand/Error_StrictKeyword.js: -------------------------------------------------------------------------------- 1 | // Error: :6:11: implements is a reserved identifier 2 | // Error: :11:11: yield is a reserved identifier 3 | 4 | function f() { 5 | 'use strict'; 6 | return {implements}; 7 | } 8 | 9 | function g() { 10 | 'use strict'; 11 | return {yield}; 12 | } 13 | -------------------------------------------------------------------------------- /test/feature/ObjectInitializerShorthand/Ok.js: -------------------------------------------------------------------------------- 1 | var x = 42; 2 | var y = 43; 3 | var object = {x, y}; 4 | 5 | // ---------------------------------------------------------------------------- 6 | 7 | assert.equal(42, object.x); 8 | assert.equal(43, object.y); 9 | -------------------------------------------------------------------------------- /test/feature/ObjectInitializerShorthand/StrictKeyword.script.js: -------------------------------------------------------------------------------- 1 | // This only tests the parsing. 2 | 3 | function f() { 4 | return {implements}; 5 | } 6 | 7 | function f2() { 8 | return {yield}; 9 | } 10 | 11 | function* g() { 12 | 'use strict'; 13 | return {yield}; 14 | } 15 | -------------------------------------------------------------------------------- /test/feature/ObjectMixin.js: -------------------------------------------------------------------------------- 1 | var target = {a: 0, b: 2}; 2 | var source = {a: 1, c: 3, get d() { return this.b || this.a + 64; }}; 3 | var mixed = Object.mixin(target, source); 4 | 5 | // ---------------------------------------------------------------------------- 6 | 7 | assert.isTrue(Object.hasOwnProperty("mixin")); 8 | assert.equal(mixed.a, source.a); 9 | assert.equal(mixed.b, target.b); 10 | assert.equal(mixed.c, source.c); 11 | assert.notEqual(mixed.d, source.d); 12 | -------------------------------------------------------------------------------- /test/feature/PrependStatement.js: -------------------------------------------------------------------------------- 1 | var count = 0; 2 | var o = { 3 | get x() { 4 | count++; 5 | return 1; 6 | } 7 | }; 8 | 9 | function f({x}) {} 10 | f(o); 11 | assert.equal(1, count); 12 | 13 | count = 0; 14 | function g({x}) { 15 | 'use strict'; 16 | } 17 | g(o); 18 | assert.equal(1, count); 19 | -------------------------------------------------------------------------------- /test/feature/Promise.js: -------------------------------------------------------------------------------- 1 | // Async. 2 | 3 | var p = new Promise((resolve, reject) => { 4 | resolve(42); 5 | }); 6 | p.then((v) => { 7 | assert.equal(v, 42); 8 | done(); 9 | }); 10 | -------------------------------------------------------------------------------- /test/feature/PromiseAll.js: -------------------------------------------------------------------------------- 1 | // Skip. 2 | // Async. 3 | 4 | // V8 does not yet support iterable argument to Promise.all. 5 | // https://code.google.com/p/v8/issues/detail?id=3705 6 | 7 | function* gen() { 8 | yield 1; 9 | yield 2; 10 | } 11 | 12 | var p2 = Promise.all(gen()); 13 | 14 | p2.then((v) => { 15 | assert.deepEqual(v, [1,2]); 16 | done(); 17 | }); 18 | -------------------------------------------------------------------------------- /test/feature/PromiseResolve.js: -------------------------------------------------------------------------------- 1 | var p = Promise.resolve(42); 2 | 3 | assert.equal(p, Promise.resolve(p)); 4 | -------------------------------------------------------------------------------- /test/feature/ProperTailCalls/Native.js: -------------------------------------------------------------------------------- 1 | // Options: --proper-tail-calls 2 | 3 | var count = 0; 4 | 5 | [1, 2, 3].forEach(function (n) { 6 | count += n; 7 | }); 8 | 9 | assert.equal(count, 6); 10 | 11 | -------------------------------------------------------------------------------- /test/feature/ProperTailCalls/This.js: -------------------------------------------------------------------------------- 1 | // Options: --proper-tail-calls 2 | 3 | class C { 4 | constructor(x) { 5 | this.x = x; 6 | } 7 | getX() { 8 | return this.x; 9 | } 10 | } 11 | 12 | var o = new C(42); 13 | 14 | assert.equal(o.getX(), 42); 15 | 16 | -------------------------------------------------------------------------------- /test/feature/PropertyMethodAssignment/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Options: --property-methods=false 2 | // Error: :5:9: Unexpected token ( 3 | 4 | var object = { 5 | method() { 6 | return 42; 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /test/feature/PropertyMethodAssignment/Error_NotNamed.js: -------------------------------------------------------------------------------- 1 | assert.throws(() => { 2 | var object = { 3 | "notNamedField"() { 4 | return notNamedField; 5 | } 6 | }; 7 | object.notNamedField(); 8 | }, ReferenceError); 9 | -------------------------------------------------------------------------------- /test/feature/PureES6Transformer/Basic.js: -------------------------------------------------------------------------------- 1 | // Options: --output-language=es6 2 | // Ironically enough we can't use es6 in this test as node can't eval it. 3 | function foo() {} -------------------------------------------------------------------------------- /test/feature/Rest/Error_NotLast.js: -------------------------------------------------------------------------------- 1 | // Error: :3:46: Unexpected token , 2 | 3 | function invalidParam(noDefault, ...restParam, noRestAgain) { 4 | // Should fail to parse since non rest param is not allowed after 5 | // param. 6 | } -------------------------------------------------------------------------------- /test/feature/Rest/Error_SetAccessor.js: -------------------------------------------------------------------------------- 1 | // Error: :4:9: Unexpected token ... 2 | 3 | var object = { 4 | set x(...rest) { 5 | // rest is not allowed for set accessor 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /test/feature/Rest/Simple.js: -------------------------------------------------------------------------------- 1 | function f(...p) { 2 | return p; 3 | } 4 | 5 | function g(a, ...p) { 6 | return p; 7 | } 8 | 9 | assert.deepEqual([], f()); 10 | assert.deepEqual([0], f(0)); 11 | assert.deepEqual([0, 1], f(0, 1)); 12 | 13 | assert.deepEqual([], g()); 14 | assert.deepEqual([], g(0)); 15 | assert.deepEqual([1], g(0, 1)); 16 | assert.deepEqual([1, 2], g(0, 1, 2)); 17 | -------------------------------------------------------------------------------- /test/feature/Rest/Strict.js: -------------------------------------------------------------------------------- 1 | function f(...xs) { 2 | 'use strict'; 3 | return this; 4 | } 5 | 6 | assert.isUndefined(f()); -------------------------------------------------------------------------------- /test/feature/Scope/BlockBinding10.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | function f() { 4 | return 'outer'; 5 | } 6 | 7 | { 8 | var f = function f() { 9 | return 'inner'; 10 | }; 11 | 12 | assert.equal('inner', f()); 13 | } 14 | 15 | assert.equal('inner', f()); 16 | -------------------------------------------------------------------------------- /test/feature/Scope/BlockBinding2.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | let result = []; 4 | let obj = {a : 'hello a', b : 'hello b', c : 'hello c' }; 5 | for (let x in obj) { 6 | result.push( 7 | function() { return obj[x]; } 8 | ); 9 | } 10 | 11 | // ---------------------------------------------------------------------------- 12 | 13 | assert.equal('hello a', result[0]()); 14 | assert.equal('hello b', result[1]()); 15 | assert.equal('hello c', result[2]()); 16 | -------------------------------------------------------------------------------- /test/feature/Scope/BlockBinding3.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | var f1, f2; 4 | 5 | { 6 | let z = 'z1 value'; 7 | f1 = function() { return z; }; 8 | } 9 | { 10 | let z = 'z2 value'; 11 | f2 = function() { return z; }; 12 | } 13 | 14 | // ---------------------------------------------------------------------------- 15 | 16 | assert.equal('z1 value', f1()); 17 | assert.equal('z2 value', f2()); 18 | -------------------------------------------------------------------------------- /test/feature/Scope/BlockBinding4.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | let result = []; 4 | for (let a = 1; a < 3; a++) { 5 | result.push( 6 | function() { return 'for ' + a; } 7 | ); 8 | } 9 | 10 | // ---------------------------------------------------------------------------- 11 | 12 | assert.equal('for 1', result[0]()); 13 | assert.equal('for 2', result[1]()); 14 | assert.equal(2, result.length); 15 | -------------------------------------------------------------------------------- /test/feature/Scope/BlockBinding6.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | function testBlock() { 4 | // Test function expressions. 5 | { 6 | var x = function g() { return 'g'; } || function h() { return 'h'; }; 7 | return x; 8 | } 9 | } 10 | 11 | // ---------------------------------------------------------------------------- 12 | 13 | var result = testBlock(); 14 | assert.equal('g', result()); 15 | -------------------------------------------------------------------------------- /test/feature/Scope/BlockBinding7.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | function blockTest() { 4 | { 5 | let x = 'let x value'; 6 | function g() { 7 | return x; 8 | } 9 | return g; 10 | } 11 | } 12 | 13 | // ---------------------------------------------------------------------------- 14 | 15 | assert.equal('let x value', blockTest()()); 16 | -------------------------------------------------------------------------------- /test/feature/Scope/BlockBinding8.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | function f() { 4 | return 'outer'; 5 | } 6 | 7 | { 8 | function f() { 9 | return 'inner'; 10 | } 11 | 12 | assert.equal('inner', f()); 13 | } 14 | 15 | assert.equal('outer', f()); 16 | -------------------------------------------------------------------------------- /test/feature/Scope/BlockBinding9.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | function f() { 4 | return 'outer'; 5 | } 6 | 7 | { 8 | (function f() { 9 | return 'inner'; 10 | }); 11 | 12 | assert.equal('outer', f()); 13 | } 14 | 15 | assert.equal('outer', f()); 16 | -------------------------------------------------------------------------------- /test/feature/Scope/BlockBindingHiddenOuterLet.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | // See issue #1671. Pass if no exception 4 | let c; 5 | 6 | function f(c) { 7 | var p; 8 | for (p of g(() => c)); 9 | } -------------------------------------------------------------------------------- /test/feature/Scope/BlockBindingSiblingRefenceError.js: -------------------------------------------------------------------------------- 1 | assert.throws(() => { 2 | { 3 | let inner = 'inner value'; 4 | } 5 | var x = inner; 6 | }, ReferenceError); 7 | -------------------------------------------------------------------------------- /test/feature/Scope/DeconstructingBlockBinding.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | if (true) { 4 | let [a,b] = [1,2]; 5 | const [c,d] = [4,5]; 6 | } 7 | if (true) { 8 | let {x: [{e}, f], g} = {x: [{e:4}, 5], g: 6}; 9 | const a = 0, [b, {c, x: [d]}] = [1, {c: 2, x: [3]}]; 10 | } 11 | 12 | // ---------------------------------------------------------------------------- 13 | -------------------------------------------------------------------------------- /test/feature/Scope/DeepNestedLet.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | var a = 'var a'; 4 | { 5 | var b = 'var b'; 6 | { 7 | var c = 'var c'; 8 | let d = 'let d'; 9 | } 10 | } 11 | 12 | // ---------------------------------------------------------------------------- 13 | -------------------------------------------------------------------------------- /test/feature/Scope/DeepNestedLetConst.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | var a = 'var a'; 4 | { 5 | var b = 'var b'; 6 | { 7 | let c = 'let c'; 8 | { 9 | const d = 'const d'; 10 | } 11 | } 12 | } 13 | 14 | // ---------------------------------------------------------------------------- 15 | -------------------------------------------------------------------------------- /test/feature/Scope/DeepNestedLetVar.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | var a = 'var a'; 4 | { 5 | var b = 'var b'; 6 | { 7 | let c = 'let c'; 8 | { 9 | var d = 'var d'; 10 | } 11 | } 12 | } 13 | 14 | // ---------------------------------------------------------------------------- 15 | -------------------------------------------------------------------------------- /test/feature/Scope/DeepNestedLetVarNoInit.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | var var_a; 4 | { 5 | var var_b; 6 | { 7 | let let_c = 'let c'; 8 | { 9 | var var_d; 10 | } 11 | } 12 | } 13 | 14 | // ---------------------------------------------------------------------------- 15 | -------------------------------------------------------------------------------- /test/feature/Scope/Error_ConstMissingInitializer.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: :4:14: const variables must have an initializer 3 | 4 | const x = 1, y; 5 | -------------------------------------------------------------------------------- /test/feature/Scope/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding=false 2 | // Error: :5:3: Unexpected reserved word let 3 | 4 | { 5 | let x = 42; 6 | } 7 | -------------------------------------------------------------------------------- /test/feature/Scope/Error_Duplicate.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: :8:9: Duplicate declaration, f 3 | 4 | (function f() { 5 | 'use strict'; 6 | { 7 | var f; 8 | let f; 9 | } 10 | })(); 11 | -------------------------------------------------------------------------------- /test/feature/Scope/Error_ForInWithInitializerConst.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: :4:18: Unexpected token in 3 | 4 | for (const i = 0 in {}) { 5 | } 6 | -------------------------------------------------------------------------------- /test/feature/Scope/Error_ForInWithInitializerLet.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: :4:16: Unexpected token in 3 | 4 | for (let i = 0 in {}) { 5 | } 6 | -------------------------------------------------------------------------------- /test/feature/Scope/Error_ForInWithInitializerVar.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: :7:22: Unexpected token in 3 | 4 | var x = 0; 5 | 6 | // ES6 does not allow this. 7 | for (var i = (x = 1) in {}) { 8 | } 9 | 10 | assert.equal(1, x); 11 | -------------------------------------------------------------------------------- /test/feature/Scope/Error_ForOfWithInitializerConst.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: :8:18: Unexpected token of 3 | 4 | function* gen() { 5 | yield 1; 6 | } 7 | 8 | for (const i = 0 of gen()) { 9 | } 10 | -------------------------------------------------------------------------------- /test/feature/Scope/Error_ForOfWithInitializerLet.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: :8:16: Unexpected token of 3 | 4 | function* gen() { 5 | yield 1; 6 | } 7 | 8 | for (let i = 0 of gen()) { 9 | } 10 | -------------------------------------------------------------------------------- /test/feature/Scope/Error_ForOfWithInitializerVar.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: :8:16: Unexpected token of 3 | 4 | function* gen() { 5 | yield 1; 6 | } 7 | 8 | for (var i = 0 of gen()) { 9 | } 10 | -------------------------------------------------------------------------------- /test/feature/Scope/Error_ForWithoutInitializerConst.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: :5:12: const variables must have an initializer 3 | 4 | var i = 0; 5 | for (const x; i < 3; i++) { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /test/feature/Scope/Error_FunctionExpressionInBlock.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: functionExpression is not defined 3 | 4 | { 5 | (function functionExpression() { 6 | return 'inner'; 7 | }); 8 | 9 | functionExpression; // function expression doesn't add name to the scope. 10 | } 11 | -------------------------------------------------------------------------------- /test/feature/Scope/Error_FunctionExpressionNameShadowing.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: :8:9: Duplicate declaration, y 3 | 4 | var x = function y() { 5 | 'use strict'; 6 | const y = 1; 7 | { 8 | var y = 2; 9 | return y; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/feature/Scope/ForInInitializers.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | (function() { 4 | var y; 5 | for (var x in {a: 'A'}) { 6 | assert.equal(x, 'a'); 7 | y = x; 8 | } 9 | assert.equal(y, 'a'); 10 | })(); 11 | -------------------------------------------------------------------------------- /test/feature/Scope/FunctionExpressionNameShadowing.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | var x = function y() { 4 | 'use strict'; 5 | var y = 1; 6 | return y; 7 | } 8 | 9 | assert.equal(x(), 1); 10 | 11 | var z = function y() { 12 | 'use strict'; 13 | let y = 2; 14 | return y; 15 | } 16 | 17 | assert.equal(z(), 2); 18 | 19 | var w = function y() { 20 | 'use strict'; 21 | let y = 3; 22 | return y; 23 | } 24 | 25 | assert.equal(w(), 3); 26 | -------------------------------------------------------------------------------- /test/feature/Scope/FunctionInBlock.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | var x = 1; 4 | { 5 | function f() { 6 | x = 2; 7 | } 8 | 9 | if (false) {} 10 | 11 | f(); 12 | } 13 | assert.equal(2, x); 14 | })(); 15 | -------------------------------------------------------------------------------- /test/feature/Scope/LetForInitializers1.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | var result; 4 | { 5 | let let_x = 'let x'; 6 | let let_l = []; 7 | for (var var_x = 1, var_y = 2, var_z = 3; var_x < 10; var_x ++) { 8 | let l_x = var_x, l_y = var_y, l_z = var_z; 9 | let_l.push( function() { return [ l_x, l_y, l_z ]; } ); 10 | } 11 | result = let_l; 12 | } 13 | 14 | // ---------------------------------------------------------------------------- 15 | -------------------------------------------------------------------------------- /test/feature/Scope/LetInClass.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | class LetInClass { 4 | get z() { 5 | let let_z = 10; 6 | return let_z; 7 | } 8 | 9 | set z(v) { 10 | let let_zv = v; 11 | } 12 | 13 | distance() { 14 | let dist = this.y - this.x; 15 | return dist; 16 | } 17 | } 18 | 19 | // ---------------------------------------------------------------------------- 20 | -------------------------------------------------------------------------------- /test/feature/Scope/LetInFor.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | for (var x = 0; x < 10; x ++) { 4 | let y = 'let y'; 5 | } 6 | 7 | // ---------------------------------------------------------------------------- 8 | -------------------------------------------------------------------------------- /test/feature/Scope/LetInForBreak.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | for (var x = 0; x < 10; x ++) { 4 | let y = 'let y'; 5 | if (x % 2 == 0) { 6 | break; 7 | } 8 | } 9 | 10 | // ---------------------------------------------------------------------------- 11 | -------------------------------------------------------------------------------- /test/feature/Scope/LetInForBreakInner.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | for (var x = 0; x < 10; x ++) { 4 | for (var y = 0; y < 10; y ++) { 5 | let z = 'let z'; 6 | if (x == 7) { 7 | break; 8 | } 9 | } 10 | } 11 | 12 | // ---------------------------------------------------------------------------- 13 | -------------------------------------------------------------------------------- /test/feature/Scope/LetInForBreakNamed.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | outer: 4 | for (var x = 0; x < 10; x ++) { 5 | for (var y = 0; y < 10; y ++) { 6 | let z = 'let z'; 7 | if (x == 7) { 8 | break outer; 9 | } 10 | } 11 | } 12 | 13 | // ---------------------------------------------------------------------------- 14 | -------------------------------------------------------------------------------- /test/feature/Scope/LetInForContinue.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | for (var x = 0; x < 10; x ++) { 4 | let y = 'let y'; 5 | if (x % 2 == 0) { 6 | continue; 7 | } 8 | } 9 | 10 | // ---------------------------------------------------------------------------- 11 | -------------------------------------------------------------------------------- /test/feature/Scope/LetInForContinueInner.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | for (var x = 0; x < 10; x ++) { 4 | for (var y = 0; y < 10; y ++) { 5 | let z = 'let z'; 6 | if (x == 7) { 7 | continue; 8 | } 9 | } 10 | } 11 | 12 | // ---------------------------------------------------------------------------- 13 | -------------------------------------------------------------------------------- /test/feature/Scope/LetInForContinueNamed.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | outer: 4 | for (var x = 0; x < 10; x ++) { 5 | for (var y = 0; y < 10; y ++) { 6 | let z = 'let z'; 7 | if (x == 7) { 8 | continue outer; 9 | } 10 | } 11 | } 12 | 13 | // ---------------------------------------------------------------------------- 14 | -------------------------------------------------------------------------------- /test/feature/Scope/LetInGenerators.js: -------------------------------------------------------------------------------- 1 | function h(t) { 2 | return t(); 3 | } 4 | 5 | function* f() { 6 | for (let i = 0; i < 3; ++i) { 7 | yield h(() => i); 8 | } 9 | } 10 | 11 | var g = f(); 12 | assert.deepEqual(g.next(), {value: 0, done: false}); 13 | assert.deepEqual(g.next(), {value: 1, done: false}); 14 | assert.deepEqual(g.next(), {value: 2, done: false}); 15 | 16 | -------------------------------------------------------------------------------- /test/feature/Scope/LetInProperties.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | var object = { 4 | get x() { 5 | while (true) { 6 | let let_x = 'let x'; 7 | return let_x; 8 | } 9 | }, 10 | 11 | set x(v) { 12 | do { 13 | let let_v = v; 14 | this.v = let_v; 15 | } while (false); 16 | } 17 | } 18 | 19 | // ---------------------------------------------------------------------------- 20 | -------------------------------------------------------------------------------- /test/feature/Scope/LetInWhileLoop.js: -------------------------------------------------------------------------------- 1 | while( true ) { 2 | let foo = 1; 3 | assert.equal(1, (() => foo)()); 4 | break; 5 | } 6 | -------------------------------------------------------------------------------- /test/feature/Scope/LetInitializerFor1.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | for (let x = 1; x < 10; x++) { 4 | x; 5 | } 6 | 7 | // ---------------------------------------------------------------------------- 8 | -------------------------------------------------------------------------------- /test/feature/Scope/LetInitializerFor2.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | for (let x = 1, y = 2, z = 3; x < 10; x ++) { 4 | y++; 5 | z++; 6 | } 7 | 8 | // ---------------------------------------------------------------------------- 9 | -------------------------------------------------------------------------------- /test/feature/Scope/LetInitializerFor3.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | for (let x = 1, y = x + 1; x < 10 && y != 0; x ++, y *= 2) { 4 | if (y > 300) { 5 | continue; 6 | } 7 | } 8 | 9 | // ---------------------------------------------------------------------------- 10 | -------------------------------------------------------------------------------- /test/feature/Scope/LetInitializerForIn.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | let sum = 0; 4 | let a = [1,2,3]; 5 | for (let x in a) { 6 | sum = sum + a[x]; 7 | } 8 | 9 | // ---------------------------------------------------------------------------- 10 | -------------------------------------------------------------------------------- /test/feature/Scope/LetNoInitializer.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | var x = 1; 4 | { 5 | let x; 6 | assert.equal(undefined, x); 7 | x = 2; 8 | assert.equal(2, x); 9 | } 10 | assert.equal(1, x); 11 | -------------------------------------------------------------------------------- /test/feature/Scope/LetNoInitializerGlobal.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | let x2; 4 | assert.equal(undefined, x2); 5 | x2 = 2; 6 | assert.equal(2, x2); 7 | -------------------------------------------------------------------------------- /test/feature/Scope/LetReinitializeInLoop.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var i = 0; 3 | while (i < 3) { 4 | let x; 5 | assert.equal(undefined, x); 6 | x = i; 7 | i++; 8 | } 9 | })(); 10 | -------------------------------------------------------------------------------- /test/feature/Scope/LetWithFor.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | for (var x = 0; x < 10; x++) { 4 | let let_y = 'let y'; 5 | for (var for_z = 0; for_z < 2; for_z ++) { 6 | break; 7 | } 8 | } 9 | 10 | // ---------------------------------------------------------------------------- 11 | -------------------------------------------------------------------------------- /test/feature/Scope/LetWithForIn.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | for (var x in [1,2,3]) { 4 | let let_y = x; 5 | for (var for_in_z in [4,5,6]) { 6 | continue; 7 | } 8 | } 9 | 10 | // ---------------------------------------------------------------------------- 11 | -------------------------------------------------------------------------------- /test/feature/Scope/LetWithSwitch.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | for (var i = 0; i < 5; i ++) { 4 | let let_x = 'let x'; 5 | 6 | switch (i) { 7 | case 0: 8 | break; 9 | case 2: 10 | break; 11 | default: 12 | break; 13 | } 14 | } 15 | 16 | // ---------------------------------------------------------------------------- 17 | -------------------------------------------------------------------------------- /test/feature/Scope/LetWithSwitch2.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | for (var i = 0; i < 5; i ++) { 4 | let let_x = 'let x'; 5 | 6 | switch (i) { 7 | case 0: 8 | continue; 9 | case 2: 10 | break; 11 | default: 12 | break; 13 | } 14 | } 15 | 16 | // ---------------------------------------------------------------------------- 17 | -------------------------------------------------------------------------------- /test/feature/Scope/NameBindingInFunction.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | { 4 | function f() { 5 | return f; 6 | } 7 | var g = f; 8 | f = 42; 9 | assert.equal(42, g()); 10 | } 11 | -------------------------------------------------------------------------------- /test/feature/Scope/NestedFunction1.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | function nestedFunction1() { 4 | return function() { 5 | let let_x = 'let x'; 6 | } 7 | } 8 | 9 | // ---------------------------------------------------------------------------- 10 | -------------------------------------------------------------------------------- /test/feature/Scope/NestedFunction2.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | function nestedFunction2() { 4 | let let_func = function() { 5 | let let_x = 'let x'; 6 | } 7 | return let_func; 8 | } 9 | 10 | // ---------------------------------------------------------------------------- 11 | -------------------------------------------------------------------------------- /test/feature/Scope/NestedFunction3.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | function nestedFunction3() { 4 | let let_x = 'let x'; 5 | function function_foo() { } 6 | } 7 | 8 | // ---------------------------------------------------------------------------- 9 | -------------------------------------------------------------------------------- /test/feature/Scope/NestedLet.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | var x = 'var'; 4 | { 5 | let y = 'let 1'; 6 | } 7 | { 8 | let y = 'let 2'; 9 | } 10 | 11 | // ---------------------------------------------------------------------------- 12 | -------------------------------------------------------------------------------- /test/feature/Scope/NestedLetConflict.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var x = 1; 3 | function f() { 4 | assert.equal(x, 1); 5 | { 6 | let x = 2; 7 | assert.equal(x, 2); 8 | } 9 | assert.equal(x, 1); 10 | } 11 | f(); 12 | })(); 13 | -------------------------------------------------------------------------------- /test/feature/Scope/Regress1381.js: -------------------------------------------------------------------------------- 1 | function test() { 2 | let ret = true; 3 | while (false) 4 | for (let i = 0; i < 1; i++) 5 | ret = () => i; 6 | return ret 7 | } 8 | assert.isTrue(test()); 9 | -------------------------------------------------------------------------------- /test/feature/Scope/RenameFunctionBlock.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Issue #1773 3 | function when() { 4 | function* where() { 5 | var index = 0; 6 | for (let x of Object) { 7 | index++; 8 | } 9 | } 10 | var x = 5; 11 | } 12 | -------------------------------------------------------------------------------- /test/feature/Scope/SiblingScopes.js: -------------------------------------------------------------------------------- 1 | // Options: --free-variable-checker=false 2 | 3 | assert.throws(() => { 4 | { 5 | let testVariable = 1; 6 | assert.equal(testVariable, 1); 7 | } 8 | 9 | { 10 | let testVariable = 2; 11 | assert.equal(testVariable, 2); 12 | } 13 | 14 | testVariable; 15 | }, ReferenceError); 16 | -------------------------------------------------------------------------------- /test/feature/Scope/TopLevelLet.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | let x = 'let'; 4 | 5 | // ---------------------------------------------------------------------------- 6 | 7 | assert.equal(x, 'let'); -------------------------------------------------------------------------------- /test/feature/Scope/TopLevelLetConst.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | let x = 'let'; 4 | const y = 'const'; 5 | 6 | // ---------------------------------------------------------------------------- 7 | 8 | assert.equal('let', x); 9 | assert.equal('const', y); 10 | -------------------------------------------------------------------------------- /test/feature/Scope/TopLevelLetVar.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | let x = 'let'; 4 | var y = 'var'; 5 | 6 | // ---------------------------------------------------------------------------- 7 | 8 | assert.equal('let', x); 9 | assert.equal('var', y); 10 | -------------------------------------------------------------------------------- /test/feature/Spread/Array.js: -------------------------------------------------------------------------------- 1 | var a = []; 2 | var b = [0, ...a]; 3 | var c = [...b, ...b]; 4 | var d; 5 | var e = [0, ...d = [1, 2], 3]; 6 | var f = [0, ...[[1, 2], [3, 4]], 5]; 7 | 8 | // ---------------------------------------------------------------------------- 9 | 10 | assert.deepEqual([0], b); 11 | assert.deepEqual([0, 0], c); 12 | assert.deepEqual([1, 2], d); 13 | assert.deepEqual([0, 1, 2, 3], e); 14 | assert.deepEqual([0, [1, 2], [3, 4], 5], f); 15 | -------------------------------------------------------------------------------- /test/feature/Spread/Call.js: -------------------------------------------------------------------------------- 1 | function* G() { 2 | yield 'hi'; 3 | yield 'there'; 4 | } 5 | 6 | function f(...args) { 7 | return args; 8 | } 9 | 10 | var result = f(0, ...[1, 2], 3, ...G()); 11 | assert.deepEqual([0, 1, 2, 3, 'hi', 'there'], result); 12 | 13 | result = f(...G()); 14 | assert.deepEqual(['hi', 'there'], result); 15 | 16 | function g() { 17 | 'use strict'; 18 | assert.strictEqual(undefined, this); 19 | } 20 | 21 | g(); 22 | g(...[]); 23 | -------------------------------------------------------------------------------- /test/feature/Spread/CallWithUndefined.js: -------------------------------------------------------------------------------- 1 | function f(...args) { 2 | return args; 3 | } 4 | 5 | assert.throw(function() { 6 | // Should throw due to ToObject(undefined) 7 | f(0, ...undefined, 1); 8 | }, TypeError) 9 | -------------------------------------------------------------------------------- /test/feature/Spread/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Options: --spread=false 2 | // Error: :4:8: Unexpected token ... 3 | 4 | [0, 1, ...[2, 3]]; 5 | -------------------------------------------------------------------------------- /test/feature/Spread/Iterators.js: -------------------------------------------------------------------------------- 1 | function* G() { 2 | yield 1; 3 | yield 2; 4 | yield 3; 5 | } 6 | 7 | var a = [...G()]; 8 | var b = [4, ...G()]; 9 | var c = [...G(), 4]; 10 | var d = [4, ...G(), 5]; 11 | 12 | // ---------------------------------------------------------------------------- 13 | 14 | assert.deepEqual([1, 2, 3], a); 15 | assert.deepEqual([4, 1, 2, 3], b); 16 | assert.deepEqual([1, 2, 3, 4], c); 17 | assert.deepEqual([4, 1, 2, 3, 5], d); 18 | -------------------------------------------------------------------------------- /test/feature/Spread/MethodCall.js: -------------------------------------------------------------------------------- 1 | var obj = { 2 | method: function(...args) { 3 | return { 4 | self: this, 5 | args: args 6 | }; 7 | } 8 | }; 9 | 10 | var result = { 11 | obj: obj, 12 | result: obj.method(0, ...[1, 2], 3) 13 | }; 14 | 15 | // ---------------------------------------------------------------------------- 16 | 17 | assert.equal(result.obj, result.result.self); 18 | assert.deepEqual([0, 1, 2, 3], result.result.args); 19 | -------------------------------------------------------------------------------- /test/feature/Spread/NewBuiltin.js: -------------------------------------------------------------------------------- 1 | var d = new Date(...[2011, 4, 3]); 2 | 3 | // ---------------------------------------------------------------------------- 4 | 5 | assert.equal(2011, d.getFullYear()); 6 | assert.equal(4, d.getMonth()); 7 | assert.equal(3, d.getDate()); 8 | -------------------------------------------------------------------------------- /test/feature/Spread/NoIterator.js: -------------------------------------------------------------------------------- 1 | assert.throw(() => [...{}], TypeError); 2 | -------------------------------------------------------------------------------- /test/feature/Spread/NotAnObject.js: -------------------------------------------------------------------------------- 1 | assert.throw(() => [...null], TypeError); 2 | -------------------------------------------------------------------------------- /test/feature/Spread/String.js: -------------------------------------------------------------------------------- 1 | var a = ''; 2 | var b = ['b', ...a]; 3 | var c = [...b, ...b]; 4 | var d; 5 | var e = [0, ...d = '12', 3]; 6 | var f = [... new String('abc')]; 7 | 8 | // ---------------------------------------------------------------------------- 9 | 10 | assert.deepEqual(['b'], b); 11 | assert.deepEqual(['b', 'b'], c); 12 | assert.deepEqual([0, '1', '2', 3], e); 13 | assert.deepEqual(['a', 'b', 'c'], f); 14 | -------------------------------------------------------------------------------- /test/feature/SpreadProperties/Getters.js: -------------------------------------------------------------------------------- 1 | // Options: --spread-properties 2 | 3 | var n = 0; 4 | var o; 5 | assert.deepEqual(o = {a: 'a', ...{get a() { n++; return 'b'; }}}, {a: 'b'}); 6 | assert.equal(1, n); 7 | assert.equal(o.a, 'b'); 8 | assert.equal(1, n); 9 | -------------------------------------------------------------------------------- /test/feature/SpreadProperties/Symbols.js: -------------------------------------------------------------------------------- 1 | // Options: --spread-properties 2 | 3 | var s1 = Symbol(); 4 | var s2 = Symbol(); 5 | 6 | var o = {[s1]: 1, ...{[s2]: 2}}; 7 | assert.equal(o[s1], 1); 8 | assert.equal(o[s2], 2); 9 | -------------------------------------------------------------------------------- /test/feature/StringIterator.js: -------------------------------------------------------------------------------- 1 | var s = 'abc 💩 def'; 2 | 3 | var expected = ['a', 'b', 'c', ' ', '💩', ' ', 'd', 'e', 'f']; 4 | var actual = []; 5 | for (var x of s) { 6 | actual.push(x); 7 | } 8 | assert.deepEqual(actual, expected); 9 | 10 | var newS = new String('abc'); 11 | var res = []; 12 | for (var x of newS) { 13 | res.push(x); 14 | } 15 | assert.deepEqual(res, ['a', 'b', 'c']); 16 | -------------------------------------------------------------------------------- /test/feature/SuperObjectLiteral/Error_Super.js: -------------------------------------------------------------------------------- 1 | // Error: :8:17: Unexpected token ; 2 | 3 | var p = {}; 4 | 5 | var o = { 6 | __proto__: p, 7 | method() { 8 | return super; 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /test/feature/SuperObjectLiteral/SuperChangeProto.js: -------------------------------------------------------------------------------- 1 | var log = ''; 2 | 3 | var base = { 4 | p() { log += '[base]'; } 5 | }; 6 | 7 | var otherBase = { 8 | p() { log += '[otherBase]'; } 9 | }; 10 | 11 | var derived = { 12 | __proto__: base, 13 | p() { 14 | log += '[derived]'; 15 | super.p(); 16 | derived.__proto__ = otherBase; 17 | super.p(); 18 | } 19 | }; 20 | 21 | derived.p(); 22 | assert.equal(log, '[derived][base][otherBase]'); 23 | -------------------------------------------------------------------------------- /test/feature/SuperObjectLiteral/SuperInArrow.js: -------------------------------------------------------------------------------- 1 | var x; 2 | 3 | var p = { 4 | m(v) { 5 | x = v; 6 | } 7 | }; 8 | 9 | var o = { 10 | __proto__: p, 11 | n(x) { 12 | var f = (x) => { 13 | super.m(x); 14 | }; 15 | f(x); 16 | } 17 | }; 18 | 19 | o.n(42); 20 | assert.equal(x, 42); 21 | -------------------------------------------------------------------------------- /test/feature/SuperObjectLiteral/SuperPostfix.js: -------------------------------------------------------------------------------- 1 | var p = { 2 | _x: 0, 3 | get x() { 4 | return this._x; 5 | }, 6 | set x(x) { 7 | this._x = x; 8 | } 9 | }; 10 | 11 | var o = { 12 | __proto__: p, 13 | m() { 14 | assert.equal(this.x, 0); 15 | assert.equal(super.x++, 0); 16 | assert.equal(this.x, 1); 17 | assert.equal(super.x--, 1); 18 | assert.equal(this.x, 0); 19 | } 20 | }; 21 | 22 | o.m(); 23 | -------------------------------------------------------------------------------- /test/feature/SuperObjectLiteral/SuperWithoutProto.js: -------------------------------------------------------------------------------- 1 | var o = { 2 | x: true, 3 | m() { 4 | return super.hasOwnProperty('x'); 5 | } 6 | }; 7 | 8 | assert.isTrue(o.m()); 9 | -------------------------------------------------------------------------------- /test/feature/Symbol/GetOwnPropertySymbols.js: -------------------------------------------------------------------------------- 1 | var s1 = Symbol(); 2 | var s2 = Symbol(); 3 | var object = {a: 'a'}; 4 | object[s1] = 's1'; 5 | object.b = 'b'; 6 | object[s2] = 's2'; 7 | assert.deepEqual([s1, s2], Object.getOwnPropertySymbols(object)); 8 | -------------------------------------------------------------------------------- /test/feature/Symbol/TransformationOff.js: -------------------------------------------------------------------------------- 1 | var s = Symbol(); 2 | var s2 = Symbol(); 3 | var object = {}; 4 | object[s] = 1; 5 | object[s2] = 2; 6 | 7 | assert.equal(object[s], 1); 8 | assert.equal(object[s2], 2); 9 | -------------------------------------------------------------------------------- /test/feature/Syntax/ArrayWithHoles.js: -------------------------------------------------------------------------------- 1 | var arr = [,1, ,3,]; 2 | assert.equal(4, arr.length); 3 | 4 | var arr2 = [,1, ,...[3],]; 5 | assert.equal(4, arr.length); 6 | 7 | var x, y; 8 | [x, , y] = [0, 1, 2]; 9 | assert.equal(0, x); 10 | assert.equal(2, y); 11 | -------------------------------------------------------------------------------- /test/feature/Syntax/CaseClauseShouldBeStatementListItem.script.js: -------------------------------------------------------------------------------- 1 | switch (1) { 2 | case 2: 3 | let x; 4 | break; 5 | case 3: 6 | const y = 4; 7 | break; 8 | case 5: 9 | function f() {} 10 | break; 11 | default: 12 | class C {} 13 | break; 14 | } 15 | -------------------------------------------------------------------------------- /test/feature/Syntax/Empty.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/traceur-compiler/0b6b96fa1ed48d77ca6908bd52ea735a9ad8f32e/test/feature/Syntax/Empty.js -------------------------------------------------------------------------------- /test/feature/Syntax/Error_Arguments.js: -------------------------------------------------------------------------------- 1 | // Error: :6:6: Unexpected token ) 2 | 3 | function f(x) { 4 | } 5 | 6 | f(x, ); 7 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_DeclarationInDoWhileClass.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: :4:4: Unexpected reserved word class 3 | 4 | do class C {} while (false); 5 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_DeclarationInDoWhileConst.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: :4:4: Unexpected reserved word const 3 | 4 | do const y = 1; while (false); 5 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_DeclarationInDoWhileFunction.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: :4:4: Unexpected reserved word function 3 | 4 | do function f() {} while (false); 5 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_DeclarationInDoWhileLet.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: :4:4: Unexpected reserved word let 3 | 4 | do let x; while (false); 5 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_DeclarationInDoWhileLetOpenSquare.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | // Error: :4:4: A statement cannot start with 'let [' 3 | 4 | do let[0] = 1; while (false); 5 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_ForInLoopTooManyVariableDeclarations.js: -------------------------------------------------------------------------------- 1 | // Error: :3:15: Unexpected token in 2 | 3 | for (var i, j in {}) {} 4 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_ForOfLoopTooManyVariableDeclarations.js: -------------------------------------------------------------------------------- 1 | // Error: :3:15: Unexpected token of 2 | 3 | for (var i, j of []) {} 4 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_FunctionParam.js: -------------------------------------------------------------------------------- 1 | // Error: :3:14: Unexpected token ) 2 | 3 | function f(x,) { 4 | return x; 5 | } 6 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_IllegalReturn.js: -------------------------------------------------------------------------------- 1 | // Error: :3:1: Illegal return statement 2 | 3 | return 42; -------------------------------------------------------------------------------- /test/feature/Syntax/Error_IllegalReturn.script.js: -------------------------------------------------------------------------------- 1 | // Error: :3:1: Illegal return statement 2 | 3 | return 42; -------------------------------------------------------------------------------- /test/feature/Syntax/Error_MultipleDefault.js: -------------------------------------------------------------------------------- 1 | // Error: :9:5: Switch statements may have at most one 'default' clause 2 | 3 | (function() { 4 | switch (42) { 5 | case 1: 6 | return; 7 | default: 8 | return; 9 | default: 10 | return; 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_NoLineTerminatorPostfix.js: -------------------------------------------------------------------------------- 1 | // Error: 6:7: Unexpected token ; 2 | 3 | function f(x) { 4 | var x = 0; 5 | x 6 | ++; 7 | } 8 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_RegExpNotClosed.js: -------------------------------------------------------------------------------- 1 | // Error: :3:1: Expected '/' in regular expression literal 2 | 3 | / -------------------------------------------------------------------------------- /test/feature/Syntax/Error_StrictKeywordsInArgumentsPattern.js: -------------------------------------------------------------------------------- 1 | // Error: :3:26: implements is a reserved identifier 2 | 3 | function testImplements({implements}) { 4 | 'use strict'; 5 | return 42; 6 | } 7 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_StrictKeywordsInPropertyDefinitionIdentifierReference.js: -------------------------------------------------------------------------------- 1 | // Error: :5:11: yield is a reserved identifier 2 | 3 | function testStrictKeywordsInPropertyDefinitionIdentifierReference() { 4 | 'use strict'; 5 | return {yield}; 6 | } 7 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_StrictKeywordsInStrict.js: -------------------------------------------------------------------------------- 1 | // Error: :4:26: implements is a reserved identifier 2 | 3 | 'use strict'; 4 | function testImplements({implements}) { 5 | return 42; 6 | } 7 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_UnicodeEscapeSequenceInName.js: -------------------------------------------------------------------------------- 1 | // Error: :3:5: Character code '48' is not a valid identifier start char 2 | 3 | var \u0030ab = 42; // 0ab 4 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_WithInClass.js: -------------------------------------------------------------------------------- 1 | // Error: :5:5: Strict mode code may not include a with statement 2 | 3 | class C { 4 | method() { 5 | with ({}) {} 6 | } 7 | } -------------------------------------------------------------------------------- /test/feature/Syntax/Error_WithInModule.js: -------------------------------------------------------------------------------- 1 | // Error: :3:1: Strict mode code may not include a with statement 2 | 3 | with ({}) {} 4 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_WithInStrictFunction.js: -------------------------------------------------------------------------------- 1 | // Error: :6:3: Strict mode code may not include a with statement 2 | 3 | function testWithInStrict() { 4 | 'use foo'; 5 | 'use strict'; 6 | with ({}) {} 7 | } -------------------------------------------------------------------------------- /test/feature/Syntax/Error_WithInStrictProgram.js: -------------------------------------------------------------------------------- 1 | // Error: :5:1: Strict mode code may not include a with statement 2 | 3 | 'use foo'; 4 | 'use strict'; 5 | with ({}) {} 6 | -------------------------------------------------------------------------------- /test/feature/Syntax/Error_YieldStarNewLine.js: -------------------------------------------------------------------------------- 1 | // Error: :5:7: Unexpected token * 2 | 3 | function* yieldStarNewLine() { 4 | yield 5 | *42; 6 | } 7 | -------------------------------------------------------------------------------- /test/feature/Syntax/ImplicitSemiColon.js: -------------------------------------------------------------------------------- 1 | function f() { 2 | return 3 | 42; 4 | } 5 | 6 | assert.isUndefined(f()); -------------------------------------------------------------------------------- /test/feature/Syntax/ImportFromTypo.js: -------------------------------------------------------------------------------- 1 | // Error: :3:11: Unexpected token FROM 2 | 3 | import {} FROM 'abc'; 4 | -------------------------------------------------------------------------------- /test/feature/Syntax/InInBinding.js: -------------------------------------------------------------------------------- 1 | var [x = 'a' in {a: 1}] = []; 2 | assert.equal(true, x); 3 | -------------------------------------------------------------------------------- /test/feature/Syntax/NoNewLineHereEndOfFile.script.js: -------------------------------------------------------------------------------- 1 | // Comment not closed. 2 | var f = (x) /* 3 | => {} 4 | -------------------------------------------------------------------------------- /test/feature/Syntax/NumberLiteralMemberExpression.js: -------------------------------------------------------------------------------- 1 | assert.equal(1 .toString(), '1'); 2 | assert.equal(1.1.toString(), '1.1'); 3 | assert.equal(1e1.toString(), '10'); 4 | assert.equal(1E1.toString(), '10'); 5 | -------------------------------------------------------------------------------- /test/feature/Syntax/ParamDuplicateCheckNonSimpleOk.js: -------------------------------------------------------------------------------- 1 | function f(a, b, {c = function(a) {}}) { 2 | 3 | } 4 | 5 | var f2 = (a, b, {c = function(a) {}}) => { 6 | 7 | }; 8 | 9 | function g(d, e, [f = function(d) {}]) { 10 | 11 | } 12 | 13 | var g2 = (d, e, [f = function(d) {}]) => { 14 | 15 | }; 16 | -------------------------------------------------------------------------------- /test/feature/Syntax/ParamDuplicateCheckOk.js: -------------------------------------------------------------------------------- 1 | function f(x, y = function(x) {}) { 2 | 'use strict'; 3 | } 4 | 5 | var f2 = (x, y = function(x) {}) => { 6 | 'use strict'; 7 | }; 8 | 9 | function g() { 10 | 'use strict'; 11 | function h(x, y = function(x) {}) { 12 | 13 | } 14 | 15 | var h2 = (x, y = function(x) {}) => { 16 | 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /test/feature/Syntax/RegularExpression.js: -------------------------------------------------------------------------------- 1 | var re1 = /a*b/; 2 | var re2 = /=a+/; 3 | var re3 = /\//; 4 | var re4 = /=/; 5 | var re5 = /=*/; 6 | var re6 = /a*b/g; 7 | var re7 = /=a+/g; 8 | var re8 = /\//g; 9 | var re9 = /=/g; 10 | var re10 = /=*/g; 11 | -------------------------------------------------------------------------------- /test/feature/Syntax/StringEscapes.js: -------------------------------------------------------------------------------- 1 | var o1 = { 2 | '\\\'': 42, 3 | '\0\b\f\n\r\t\v\x42\u1234': 1234 4 | }; 5 | var o2 = { 6 | '\\\'\ 7 | ': 42, 8 | '\0\b\f\n\r\t\v\x42\u1234': 1234 9 | }; 10 | 11 | assert.deepEqual(Object.keys(o1), Object.keys(o2)); 12 | assert.equal(42, o1['\\\'']); 13 | assert.equal(42, o2['\\\'']); 14 | -------------------------------------------------------------------------------- /test/feature/Syntax/UnicodeEscapeSequenceInName.js: -------------------------------------------------------------------------------- 1 | var a\u0062c = 1; 2 | assert.equal(1, abc); 3 | 4 | var λ = 2; 5 | assert.equal(2, \u03bb); 6 | -------------------------------------------------------------------------------- /test/feature/Syntax/UseStrictEscapeSequence.script.js: -------------------------------------------------------------------------------- 1 | function testUseStrictEscapeSequence() { 2 | 'use str\x69ct'; 3 | return this; 4 | } 5 | 6 | assert.notEqual(testUseStrictEscapeSequence(), undefined); 7 | 8 | -------------------------------------------------------------------------------- /test/feature/Syntax/UseStrictLineContinuation.script.js: -------------------------------------------------------------------------------- 1 | function testUseStrictLineContinuation() { 2 | 'use \ 3 | strict'; 4 | return this; 5 | } 6 | 7 | assert.notEqual(testUseStrictLineContinuation(), undefined); 8 | -------------------------------------------------------------------------------- /test/feature/Syntax/null.js: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /test/feature/TempVarTransformer/UseStrictDirective.script.js: -------------------------------------------------------------------------------- 1 | // This test depends on it running in non strict mode. 2 | assert.isTrue(function() { return this; }() !== undefined); 3 | 4 | function f() { 5 | 'use strict'; 6 | var xs = 'abc'.split(''); 7 | var o = { 8 | f() { 9 | return this; 10 | } 11 | }; 12 | o.f(...xs); 13 | return (1, o.f)(); 14 | } 15 | 16 | assert.isUndefined(f()); -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/CallExpression.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | { 4 | let i = 0, called = 0; 5 | function f() { 6 | called++; 7 | return function() { 8 | return ++i; 9 | }; 10 | } 11 | 12 | assert.equal(1, f() `whatevs`); 13 | assert.equal(1, called); 14 | assert.equal(2, f `abc` `def`); 15 | assert.equal(2, called); 16 | assert.equal(3, f `ghi` ()); 17 | assert.equal(3, called); 18 | } 19 | -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/CommaExpression.js: -------------------------------------------------------------------------------- 1 | assert.equal('24', `${ 1, 2 }${ 3, 4 }`); 2 | assert.equal('6', `${ 5, 6 }`); 3 | 4 | function templateLiteralCommaTest(callsite, x, y) { 5 | assert.equal(2, x); 6 | assert.equal(4, y); 7 | return x + y; 8 | } 9 | 10 | assert.equal(6, templateLiteralCommaTest`${ 1, 2 }${ 3, 4 }`); 11 | -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Options: --template-literals=false 2 | // Error: :5:1: Unexpected token ` 3 | // Error: :9:5: Unexpected token ` 4 | 5 | `abc`; 6 | 7 | function tag() {} 8 | 9 | tag `def`; 10 | -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/Error_InvalidSubstitution.js: -------------------------------------------------------------------------------- 1 | // Error: :6:1: Unterminated template literal 2 | 3 | function f() {} 4 | 5 | f`a${ ` 6 | -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/Error_InvalidSubstitution2.js: -------------------------------------------------------------------------------- 1 | // Error: :5:7: Unexpected token } 2 | 3 | function f() {} 4 | 5 | f`a${ }` 6 | -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/Error_NotClosed.js: -------------------------------------------------------------------------------- 1 | // Error: :6:1: Unterminated template literal 2 | 3 | function f() {} 4 | 5 | f`not closed \` 6 | -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/InBlock.js: -------------------------------------------------------------------------------- 1 | // This just tests that we do not get any compile errors. 2 | 3 | { 4 | `abc` 5 | } 6 | 7 | (function() { 8 | `def` 9 | }); -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/InModule.js: -------------------------------------------------------------------------------- 1 | import * as m from './resources/m.js'; 2 | import * as n from './resources/n.js'; 3 | -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/MemberExpression.js: -------------------------------------------------------------------------------- 1 | // Options: --block-binding 2 | 3 | { 4 | let a = [function() { 5 | return 1; 6 | }]; 7 | 8 | assert.equal(1, a[0] `whatevs`); 9 | 10 | function f() { 11 | return [function() { 12 | return 2; 13 | }]; 14 | } 15 | 16 | assert.equal(2, f `abc` [0] `def`); 17 | 18 | let o = { 19 | g: function() { 20 | return 3; 21 | } 22 | }; 23 | 24 | assert.equal(3, o.g `ghi`); 25 | } 26 | -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/Strict.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function f(...args) { 4 | return this; 5 | } 6 | 7 | assert.equal(undefined, f `a`); 8 | -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/StringRaw.js: -------------------------------------------------------------------------------- 1 | assert.equal('', String.raw ``); 2 | assert.equal('\n', String.raw ` 3 | `); 4 | assert.equal('\\n', String.raw `\n`); 5 | assert.equal('\\n42\\t', String.raw `\n${ 40 + 2 }\t`); 6 | assert.equal('\n42\t', String.raw ` 7 | ${42} `); 8 | assert.equal('\\\n42\\\n', String.raw `\ 9 | ${42}\ 10 | `); 11 | -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/TemplateObjectCaching.js: -------------------------------------------------------------------------------- 1 | import {cooked, raw} from './resources/template-objects.js'; 2 | 3 | function assertCooked(obj) { 4 | assert.equal(obj, cooked); 5 | assert.notEqual(obj, raw); 6 | } 7 | 8 | function assertRaw(obj) { 9 | assert.equal(obj, raw); 10 | assert.notEqual(obj, cooked); 11 | } 12 | 13 | assertCooked `a${1}b`; 14 | assertCooked `a${2}b`; 15 | 16 | assertRaw `c${3}d\n`; 17 | assertRaw `c${4}d\n`; 18 | -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/resources/f.js: -------------------------------------------------------------------------------- 1 | export function f(...args) { 2 | return args; 3 | } 4 | -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/resources/m.js: -------------------------------------------------------------------------------- 1 | 2 | import {assert} from '../../../asserts.js'; 3 | import {f} from './f.js'; 4 | 5 | assert.equal('a', (f `a`)[0][0]); 6 | -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/resources/n.js: -------------------------------------------------------------------------------- 1 | import {assert} from '../../../asserts.js'; 2 | import {f} from './f.js'; 3 | 4 | assert.equal('b', (f `b`)[0][0]); 5 | -------------------------------------------------------------------------------- /test/feature/TemplateLiterals/resources/template-objects.js: -------------------------------------------------------------------------------- 1 | export let cooked; 2 | export let raw; 3 | 4 | function setCooked(obj) { 5 | cooked = obj; 6 | } 7 | 8 | function setRaw(obj) { 9 | raw = obj; 10 | } 11 | 12 | setCooked `a${1}b`; 13 | setRaw `c${3}d\n`; 14 | -------------------------------------------------------------------------------- /test/feature/TestRunner/RelativeUnixPath.js: -------------------------------------------------------------------------------- 1 | // Error: Intentional error 'test/feature/foo/bar' more. 2 | 3 | throw new Error('Intentional error \'test/feature/foo/bar\' more.'); 4 | -------------------------------------------------------------------------------- /test/feature/TestRunner/RelativeWindowsPath.js: -------------------------------------------------------------------------------- 1 | // Error: Intentional error 'test/feature/foo/bar' more. 2 | 3 | throw new Error('Intentional error \'test\\feature\\foo\\bar\' more.'); 4 | -------------------------------------------------------------------------------- /test/feature/TestRunner/UnixPath.js: -------------------------------------------------------------------------------- 1 | // Error: Intentional error 'test/feature/foo/bar' more. 2 | 3 | throw new Error( 4 | 'Intentional error \'/src/traceur/test/feature/foo/bar\' more.'); 5 | -------------------------------------------------------------------------------- /test/feature/TestRunner/WindowsPath.js: -------------------------------------------------------------------------------- 1 | // Error: Intentional error 'test/feature/foo/bar' more. 2 | 3 | throw new Error( 4 | 'Intentional error \'c:\\src\\traceur\\test\\feature\\foo\\bar\' more.'); 5 | -------------------------------------------------------------------------------- /test/feature/Tools/FreeVariableChecker.js: -------------------------------------------------------------------------------- 1 | // Options: --freeVariableChecker 2 | // Error: :4:11: xxx is not defined 3 | try { 4 | var y = xxx; 5 | } catch (e) {} 6 | // test/unit/semantics/freeVariableChecker.traceur.js checks operation 7 | // of the checker, here we check that the option works in the compiler. 8 | -------------------------------------------------------------------------------- /test/feature/Types/Error_FunctionType.js: -------------------------------------------------------------------------------- 1 | // Options: --types --free-variable-checker 2 | // Error: :6:3: unresolved is not defined 3 | 4 | (function() { 5 | var f: (unresolved: number) => string 6 | unresolved; 7 | }); 8 | -------------------------------------------------------------------------------- /test/feature/Types/Error_TypeAlias.js: -------------------------------------------------------------------------------- 1 | // Options: --types 2 | // Error: :5:10: Unexpected token 42 3 | // Error: :6:7: Unexpected token ; 4 | 5 | type A = 42; 6 | type B; 7 | -------------------------------------------------------------------------------- /test/feature/Types/Error_TypeArguments.js: -------------------------------------------------------------------------------- 1 | // Options: --types 2 | // Error: :4:17: Unexpected token ) 3 | 4 | function f(x: X<) {} 5 | -------------------------------------------------------------------------------- /test/feature/Types/Error_TypeArguments2.js: -------------------------------------------------------------------------------- 1 | // Options: --types 2 | // Error: :5:1: Unexpected token End of File 3 | 4 | var x: X< 5 | -------------------------------------------------------------------------------- /test/feature/Types/Error_TypeArguments3.js: -------------------------------------------------------------------------------- 1 | // Options: --types 2 | // Error: :4:10: Unexpected token > 3 | 4 | var x: X<>; 5 | -------------------------------------------------------------------------------- /test/feature/Types/Interface.js: -------------------------------------------------------------------------------- 1 | // Options: --types 2 | 3 | interface A {} 4 | interface B {} 5 | interface D extends F {} 6 | interface G extends H, I {} 7 | 8 | interface J { 9 | a: K; 10 | b: L[]; 11 | } 12 | -------------------------------------------------------------------------------- /test/feature/Types/TypeAlias.js: -------------------------------------------------------------------------------- 1 | // Options: --types 2 | 3 | type A = string; 4 | type 5 | B = Array; 6 | 7 | export type C = number; 8 | -------------------------------------------------------------------------------- /test/feature/Types/TypeAlias.script.js: -------------------------------------------------------------------------------- 1 | // Options: --types 2 | 3 | var type = 42; 4 | type; 5 | 6 | type A = string; 7 | type 8 | B = Array; 9 | -------------------------------------------------------------------------------- /test/feature/Types/TypeAnnotations.js: -------------------------------------------------------------------------------- 1 | // Options: --types --annotations 2 | 3 | class Test {} 4 | 5 | function abc(x: Test) : Test { 6 | var a : Test = new Test(); 7 | } 8 | 9 | function xyz(x: number, y: boolean): string {} 10 | -------------------------------------------------------------------------------- /test/feature/UnicodeEscapeSequence/Error_CodePointTooHigh.js: -------------------------------------------------------------------------------- 1 | // Options: --unicode-escape-sequences 2 | // Error: :4:5: The code point in a Unicode escape sequence cannot exceed 10FFFF 3 | 4 | "\u{1000000}"; 5 | -------------------------------------------------------------------------------- /test/feature/UnicodeEscapeSequence/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Options: --unicode-escape-sequences=false 2 | // Error: :4:4: Hex digit expected 3 | 4 | "\u{0}"; 5 | -------------------------------------------------------------------------------- /test/feature/UnicodeEscapeSequence/Error_HexDigitExpected.js: -------------------------------------------------------------------------------- 1 | // Options: --unicode-escape-sequences 2 | // Error: :4:5: Hex digit expected 3 | 4 | "\u{"; 5 | -------------------------------------------------------------------------------- /test/feature/UnicodeEscapeSequence/Error_HexDigitExpected2.js: -------------------------------------------------------------------------------- 1 | // Options: --unicode-escape-sequences 2 | // Error: :4:5: Hex digit expected 3 | 4 | "\u{1"; 5 | -------------------------------------------------------------------------------- /test/feature/UnicodeEscapeSequence/Error_HexDigitExpected3.js: -------------------------------------------------------------------------------- 1 | // Options: --unicode-escape-sequences 2 | // Error: :4:5: Hex digit expected 3 | 4 | "\u{ 5 | -------------------------------------------------------------------------------- /test/feature/UnicodeEscapeSequence/Error_HexDigitExpected4.js: -------------------------------------------------------------------------------- 1 | // Options: --unicode-escape-sequences 2 | // Error: :4:5: Hex digit expected 3 | 4 | "\u{}"; 5 | -------------------------------------------------------------------------------- /test/feature/Yield/Arguments.js: -------------------------------------------------------------------------------- 1 | function* f() { 2 | yield [arguments[0], arguments[1]]; 3 | } 4 | 5 | for (var arr of f(1, 2)) { 6 | assert.equal(1, arr[0]); 7 | assert.equal(2, arr[1]); 8 | } -------------------------------------------------------------------------------- /test/feature/Yield/BinaryOperator.js: -------------------------------------------------------------------------------- 1 | function* f(x) { 2 | var a = (yield x) + (yield x + 1); 3 | return a; 4 | } 5 | 6 | var g = f(1); 7 | assert.deepEqual(g.next(), {value: 1, done: false}); 8 | assert.deepEqual(g.next(1), {value: 2, done: false}); 9 | assert.deepEqual(g.next(2), {value: 3, done: true}); 10 | -------------------------------------------------------------------------------- /test/feature/Yield/CommaOperator.js: -------------------------------------------------------------------------------- 1 | function* f(x, y) { 2 | yield x, yield y; 3 | return x + y; 4 | } 5 | 6 | var g = f(1, 2); 7 | assert.deepEqual(g.next(), {value: 1, done: false}); 8 | assert.deepEqual(g.next(1), {value: 2, done: false}); 9 | assert.deepEqual(g.next(2), {value: 3, done: true}); 10 | -------------------------------------------------------------------------------- /test/feature/Yield/Continue.js: -------------------------------------------------------------------------------- 1 | var x = ':'; 2 | 3 | function* f() { 4 | yield 1; 5 | var j = 0; 6 | label1: for (var i = 0; i < 3; i++) { 7 | x += 'i:' + i; 8 | x += 'j:' + j; 9 | if (j++ > 4) return; 10 | continue label1; 11 | x += 'x'; 12 | } 13 | } 14 | 15 | var g = f(); 16 | assert.deepEqual(g.next(), {value: 1, done: false}); 17 | assert.deepEqual(g.next(), {value: undefined, done: true}); 18 | assert.equal(x, ':i:0j:0i:1j:1i:2j:2'); 19 | -------------------------------------------------------------------------------- /test/feature/Yield/DefaultArguments.js: -------------------------------------------------------------------------------- 1 | function* f(x = 1) { 2 | yield x; 3 | } 4 | 5 | for (var x of f(42)) { 6 | assert.equal(42, x); 7 | } -------------------------------------------------------------------------------- /test/feature/Yield/EmptyGenerator.js: -------------------------------------------------------------------------------- 1 | function* f() { 2 | } 3 | 4 | var g = f(); 5 | assert.deepEqual(g.next(), {done: true, value: undefined}); 6 | -------------------------------------------------------------------------------- /test/feature/Yield/Error_Disabled.js: -------------------------------------------------------------------------------- 1 | // Options: --generators=false 2 | // Error: :4:9: Unexpected token * 3 | 4 | function* range(start, end) { 5 | for (var i = start; i < end; i++) { 6 | yield i; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/feature/Yield/Error_Disabled2.js: -------------------------------------------------------------------------------- 1 | // Options: --forOf=false 2 | // Error: :5:12: Unexpected token of 3 | 4 | var s = []; 5 | for (var i of yieldFor()) { 6 | s.push(i); 7 | } 8 | -------------------------------------------------------------------------------- /test/feature/Yield/Error_MissingStar.script.js: -------------------------------------------------------------------------------- 1 | // Error: :4:9: Semi-colon expected 2 | 3 | function simpleGenerator() { 4 | yield 1; 5 | } 6 | -------------------------------------------------------------------------------- /test/feature/Yield/ForEmptyGenerator.js: -------------------------------------------------------------------------------- 1 | function* forEmptyGenerator() { 2 | yield* []; 3 | } 4 | 5 | function accumulate(iterator) { 6 | var result = ''; 7 | for (var value of iterator) { 8 | result = result + String(value); 9 | } 10 | return result; 11 | } 12 | 13 | // ---------------------------------------------------------------------------- 14 | 15 | assert.equal('', accumulate(forEmptyGenerator())); 16 | -------------------------------------------------------------------------------- /test/feature/Yield/FunctionDeclaration.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 3 | function* f() { 4 | function g() { 5 | return 42; 6 | } 7 | yield g; 8 | } 9 | 10 | assert.equal(42, f().next().value()); 11 | 12 | })(); 13 | -------------------------------------------------------------------------------- /test/feature/Yield/GeneratorWithoutYieldOrReturn.js: -------------------------------------------------------------------------------- 1 | var x = 0; 2 | 3 | function* f() { 4 | x++; 5 | } 6 | 7 | var g = f(); 8 | assert.equal(x, 0); 9 | assert.deepEqual(g.next(), {done: true, value: undefined}); 10 | assert.equal(x, 1); 11 | -------------------------------------------------------------------------------- /test/feature/Yield/Hoisting.js: -------------------------------------------------------------------------------- 1 | // f is declared at the end to test hoisting. 2 | 3 | var g = f(); 4 | assert.deepEqual(g.next(), {value: 2, done: false}); 5 | assert.deepEqual(g.next(), {value: undefined, done: true}); 6 | 7 | function* f() { 8 | yield 1; 9 | } 10 | 11 | function* f() { 12 | yield 2; 13 | } -------------------------------------------------------------------------------- /test/feature/Yield/IfStatementWithYield.js: -------------------------------------------------------------------------------- 1 | function* f(x) { 2 | if (yield x) { 3 | return 2; 4 | } 5 | return 3; 6 | } 7 | 8 | var g = f(1); 9 | assert.deepEqual(g.next(), {value: 1, done: false}); 10 | assert.deepEqual(g.next(true), {value: 2, done: true}); 11 | 12 | g = f(4); 13 | assert.deepEqual(g.next(), {value: 4, done: false}); 14 | assert.deepEqual(g.next(false), {value: 3, done: true}); 15 | -------------------------------------------------------------------------------- /test/feature/Yield/LabelledBlockGenerator.js: -------------------------------------------------------------------------------- 1 | var i = 0; 2 | var s = ''; 3 | 4 | function* f() { 5 | s += 'a'; 6 | while(i++ < 3) { 7 | s += 'b'; 8 | label1: { 9 | s += 'c'; 10 | break label1; 11 | s += 'd'; 12 | } 13 | s += 'e'; 14 | } 15 | s += 'f'; 16 | } 17 | 18 | var g = f(); 19 | g.next(); 20 | assert.equal(s, 'abcebcebcef'); 21 | -------------------------------------------------------------------------------- /test/feature/Yield/OverrideGenerator.js: -------------------------------------------------------------------------------- 1 | function* f() { 2 | yield 1; 3 | } 4 | 5 | var f2 = f; 6 | 7 | f = 42; 8 | 9 | var g = f2(); 10 | 11 | assert.deepEqual(g.next(), {value: 1, done: false}); 12 | assert.deepEqual(g.next(), {value: undefined, done: true}); 13 | 14 | assert.instanceOf(g, f2); 15 | -------------------------------------------------------------------------------- /test/feature/Yield/ReturnCatch.js: -------------------------------------------------------------------------------- 1 | function* f () { 2 | try { 3 | yield 1; 4 | } catch (e) { 5 | f.x = 2; 6 | } finally { 7 | f.y = 3; 8 | } 9 | } 10 | 11 | var g = f(); 12 | assert.deepEqual(g.next(), {value: 1, done: false}); 13 | assert.deepEqual(g.return(3), {value: 3, done: true}); 14 | assert.equal(f.x, undefined); 15 | assert.equal(f.y, 3); 16 | 17 | -------------------------------------------------------------------------------- /test/feature/Yield/ReturnYieldFor.js: -------------------------------------------------------------------------------- 1 | function* f() { 2 | return yield* h(); 3 | } 4 | 5 | function* h() { 6 | yield 111; 7 | yield 222; 8 | return 333; 9 | } 10 | 11 | var g = f(); 12 | 13 | assert.deepEqual({value: 111, done: false}, g.next()); 14 | assert.deepEqual({value: 222, done: false}, g.next()); 15 | assert.deepEqual({value: 333, done: true}, g.next()); 16 | -------------------------------------------------------------------------------- /test/feature/Yield/SimpleGenerator.js: -------------------------------------------------------------------------------- 1 | function* simpleGenerator() { 2 | yield 1; 3 | } 4 | 5 | function accumulate(iterator) { 6 | var result = ''; 7 | for (var value of iterator) { 8 | result = result + String(value); 9 | } 10 | return result; 11 | } 12 | 13 | // ---------------------------------------------------------------------------- 14 | 15 | assert.equal('1', accumulate(simpleGenerator())); 16 | -------------------------------------------------------------------------------- /test/feature/Yield/This.js: -------------------------------------------------------------------------------- 1 | function* f() { 2 | yield this; 3 | } 4 | 5 | var o = {}; 6 | for (var x of f.call(o)) { 7 | assert.equal(o, x); 8 | } 9 | -------------------------------------------------------------------------------- /test/feature/Yield/ThrowInCatch.js: -------------------------------------------------------------------------------- 1 | function* f() { 2 | try { 3 | yield 1; 4 | throw 'caught'; 5 | } catch (e) { 6 | throw 'ex'; 7 | } finally { 8 | f.x = 2; 9 | } 10 | } 11 | 12 | var g = f(); 13 | assert.deepEqual(g.next(), {value: 1, done: false}); 14 | assert.throws(() => g.next(), 'ex'); 15 | assert.equal(f.x, 2); 16 | -------------------------------------------------------------------------------- /test/instantiate/b.js: -------------------------------------------------------------------------------- 1 | export var b = 2; 2 | -------------------------------------------------------------------------------- /test/instantiate/circular1.js: -------------------------------------------------------------------------------- 1 | import {fn2, variable2} from './circular2.js'; 2 | 3 | export var variable1 = 'test circular 1'; 4 | 5 | fn2(); 6 | 7 | export var output; 8 | 9 | export function fn1() { 10 | output = variable2; 11 | } -------------------------------------------------------------------------------- /test/instantiate/circular2.js: -------------------------------------------------------------------------------- 1 | import {fn1, variable1} from './circular1.js'; 2 | 3 | export var variable2 = 'test circular 2'; 4 | 5 | fn1(); 6 | 7 | export var output; 8 | 9 | export function fn2() { 10 | output = variable1; 11 | } -------------------------------------------------------------------------------- /test/instantiate/circular_annotation1.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations --types 2 | import {FooAnnotation} from './circular_annotation2.js'; 3 | 4 | @FooAnnotation 5 | export class BarAnnotation { 6 | constructor(@FooAnnotation foo1, foo2: FooAnnotation) {} 7 | } 8 | -------------------------------------------------------------------------------- /test/instantiate/circular_annotation2.js: -------------------------------------------------------------------------------- 1 | // Options: --annotations --types 2 | import {BarAnnotation} from './circular_annotation1.js'; 3 | 4 | @BarAnnotation 5 | export class FooAnnotation { 6 | constructor(@BarAnnotation bar1, bar2: BarAnnotation) { 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/instantiate/export-default-class.js: -------------------------------------------------------------------------------- 1 | export default class F { 2 | foo() { 3 | return 'foo'; 4 | } 5 | } -------------------------------------------------------------------------------- /test/instantiate/export-default-fn.js: -------------------------------------------------------------------------------- 1 | export default { 2 | fn: function bar() { 3 | 4 | function test() { 5 | } 6 | 7 | function foo() { 8 | test(); 9 | } 10 | 11 | return { 12 | foo: foo 13 | } 14 | } 15 | }; -------------------------------------------------------------------------------- /test/instantiate/export-default.js: -------------------------------------------------------------------------------- 1 | export default 42; 2 | -------------------------------------------------------------------------------- /test/instantiate/export-destructuring.js: -------------------------------------------------------------------------------- 1 | export var {x, y = 2} = {x: 1}, 2 | f = () => { x = 3; }; 3 | -------------------------------------------------------------------------------- /test/instantiate/export-forward-default.js: -------------------------------------------------------------------------------- 1 | // Options: --export-from-extended 2 | 3 | export a from './export-default.js'; 4 | -------------------------------------------------------------------------------- /test/instantiate/export-star-as.js: -------------------------------------------------------------------------------- 1 | export * as a from './b.js'; 2 | -------------------------------------------------------------------------------- /test/instantiate/export.js: -------------------------------------------------------------------------------- 1 | export var p = 5; 2 | export function foo() {}; 3 | export var q = {}; 4 | 5 | export default function bar() {}; 6 | 7 | var s = 4; 8 | 9 | export {s}; 10 | export {s as t, q as m}; -------------------------------------------------------------------------------- /test/instantiate/generator.js: -------------------------------------------------------------------------------- 1 | export function* generator() { 2 | yield 1; 3 | } 4 | -------------------------------------------------------------------------------- /test/instantiate/hoisting.js: -------------------------------------------------------------------------------- 1 | export var a; 2 | a = 1; 3 | -------------------------------------------------------------------------------- /test/instantiate/inheritance.js: -------------------------------------------------------------------------------- 1 | export class Foo { 2 | }; 3 | 4 | export class Bar extends Foo { 5 | constructor() { 6 | super(); 7 | } 8 | }; 9 | 10 | export var test = new Bar(); 11 | -------------------------------------------------------------------------------- /test/instantiate/module-import.js: -------------------------------------------------------------------------------- 1 | /* 2 | Becomes: 3 | 4 | System.register(["./export-reassignment"], function($__export) { 5 | "use strict"; 6 | var M; 7 | return { 8 | setters: [function(m) { 9 | M = m; 10 | }], 11 | execute: function() { 12 | $__export('default', M.a); 13 | } 14 | }; 15 | }); 16 | */ 17 | 18 | import * as M from './export-reassignment.js'; 19 | export default M.a; -------------------------------------------------------------------------------- /test/instantiate/module-name.js: -------------------------------------------------------------------------------- 1 | export var name = __moduleName; 2 | 3 | export function f(__moduleName) { 4 | return __moduleName; 5 | } -------------------------------------------------------------------------------- /test/instantiate/postfix-operator.js: -------------------------------------------------------------------------------- 1 | export var a = 5; 2 | export var b = a++; 3 | export var c = a--; 4 | export var d = a; 5 | 6 | -------------------------------------------------------------------------------- /test/instantiate/rebinding.js: -------------------------------------------------------------------------------- 1 | export var p = 4; -------------------------------------------------------------------------------- /test/instantiate/reexport-binding.js: -------------------------------------------------------------------------------- 1 | import {p} from './rebinding.js'; 2 | -------------------------------------------------------------------------------- /test/instantiate/reexport1.js: -------------------------------------------------------------------------------- 1 | export * from './export.js'; -------------------------------------------------------------------------------- /test/instantiate/shorthand.js: -------------------------------------------------------------------------------- 1 | import {p} from './rebinding.js'; 2 | import {foo} from './export.js'; 3 | 4 | export var vars = {p, foo}; 5 | -------------------------------------------------------------------------------- /test/manual/browser_error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /test/modular/README.md: -------------------------------------------------------------------------------- 1 | tools/gulp 2 | 3 | ./modularTests.js 4 | Applies unitTests.js to tests.js 5 | 6 | ./unitTests.js 7 | Configures Mocha6 to run Tracuer tests. 8 | 9 | ./tests.js 10 | Imports all test modules, eg test/unit/util/url.js 11 | 12 | ../../unit/util/url.js 13 | Example modular test, a module that calls suite() to install a test. 14 | 15 | ./Mocha6.js 16 | Adapts mocha to es6. 17 | 18 | -------------------------------------------------------------------------------- /test/node-commonjs-test.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | 3 | var COMPILED_DIR = __dirname + '/commonjs-compiled'; 4 | 5 | function onlyJsFiles(path) { 6 | return /\.js$/.test(path); 7 | } 8 | 9 | var testFiles = fs.readdirSync(COMPILED_DIR).filter(onlyJsFiles); 10 | 11 | suite('commonjs', function() { 12 | testFiles.forEach(function(testFile) { 13 | test(testFile, function() { 14 | require('./commonjs-compiled/' + testFile); 15 | }); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /test/unit/node/resources/aDeeperModule.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | aNodeExport: 'intoTraceur' 3 | }; 4 | -------------------------------------------------------------------------------- /test/unit/node/resources/aNodeModule.js: -------------------------------------------------------------------------------- 1 | var requiredDeeper = require('./aDeeperModule.js'); 2 | module.exports = { 3 | aNodeExport: requiredDeeper.aNodeExport 4 | }; -------------------------------------------------------------------------------- /test/unit/node/resources/async-function.js: -------------------------------------------------------------------------------- 1 | async function foo() {} 2 | export {foo}; 3 | -------------------------------------------------------------------------------- /test/unit/node/resources/checkRequire.js: -------------------------------------------------------------------------------- 1 | // This file can be loaded by traceur and node. 2 | var assert = require('chai').assert; 3 | var traceurRequire = require('../../../src/node/require.js'); 4 | assert(traceurRequire); 5 | -------------------------------------------------------------------------------- /test/unit/node/resources/class.js: -------------------------------------------------------------------------------- 1 | class B { 2 | constructor(x) { 3 | this.x = x; 4 | } 5 | method() { 6 | return 1; 7 | } 8 | } 9 | 10 | class C extends B { 11 | method() { 12 | return super.method() + this.x; 13 | } 14 | } 15 | 16 | var result = new C(1).method(); 17 | -------------------------------------------------------------------------------- /test/unit/node/resources/compile-dir/dep.js: -------------------------------------------------------------------------------- 1 | export var q = 'q'; 2 | -------------------------------------------------------------------------------- /test/unit/node/resources/compile-dir/file.js: -------------------------------------------------------------------------------- 1 | import {q} from './dep.js'; 2 | export var p = 'module'; 3 | -------------------------------------------------------------------------------- /test/unit/node/resources/export-default-class.js: -------------------------------------------------------------------------------- 1 | export default class Q { 2 | foo() { 3 | console.log('class method'); 4 | } 5 | get name() { 6 | return 'Q'; 7 | } 8 | } 9 | var p = 5; 10 | -------------------------------------------------------------------------------- /test/unit/node/resources/export-default-function.js: -------------------------------------------------------------------------------- 1 | export default function f() { 2 | return 1; 3 | } 4 | -------------------------------------------------------------------------------- /test/unit/node/resources/export-default.js: -------------------------------------------------------------------------------- 1 | export class q { 2 | foo() { 3 | console.log('class method'); 4 | } 5 | } 6 | export default q; 7 | var p = 5; 8 | -------------------------------------------------------------------------------- /test/unit/node/resources/generator.js: -------------------------------------------------------------------------------- 1 | function* f(x, y) { 2 | yield x; 3 | yield y; 4 | } 5 | 6 | var result = []; 7 | 8 | for (var value of f(1, 2)) { 9 | result.push(value); 10 | } 11 | 12 | for (var value of (for (x of f(3, 4)) x * x)) { 13 | result.push(value); 14 | } 15 | -------------------------------------------------------------------------------- /test/unit/node/resources/glob-normal.js: -------------------------------------------------------------------------------- 1 | this.normalResult = true; -------------------------------------------------------------------------------- /test/unit/node/resources/glob-pattern-a.js: -------------------------------------------------------------------------------- 1 | const g = typeof global !== 'undefined' ? global : 2 | typeof window !== 'undefined' ? window : undefined; 3 | g.anotherResult = 17; 4 | -------------------------------------------------------------------------------- /test/unit/node/resources/glob-pattern-b.js: -------------------------------------------------------------------------------- 1 | const g = typeof global !== 'undefined' ? global : 2 | typeof window !== 'undefined' ? window : undefined; 3 | g.someResult = 42; 4 | -------------------------------------------------------------------------------- /test/unit/node/resources/golden-amd/dep.js: -------------------------------------------------------------------------------- 1 | define([], function() { 2 | "use strict"; 3 | var q = 'q'; 4 | return { 5 | get q() { 6 | return q; 7 | }, 8 | __esModule: true 9 | }; 10 | }); 11 | -------------------------------------------------------------------------------- /test/unit/node/resources/golden-amd/file.js: -------------------------------------------------------------------------------- 1 | define(["./dep"], function($__0) { 2 | "use strict"; 3 | if (!$__0 || !$__0.__esModule) 4 | $__0 = {default: $__0}; 5 | var q = $__0.q; 6 | var p = 'module'; 7 | return { 8 | get p() { 9 | return p; 10 | }, 11 | __esModule: true 12 | }; 13 | }); 14 | -------------------------------------------------------------------------------- /test/unit/node/resources/golden-cjs/dep.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperties(module.exports, { 3 | __esModule: {value: true}, 4 | q: { 5 | enumerable: true, 6 | get: function() { 7 | return q; 8 | } 9 | } 10 | }); 11 | var q = 'q'; 12 | -------------------------------------------------------------------------------- /test/unit/node/resources/golden-cjs/file.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperties(module.exports, { 3 | __esModule: {value: true}, 4 | p: { 5 | enumerable: true, 6 | get: function() { 7 | return p; 8 | } 9 | } 10 | }); 11 | var q = require("./dep.js").q; 12 | var p = 'module'; 13 | -------------------------------------------------------------------------------- /test/unit/node/resources/iAmScript.js: -------------------------------------------------------------------------------- 1 | var iAmScript; 2 | iAmScript = true; // The last statement becomes the value of the Script. -------------------------------------------------------------------------------- /test/unit/node/resources/iAmScriptAlso.es: -------------------------------------------------------------------------------- 1 | var iAmScript; 2 | iAmScript = true; // The last statement becomes the value of the Script. -------------------------------------------------------------------------------- /test/unit/node/resources/import-another-x.js: -------------------------------------------------------------------------------- 1 | export var iAmNotScript = true; 2 | this.anotherResult = 17; // To verify execution, test this global value. 3 | -------------------------------------------------------------------------------- /test/unit/node/resources/import-export.js: -------------------------------------------------------------------------------- 1 | import Q from './export-default-class.js'; 2 | export {Q}; 3 | -------------------------------------------------------------------------------- /test/unit/node/resources/import-x.js: -------------------------------------------------------------------------------- 1 | import {x} from './reexport-x.js'; 2 | const g = typeof global !== 'undefined' ? global : 3 | typeof window !== 'undefined' ? window : undefined; 4 | g.result = x; // To verify execution, test this global value. 5 | -------------------------------------------------------------------------------- /test/unit/node/resources/let-x.js: -------------------------------------------------------------------------------- 1 | export let x = 'x'; 2 | -------------------------------------------------------------------------------- /test/unit/node/resources/module-global.js: -------------------------------------------------------------------------------- 1 | // Tests that the global this is undefined in modules. 2 | export var aModular = typeof this; 3 | -------------------------------------------------------------------------------- /test/unit/node/resources/only-export.js: -------------------------------------------------------------------------------- 1 | export var x = 6; -------------------------------------------------------------------------------- /test/unit/node/resources/reexport-x.js: -------------------------------------------------------------------------------- 1 | export {x} from "./x.js"; 2 | -------------------------------------------------------------------------------- /test/unit/node/resources/register-module-bindings.js: -------------------------------------------------------------------------------- 1 | export class q extends p() { 2 | 3 | } 4 | export function p() { 5 | return {}; 6 | } -------------------------------------------------------------------------------- /test/unit/node/resources/scriptUsesModuleGlobal.js: -------------------------------------------------------------------------------- 1 | (function(global) { 2 | global.sandwich = global.aGlobal + ' pastrami'; 3 | }(typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this)); 4 | -------------------------------------------------------------------------------- /test/unit/node/resources/subdir/requireAndImport.js: -------------------------------------------------------------------------------- 1 | import {x} from '../reexport-x.js'; 2 | var path = require('path'); 3 | var aNodeModule = require('../aNodeModule.js'); 4 | export var testForRequireAndImport = 5 | `we have path and x=${x} and aNodeExport=${aNodeModule.aNodeExport}`; 6 | -------------------------------------------------------------------------------- /test/unit/node/resources/syntax-error.js: -------------------------------------------------------------------------------- 1 | syntax error -------------------------------------------------------------------------------- /test/unit/node/resources/testErrorForSourceMaps.js: -------------------------------------------------------------------------------- 1 | // Lots of blank lines to make the line numbers clearly wrong. 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | throw new Error('Test error on line 13'); -------------------------------------------------------------------------------- /test/unit/node/resources/testForRequireAndImport.js: -------------------------------------------------------------------------------- 1 | import {testForRequireAndImport} from './subdir/requireAndImport.js'; 2 | console.log(testForRequireAndImport); 3 | -------------------------------------------------------------------------------- /test/unit/node/resources/test_tval.js: -------------------------------------------------------------------------------- 1 | // Verify process.argv in a file of es6 code. 2 | let theArgs = process.argv.slice(2); 3 | console.log(['args', ...theArgs].join('')); 4 | 5 | var checkRequire = require('./iAmScript.js'); 6 | -------------------------------------------------------------------------------- /test/unit/node/resources/x.js: -------------------------------------------------------------------------------- 1 | export var x = 'x'; 2 | -------------------------------------------------------------------------------- /test/unit/runtime/loads/deperror.js: -------------------------------------------------------------------------------- 1 | function causeAnError() { 2 | throw new Error('dep error'); 3 | } 4 | 5 | function seeAStack() { 6 | causeAnError(); 7 | } 8 | 9 | seeAStack(); -------------------------------------------------------------------------------- /test/unit/runtime/loads/main.js: -------------------------------------------------------------------------------- 1 | import "./deperror.js"; 2 | -------------------------------------------------------------------------------- /test/unit/runtime/resources/CallsThrowsError.js: -------------------------------------------------------------------------------- 1 | import {A} from './throwsErrorES6.js'; 2 | new A().foo(); 3 | -------------------------------------------------------------------------------- /test/unit/runtime/resources/side-effect.js: -------------------------------------------------------------------------------- 1 | testGlobal.sideEffect = 6; 2 | export var currentSideEffect = () => testGlobal.sideEffect; 3 | -------------------------------------------------------------------------------- /test/unit/runtime/resources/test_a.js: -------------------------------------------------------------------------------- 1 | export var name = 'A'; 2 | -------------------------------------------------------------------------------- /test/unit/runtime/resources/test_b.js: -------------------------------------------------------------------------------- 1 | import * as c from './test_c.js'; 2 | 3 | export var name = 'B'; 4 | -------------------------------------------------------------------------------- /test/unit/runtime/resources/test_c.js: -------------------------------------------------------------------------------- 1 | export var name = 'C'; 2 | -------------------------------------------------------------------------------- /test/unit/runtime/resources/test_module.js: -------------------------------------------------------------------------------- 1 | export {name as a} from './test_a.js'; 2 | export {name as b} from './test_b.js'; 3 | export {name as c} from './test_c.js'; 4 | 5 | export var name = 'test'; 6 | -------------------------------------------------------------------------------- /test/unit/runtime/resources/test_script.js: -------------------------------------------------------------------------------- 1 | var a = 'A'; 2 | var b = 'B'; 3 | var c = 'C'; 4 | 5 | [a, b, c]; 6 | -------------------------------------------------------------------------------- /test/unit/runtime/resources/test_source_map_module.js: -------------------------------------------------------------------------------- 1 | export {name as a} from './test_a.js'; 2 | export {name as b} from './test_b.js'; 3 | export {name as c} from './test_c.js'; 4 | 5 | export var name = 'test'; 6 | -------------------------------------------------------------------------------- /test/unit/runtime/resources/throwsError.js: -------------------------------------------------------------------------------- 1 | throw new Error('test-intepreter'); -------------------------------------------------------------------------------- /test/unit/runtime/resources/throwsError.output: -------------------------------------------------------------------------------- 1 | ./traceur test/unit/runtime/throwsError.js 2>&1 | wc -l 2 | 11 3 | -------------------------------------------------------------------------------- /test/unit/runtime/resources/throwsErrorES6.js: -------------------------------------------------------------------------------- 1 | export class A { 2 | foo() { 3 | throw new Error('test-intepreter'); 4 | } 5 | } 6 | 7 | -------------------------------------------------------------------------------- /test/unit/runtime/subdir/test_d.js: -------------------------------------------------------------------------------- 1 | import * as e from './test_e.js'; 2 | export {e}; 3 | export var name = 'D'; 4 | -------------------------------------------------------------------------------- /test/unit/runtime/subdir/test_e.js: -------------------------------------------------------------------------------- 1 | export var name = 'E'; 2 | -------------------------------------------------------------------------------- /test/unit/tools/HTMLImportTranscoder/basic/a.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | -------------------------------------------------------------------------------- /test/unit/tools/HTMLImportTranscoder/basic/b.html: -------------------------------------------------------------------------------- 1 | 4 | 5 | -------------------------------------------------------------------------------- /test/unit/tools/HTMLImportTranscoder/import-order/a.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /test/unit/tools/HTMLImportTranscoder/import-order/b.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /test/unit/tools/HTMLImportTranscoder/import-order/c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /test/unit/tools/HTMLImportTranscoder/import-order/d.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /test/unit/tools/HTMLImportTranscoder/import-order/e.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /test/unit/tools/HTMLImportTranscoder/import-order/f.html: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /test/unit/tools/HTMLImportTranscoder/import-order/g.html: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /test/unit/tools/HTMLImportTranscoder/import-order/h.html: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /test/wiki/.gitignore: -------------------------------------------------------------------------------- 1 | !out -------------------------------------------------------------------------------- /test/wiki/CompilingOffline/UsingCompiledFiles.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | You should see "Hi!" in your console. 7 | 8 | -------------------------------------------------------------------------------- /test/wiki/CompilingOffline/deepDirectory/src/js/app.js: -------------------------------------------------------------------------------- 1 | import {Greeter} from './greeter.js'; 2 | 3 | var greeter = new Greeter(); 4 | greeter.sayHi(); -------------------------------------------------------------------------------- /test/wiki/CompilingOffline/deepDirectory/src/js/greeter.js: -------------------------------------------------------------------------------- 1 | // greeter.js 2 | export class Greeter { 3 | sayHi() { console.log('Hi!'); } 4 | } 5 | -------------------------------------------------------------------------------- /test/wiki/CompilingOffline/greeter.js: -------------------------------------------------------------------------------- 1 | // greeter.js 2 | class Greeter { 3 | sayHi() { console.log('Hi!'); } 4 | } 5 | 6 | var greeter = new Greeter(); 7 | greeter.sayHi(); -------------------------------------------------------------------------------- /third_party/CodeMirror-4.0.3/.gitattributes: -------------------------------------------------------------------------------- 1 | *.txt text 2 | *.js text 3 | *.html text 4 | *.md text 5 | *.json text 6 | *.yml text 7 | *.css text 8 | *.svg text 9 | -------------------------------------------------------------------------------- /third_party/CodeMirror-4.0.3/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /npm-debug.log 3 | test.html 4 | .tern-* 5 | *~ 6 | *.swp 7 | -------------------------------------------------------------------------------- /third_party/CodeMirror-4.0.3/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 0.8 4 | -------------------------------------------------------------------------------- /third_party/CodeMirror-4.0.3/addon/display/fullscreen.css: -------------------------------------------------------------------------------- 1 | .CodeMirror-fullscreen { 2 | position: fixed; 3 | top: 0; left: 0; right: 0; bottom: 0; 4 | height: auto; 5 | z-index: 9; 6 | } 7 | -------------------------------------------------------------------------------- /third_party/CodeMirror-4.0.3/bin/authors.sh: -------------------------------------------------------------------------------- 1 | # Combine existing list of authors with everyone known in git, sort, add header. 2 | tail --lines=+3 AUTHORS > AUTHORS.tmp 3 | git log --format='%aN' >> AUTHORS.tmp 4 | echo -e "List of CodeMirror contributors. Updated before every release.\n" > AUTHORS 5 | sort -u AUTHORS.tmp >> AUTHORS 6 | rm -f AUTHORS.tmp 7 | -------------------------------------------------------------------------------- /third_party/CodeMirror-4.0.3/bin/lint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var lint = require("../test/lint/lint"), 4 | path = require("path"); 5 | 6 | if (process.argv.length > 2) { 7 | lint.checkDir(process.argv[2]); 8 | } else { 9 | process.chdir(path.resolve(__dirname, "..")); 10 | lint.checkDir("lib"); 11 | lint.checkDir("mode"); 12 | lint.checkDir("addon"); 13 | lint.checkDir("keymap"); 14 | } 15 | 16 | process.exit(lint.success() ? 0 : 1); 17 | -------------------------------------------------------------------------------- /third_party/CodeMirror-4.0.3/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CodeMirror", 3 | "main": ["lib/codemirror.js", "lib/codemirror.css"], 4 | "ignore": [ 5 | "**/.*", 6 | "node_modules", 7 | "components", 8 | "bin", 9 | "demo", 10 | "doc", 11 | "test", 12 | "index.html", 13 | "package.json" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /third_party/CodeMirror-4.0.3/doc/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/traceur-compiler/0b6b96fa1ed48d77ca6908bd52ea735a9ad8f32e/third_party/CodeMirror-4.0.3/doc/logo.png -------------------------------------------------------------------------------- /third_party/CodeMirror-4.0.3/mode/ruby/test.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var mode = CodeMirror.getMode({indentUnit: 2}, "ruby"); 3 | function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } 4 | 5 | MT("divide_equal_operator", 6 | "[variable bar] [operator /=] [variable foo]"); 7 | 8 | MT("divide_equal_operator_no_spacing", 9 | "[variable foo][operator /=][number 42]"); 10 | 11 | })(); 12 | -------------------------------------------------------------------------------- /third_party/CodeMirror-4.0.3/mode/tiddlywiki/tiddlywiki.css: -------------------------------------------------------------------------------- 1 | span.cm-underlined { 2 | text-decoration: underline; 3 | } 4 | span.cm-strikethrough { 5 | text-decoration: line-through; 6 | } 7 | span.cm-brace { 8 | color: #170; 9 | font-weight: bold; 10 | } 11 | span.cm-table { 12 | color: blue; 13 | font-weight: bold; 14 | } 15 | -------------------------------------------------------------------------------- /third_party/CodeMirror-4.0.3/test/mode_test.css: -------------------------------------------------------------------------------- 1 | .mt-output .mt-token { 2 | border: 1px solid #ddd; 3 | white-space: pre; 4 | font-family: "Consolas", monospace; 5 | text-align: center; 6 | } 7 | 8 | .mt-output .mt-style { 9 | font-size: x-small; 10 | } 11 | -------------------------------------------------------------------------------- /third_party/CodeMirror-4.0.3/theme/ambiance-mobile.css: -------------------------------------------------------------------------------- 1 | .cm-s-ambiance.CodeMirror { 2 | -webkit-box-shadow: none; 3 | -moz-box-shadow: none; 4 | box-shadow: none; 5 | } 6 | -------------------------------------------------------------------------------- /third_party/README: -------------------------------------------------------------------------------- 1 | https://github.com/marijnh/codemirror 2 | -------------------------------------------------------------------------------- /third_party/es6-module-loader/index.js: -------------------------------------------------------------------------------- 1 | if (!global.traceur) 2 | require('traceur'); 3 | module.exports = { 4 | Loader: require('./loader'), 5 | System: require('./system') 6 | }; 7 | -------------------------------------------------------------------------------- /tools/find-unused-imports.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var System = require('../src/node/System.js'); 3 | 4 | System.baseURL = __filename; 5 | System.import('./findUnusedImports.js').then(function(m) { 6 | var code = m.main(fs); 7 | process.exit(code); 8 | }).catch(function(err) { 9 | console.error(err); 10 | process.exit(1); 11 | }); 12 | -------------------------------------------------------------------------------- /traceur: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | require('./src/node/command.js'); 4 | -------------------------------------------------------------------------------- /traceur-build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | require('./build/node/command.js'); 4 | --------------------------------------------------------------------------------