001    /*
002     * Copyright 2010-2015 JetBrains s.r.o.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.jetbrains.kotlin.js.translate.test;
018    
019    import com.google.dart.compiler.backend.js.ast.JsBlock;
020    import com.google.dart.compiler.backend.js.ast.JsExpression;
021    import com.google.dart.compiler.backend.js.ast.JsStringLiteral;
022    import org.jetbrains.annotations.NotNull;
023    import org.jetbrains.annotations.Nullable;
024    import org.jetbrains.kotlin.js.translate.context.TranslationContext;
025    
026    public abstract class JSTester {
027    
028        @Nullable
029        private JsBlock block;
030    
031        @Nullable
032        private TranslationContext context;
033    
034        public JSTester() {
035            this.block = null;
036            this.context = null;
037        }
038    
039        public abstract void constructTestMethodInvocation(@NotNull JsExpression call, @NotNull JsStringLiteral name);
040    
041        @NotNull
042        protected JsBlock getBlock() {
043            assert block != null : "Call initialize before using tester.";
044            return block;
045        }
046    
047        @NotNull
048        protected TranslationContext getContext() {
049            assert context != null : "Call initialize before using tester.";
050            return context;
051        }
052    
053        public void initialize(@NotNull TranslationContext context, @NotNull JsBlock block) {
054            this.block = block;
055            this.context = context;
056        }
057    
058        public void deinitialize() {
059            this.block = null;
060            this.context = null;
061        }
062    }