package net.qiujuer.tips.factory.view;

import net.qiujuer.tips.factory.util.TipsCalender;

import java.util.UUID;

public interface RecordEditView extends RecordAddView {
    UUID getId();

    void setType(int type);

    void setBrief(String title);

    void setDate(TipsCalender date);

    void setColor(int color);

    void setContactName(String name);
}


#! FIELDS phi projection
#! SET min_phi -pi
#! SET max_phi pi
#! SET nbins_phi  100
#! SET periodic_phi true
   -3.141592654   68.585848989
   -3.078760801   67.223659404
   -3.015928947   65.776157215
   -2.953097094   64.374021180
   -2.890265241   63.180311593
   -2.827433388   62.366468566
   -2.764601535   62.067386942
   -2.701769682   62.321903341
   -2.638937829   63.014807524
   -2.576105976   63.885757021
   -2.513274123   64.700820473
   -2.450442270   65.420932364
   -2.387610417   66.106524172
   -2.324778564   66.772520608
   -2.261946711   67.365189258
   -2.199114858   67.770205418
   -2.136283004   67.751305742
   -2.073451151   66.666246909
   -2.010619298   63.324801595
   -1.947787445   57.622512856
   -1.884955592   50.506518183
   -1.822123739   42.553901742
   -1.759291886   34.161906600
   -1.696460033   25.756531404
   -1.633628180   17.813707586
   -1.570796327   10.830069381
   -1.507964474    5.279794306
   -1.445132621    1.569723767
   -1.382300768    0.000000000
   -1.319468915    0.734691797
   -1.256637061    3.784854706
   -1.193805208    9.004957229
   -1.130973355   16.102299050
   -1.068141502   24.657716237
   -1.005309649   34.154406245
   -0.942477796   44.010212671
   -0.879645943   53.605451398
   -0.816814090   62.252764557
   -0.753982237   68.822224395
   -0.691150384   72.116376776
   -0.628318531   73.341770591
   -0.565486678   73.782288942
   -0.502654825   73.798919906
   -0.439822972   73.492888665
   -0.376991118   72.894857061
   -0.314159265   71.987461820
   -0.251327412   70.728488151
   -0.188495559   69.146467681
   -0.125663706   67.446671799
   -0.062831853   65.956785080
    0.000000000   64.971179394
    0.062831853   64.663633248
    0.125663706   65.074537022
    0.188495559   66.121404383
    0.251327412   67.611011033
    0.314159265   69.256421414
    0.376991118   70.732349878
    0.439822972   71.800698101
    0.502654825   72.407661155
    0.565486678   72.624494355
    0.628318531   72.537097227
    0.691150384   72.204089074
    0.753982237   71.659772174
    0.816814090   70.924668103
    0.879645943   70.019576761
    0.942477796   68.988335136
    1.005309649   67.921766503
    1.068141502   66.960046596
    1.130973355   66.262406182
    1.193805208   65.962427998
    1.256637061   66.132426908
    1.319468915   66.763898118
    1.382300768   67.761019377
    1.445132621   68.948355234
    1.507964474   70.106553986
    1.570796327   71.045997263
    1.633628180   71.674809036
    1.696460033   71.993126538
    1.759291886   72.036446551
    1.822123739   71.837298556
    1.884955592   71.418236576
    1.947787445   70.797565506
    2.010619298   69.998529405
    2.073451151   69.062640531
    2.136283004   68.065633223
    2.199114858   67.124648570
    2.261946711   66.384064279
    2.324778564   65.982929557
    2.387610417   66.019575044
    2.450442270   66.524406784
    2.513274123   67.442281324
    2.576105976   68.624726713
    2.638937829   69.844988856
    2.701769682   70.863943019
    2.764601535   71.531230372
    2.827433388   71.819096603
    2.890265241   71.759598900
    2.953097094   71.384536533
    3.015928947   70.714199472
    3.078760801   69.769498624


/*
 * Copyright (C) 2019. Uber Technologies
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package anotherpackage;

import static anotherpackage.DogTagTestUtil.getPreviousLineNumber;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;

import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Flowable;
import io.reactivex.rxjava3.core.Maybe;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.core.Single;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.exceptions.CompositeException;
import io.reactivex.rxjava3.exceptions.OnErrorNotImplementedException;
import io.reactivex.rxjava3.observers.TestObserver;
import io.reactivex.rxjava3.subjects.PublishSubject;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import rxdogtag2.RxDogTag;
import rxdogtag2.RxDogTagErrorReceiver;
import rxdogtag2.RxDogTagTaggedExceptionReceiver;

/**
 * NOTE: These tests are a little odd. There are two conditions for them running correctly because
 * they verify via inspecting stacktraces. 1. the throwError() method MUST calculate the line number
 * immediately after subscribe (on the next line). 2. it must not be in the rxdogtag2 package
 * because that is filtered out in stacktrace inspection.
 */
public class DogTagObserverTest implements DogTagTest {

  @Rule public RxErrorsRule errorsRule = new RxErrorsRule();

  @Before
  public void setUp() {
    RxDogTag.install();
  }

  @After
  public void tearDown() {
    RxDogTag.reset();
  }

  @Test
  public void testObservable() {
    Exception original = new RuntimeException("Blah");
    assertRewrittenStacktrace(subscribeError(Observable.error(original)), original);
  }

  @Test
  public void testFlowable() {
    Exception original = new RuntimeException("Blah");
    assertRewrittenStacktrace(subscribeError(Flowable.error(original)), original);
  }

  @Test
  public void testSingle() {
    Exception original = new RuntimeException("Blah");
    assertRewrittenStacktrace(subscribeError(Single.error(original)), original);
  }

  @Test
  public void testMaybe() {
    Exception original = new RuntimeException("Blah");
    assertRewrittenStacktrace(subscribeError(Maybe.error(original)), original);
  }

  @Test
  public void testCompletable() {
    Exception original = new RuntimeException("Blah");
    assertRewrittenStacktrace(subscribeError(Completable.error(original)), original);
  }

  @Test
  public void noConstructor_generatesStringFromStackElement_anonymous() {
    Exception originalError = new IllegalStateException("illegal state exception");
    assertRewrittenStacktrace(
        throwError(new EmptyObserver<Integer>() {}, originalError), originalError);
  }

  @Test
  public void noConstructor_generatesStringFromStackElement_instance() {
    Exception originalError = new IllegalStateException("illegal state exception");
    Observer<Integer> o = new EmptyObserver<Integer>() {};
    assertRewrittenStacktrace(throwError(o, originalError), originalError);
  }

  @Test
  public void noConstructor_generatesStringFromStackElement_subclass() {
    Exception originalError = new IllegalStateException("illegal state exception");
    Another o = new Another();
    assertRewrittenStacktrace(throwError(o, originalError), originalError);
  }

  @Test
  public void observerWithErrorHandling_ignoredByRxDogTag() {
    Exception originalError = new IllegalStateException("illegal state exception");
    // Test observer which custom error handling.
    TestObserver<Object> testObserver = Observable.error(originalError).test();
    // No errors intercepted by RxDogTag.
    errorsRule.assertNoErrors();

    testObserver.assertError(
        (error) -> {
          assertThat(error).isNotInstanceOf(OnErrorNotImplementedException.class);
          assertThat(error).hasMessageThat().isEqualTo(originalError.getMessage());
          assertThat(error.getStackTrace()).isNotEmpty();
          return true;
        });
  }

  @Test
  public void nullOriginErrorMessage_replacedWithEmptyString() {
    Exception originalError = new IllegalStateException();
    int expectedLineNumber = subscribeError(Observable.error(originalError));

    Throwable e = errorsRule.take();
    assertThat(e).isInstanceOf(OnErrorNotImplementedException.class);
    // Original error message was null. Now replaced by empty string
    assertThat(e).hasMessageThat().isNotEqualTo(originalError.getMessage());
    assertThat(e).hasMessageThat().isEqualTo("");

    assertThat(e.getStackTrace()).isEmpty();
    Throwable cause = e.getCause();
    assertThat(cause.getStackTrace()[0].getFileName())
        .isEqualTo(getClass().getSimpleName() + ".java");
    assertThat(cause.getStackTrace()[0].getLineNumber()).isEqualTo(expectedLineNumber);
    assertThat(cause.getStackTrace()[1].getClassName())
        .isEqualTo(RxDogTag.STACK_ELEMENT_SOURCE_HEADER);
    assertThat(cause.getStackTrace()[2].getClassName())
        .isEqualTo(RxDogTag.STACK_ELEMENT_TRACE_HEADER);
  }

  @Test
  public void compositeException() {
    IllegalStateException original = new IllegalStateException("Initial exception");
    RuntimeException runtimeException = new RuntimeException("Resulting exception");

    CompositeException compositeException = new CompositeException(original, runtimeException);
    int expectedLineNumber = subscribeError(Observable.error(compositeException));

    assertRewrittenStacktrace(expectedLineNumber, compositeException);
  }

  @Test
  public void mangledCompositeException() {
    Observable<Integer> mainObservable =
        Observable.concatDelayError(
            withError(
                Observable.just(
                    withError(
                        withError(Observable.just(1), new RuntimeException("1")),
                        new RuntimeException("2"))),
                new RuntimeException("3")));

    int expectedLineNumber = subscribeError(mainObservable);
    Throwable e = errorsRule.take();
    assertThat(e).isInstanceOf(OnErrorNotImplementedException.class);
    assertThat(e).hasMessageThat().isEqualTo("2 exceptions occurred. "); // For composite exception
    assertThat(e.getStackTrace()).isEmpty();
    Throwable cause = e.getCause();
    assertThat(cause.getStackTrace()[0].getFileName())
        .isEqualTo(getClass().getSimpleName() + ".java");
    assertThat(cause.getStackTrace()[0].getLineNumber()).isEqualTo(expectedLineNumber);
    assertThat(cause.getStackTrace()[1].getClassName())
        .isEqualTo(RxDogTag.STACK_ELEMENT_SOURCE_HEADER);
    assertThat(cause.getStackTrace()[2].getClassName())
        .isEqualTo(RxDogTag.STACK_ELEMENT_TRACE_HEADER);
  }

  @Test
  public void errorReceiver_noGuards() {
    RxDogTag.reset();
    RxDogTag.builder().guardObserverCallbacks(false).install();
    AtomicReference<Throwable> recordedError = new AtomicReference<>();
    TestErrorReceiver<Integer> o =
        new TestErrorReceiver<Integer>() {
          @Override
          public void onError(Throwable e) {
            recordedError.compareAndSet(null, e);
          }

          @Override
          public void onSubscribe(Disposable d) {}

          @Override
          public void onNext(Integer integer) {}

          @Override
          public void onComplete() {}
        };
    Exception original = new RuntimeException("Blah");
    Observable.<Integer>error(original).subscribe(o);
    Throwable recorded = recordedError.get();
    assertThat(recorded).isSameInstanceAs(original);
  }

  @Test
  public void errorReceiver_withGuard_noException() {
    RxDogTag.reset();
    RxDogTag.builder().guardObserverCallbacks(true).install();
    AtomicReference<Throwable> recordedError = new AtomicReference<>();
    TestErrorReceiver<Integer> o =
        new TestErrorReceiver<Integer>() {
          @Override
          public void onError(Throwable e) {
            recordedError.compareAndSet(null, e);
          }

          @Override
          public void onSubscribe(Disposable d) {}

          @Override
          public void onNext(Integer integer) {}

          @Override
          public void onComplete() {}
        };
    Exception original = new RuntimeException("Blah");
    Observable.<Integer>error(original).subscribe(o);
    Throwable recorded = recordedError.get();
    assertThat(recorded).isSameInstanceAs(original);
  }

  @Test
  public void errorReceiver_withGuard_withException() {
    RxDogTag.reset();
    RxDogTag.builder().guardObserverCallbacks(true).install();
    AtomicReference<Throwable> thrownException = new AtomicReference<>();
    TestErrorReceiver<Integer> o =
        new TestErrorReceiver<Integer>() {
          @Override
          public void onError(Throwable e) {
            RuntimeException toThrow = new RuntimeException(e);
            thrownException.compareAndSet(null, toThrow);
            throw toThrow;
          }

          @Override
          public void onSubscribe(Disposable d) {}

          @Override
          public void onNext(Integer integer) {}

          @Override
          public void onComplete() {}
        };
    Exception original = new RuntimeException("Blah");
    PublishSubject<Integer> subject = PublishSubject.create();
    // Can't do this one synchronously because it will fail in subscribe();
    subject.subscribe(o);
    int lineNumber = getPreviousLineNumber();
    subject.onError(original);
    Throwable recorded = errorsRule.take();
    Throwable thrown = thrownException.get();
    if (thrown == null) {
      // Partially more descriptive error message, partially to make NullAway happy since it doesn't
      // speak truth's isNotNull() assertions
      fail("thrown was null! This means the observer's onError was never called");
      return;
    }
    assertThat(thrown).hasCauseThat().isSameInstanceAs(original);
    assertThat(recorded).isInstanceOf(OnErrorNotImplementedException.class);
    assertThat(recorded).hasCauseThat().isSameInstanceAs(thrown);
    // The original cause was put in this
    assertThat(recorded).hasMessageThat().contains("java.lang.RuntimeException: Blah");

    // Slightly duplicated, but this is a special delegates case for onError
    Throwable cause = recorded.getCause();
    assertThat(cause).isNotNull();
    assertThat(cause.getStackTrace()[0].getFileName())
        .isEqualTo(getClass().getSimpleName() + ".java");
    assertThat(cause.getStackTrace()[0].getLineNumber()).isEqualTo(lineNumber);
    assertThat(cause.getStackTrace()[1].getClassName())
        .isEqualTo(RxDogTag.STACK_ELEMENT_SOURCE_HEADER);
    assertThat(cause.getStackTrace()[2].getClassName())
        .isEqualTo(String.format(Locale.US, RxDogTag.STACK_ELEMENT_SOURCE_DELEGATE, "onError"));
    assertThat(cause.getStackTrace()[3].getClassName())
        .isEqualTo(RxDogTag.STACK_ELEMENT_TRACE_HEADER);
  }

  @Test
  public void taggedErrorReceiver() {
    AtomicReference<Throwable> recordedError = new AtomicReference<>();
    TestTaggedErrorReceiver<Integer> o =
        new TestTaggedErrorReceiver<Integer>() {
          @Override
          public void onError(Throwable e) {
            recordedError.compareAndSet(null, e);
          }

          @Override
          public void onSubscribe(Disposable d) {}

          @Override
          public void onNext(Integer integer) {}

          @Override
          public void onComplete() {}
        };
    Exception original = new RuntimeException("Blah");
    Observable.<Integer>error(original).subscribe(o);
    int lineNumber = getPreviousLineNumber();
    Throwable recorded = recordedError.get();
    if (recorded == null) {
      fail("No exception recorded!");
    } else {
      assertRewrittenStacktrace(lineNumber, original, recorded);
    }
  }

  private interface TestTaggedErrorReceiver<T>
      extends RxDogTagTaggedExceptionReceiver, Observer<T> {}

  private interface TestErrorReceiver<T> extends RxDogTagErrorReceiver, Observer<T> {}

  /** This tests that the original stacktrace was rewritten with the relevant source information. */
  private void assertRewrittenStacktrace(int expectedLineNumber, Throwable original) {
    Throwable e = errorsRule.take();
    assertRewrittenStacktrace(expectedLineNumber, original, e);
  }
  /** This tests that the original stacktrace was rewritten with the relevant source information. */
  private void assertRewrittenStacktrace(
      int expectedLineNumber, Throwable original, Throwable recorded) {
    assertThat(recorded).isInstanceOf(OnErrorNotImplementedException.class);
    assertThat(recorded).hasMessageThat().isEqualTo(original.getMessage());
    assertThat(recorded.getStackTrace()).isEmpty();
    Throwable cause = recorded.getCause();
    assertThat(cause.getStackTrace()[0].getFileName())
        .isEqualTo(getClass().getSimpleName() + ".java");
    assertThat(cause.getStackTrace()[0].getLineNumber()).isEqualTo(expectedLineNumber);
    assertThat(cause.getStackTrace()[1].getClassName())
        .isEqualTo(RxDogTag.STACK_ELEMENT_SOURCE_HEADER);
    assertThat(cause.getStackTrace()[2].getClassName())
        .isEqualTo(RxDogTag.STACK_ELEMENT_TRACE_HEADER);
  }

  private static int subscribeError(Completable completable) {
    completable.subscribe();
    return getPreviousLineNumber();
  }

  private static <T> int subscribeError(Observable<T> observable) {
    observable.subscribe();
    return getPreviousLineNumber();
  }

  private static <T> int subscribeError(Maybe<T> maybe) {
    maybe.subscribe();
    return getPreviousLineNumber();
  }

  private static <T> int subscribeError(Single<T> single) {
    single.subscribe();
    return getPreviousLineNumber();
  }

  private static <T> int subscribeError(Flowable<T> flowable) {
    flowable.subscribe();
    return getPreviousLineNumber();
  }

  private static <T> int throwError(Observer<T> observer, Exception error) {
    Observable.<T>defer(() -> Observable.error(error)).subscribe(observer);
    return getPreviousLineNumber();
  }

  private static <T> Observable<T> withError(Observable<T> source, Exception exception) {
    return source.concatWith(Observable.error(exception));
  }

  private static class Another extends EmptyObserver<Object> {

    @Override
    public void onNext(Object unit) {}
  }
}


Android N引入了一种包含编译、解释和JIT（Just In Time）的混合运行时，以便在安装时间、内存占用、电池消耗和性能之间获得最好的折衷。

ART是在Android KitKat（译者注：Android 4.0）引入并在Lollipop（译者注：Android 5.0）中设为默认解决方案的主要特性之一，是当时的一种新的运行时。ART取代了Dalvik，但是前者与后者仍然保持了字节码级的兼容，因为前者仍在运行DEX文件。ART的主要特征之一就是安装时对应用的AOT编译。这种方式的主要优点就是优化产生的本地代码性能更好，执行起来需要更少的电量。劣势在于安装文件所需的空间和时间。在Lollipop和Marshmallow（译者注：Android 6.0）中，大的应用需要数分钟才能安装完。

Android N包含了一个混合模式的运行时。应用在安装时不做编译，而是解释字节码，所以可以快速启动。ART中有一种新的、更快的解释器，通过一种新的JIT完成，但是这种JIT的信息不是持久化的。取而代之的是，代码在执行期间被分析，分析结果保存起来。然后，当设备空转和充电的时候，ART会执行针对“热代码”进行的基于分析的编译，其他代码不做编译。为了得到更优的代码，ART采用了几种技巧包括深度内联。

对同一个应用可以编译数次，或者找到变“热”的代码路径或者对已经编译的代码进行新的优化，这取决于分析器在随后的执行中的分析数据。这个步骤仍被简称为AOT，可以理解为“全时段的编译”（All-Of-the-Time compilation）。

这种混合使用AOT、解释、JIT的策略的全部优点如下。

- 即使是大应用，安装时间也能缩短到几秒
- 系统升级能更快地安装，因为不再需要优化这一步
- 应用的内存占用更小，有些情况下可以降低50%
- 改善了性能
- 更低的电池消耗

[原文](https://www.jianshu.com/p/8d3701e3ee94)


<?php

/**
 * Created by PhpStorm.
 * User: domenico
 * Date: 23/02/15
 * Time: 14.54
 */

/**
 * Class Engine_MicrosoftHubStruct
 *
 * This class contains the default parameters for a Microsoft Hub Engine CREATION
 *
 */
class EnginesModel_MicrosoftHubStruct extends EnginesModel_EngineStruct {

    /**
     * @var string
     */
    public $description = "Microsoft Translator Hub";

    /**
     * @var string
     */
    public $base_url = "https://api.microsofttranslator.com/v2/Http.svc/";

    /**
     * @var string
     */
    public $translate_relative_url = "Translate";

    /**
     * @var array
     */
    public $others = array(
            'oauth_url' => 'https://api.cognitive.microsoft.com/sts/v1.0/issueToken'
    );

    /**
     * @var string
     */
    public $class_load = Constants_Engines::MICROSOFT_HUB;

    /**
     * @var array
     */
    public $extra_parameters = array(
            'token'         => null,
            'token_endlife' => 0,
            'client_id'     => "",
            'client_secret' => "",
            'category'      => "",
    );

    /**
     * @var int
     */
    public $google_api_compliant_version = 2;

    /**
     * @var int
     */
    public $penalty = 14;

    /**
     * An empty struct
     * @return EnginesModel_EngineStruct
     */
    public static function getStruct() {
        return new EnginesModel_MicrosoftHubStruct();
    }

}


from utils import *

def test_anima_golem():
	game = prepare_game()
	anima = game.player1.give("GVG_077")
	anima.play()
	wisp1 = game.player1.summon(WISP)
	wisp2 = game.player2.summon(WISP)
	game.end_turn()
	game.end_turn()

	assert not anima.dead
	wisp1.destroy()
	game.end_turn()

	assert anima.dead
	assert not wisp2.dead
	game.end_turn()

def test_ancestors_call():
	game = prepare_game()
	game.player1.discard_hand()
	game.player2.discard_hand()
	novice = game.player1.give("EX1_015")
	wisp = game.player2.give(WISP)
	call = game.player1.give("GVG_029")
	call.play()
	assert novice in game.player1.field
	assert wisp in game.player2.field
	assert not game.player1.hand
	assert not game.player2.hand

def test_blingtron_3000():
	game = prepare_game()
	blingtron = game.player1.give("GVG_119")
	blingtron.play()
	assert game.player1.weapon
	assert game.player2.weapon

def test_bolvar_fordragon():
	game = prepare_game()
	bolvar = game.player1.give("GVG_063")
	assert bolvar.atk == 1
	wisp = game.player1.give(WISP)
	wisp.play()
	game.player1.give(MOONFIRE).play(target=wisp)
	assert bolvar.atk == 2
	assert bolvar.buffs
	wisp = game.player1.give(WISP)
	wisp.play()
	game.player1.give(MOONFIRE).play(target=wisp)
	assert bolvar.atk == 3
	game.end_turn()
	game.end_turn()

	assert bolvar.atk == 3
	assert bolvar.buffs
	bolvar.play()
	assert bolvar.atk == 3
	assert bolvar.buffs
	# game.player1.give(DREAM).play(target=bolvar)
	# assert bolvar.atk == 1
	# assert not bolvar.buffs

def test_bomb_lobber():
	game = prepare_game()
	lobber1 = game.player1.give("GVG_099")
	lobber1.play()
	assert game.player2.hero.health == 30
	game.end_turn()

	wisp = game.player2.give(WISP)
	wisp.play()
	statue = game.player2.give(ANIMATED_STATUE)
	statue.play()
	game.end_turn()

	lobber2 = game.player1.give("GVG_099")
	lobber2.play()
	assert wisp.dead ^ (statue.health == 10 - 4)

def test_bouncing_blade():
	game = prepare_game()
	acolyte = game.player1.give("EX1_007")
	acolyte.play()
	game.player1.discard_hand()
	game.player1.give("GVG_050").play()
	assert acolyte.dead
	assert len(game.player1.hand) == 3

	wisp1 = game.player1.summon(WISP)
	wisp2 = game.player2.summon(WISP)
	game.player1.give("GVG_050").play()
	assert wisp1.dead ^ wisp2.dead

def test_bouncing_blade_commanding_shout():
	game = prepare_game()
	acolyte = game.player1.give("EX1_007")
	acolyte.play()
	shout = game.player1.give("NEW1_036")
	shout.play()
	game.player1.discard_hand()
	assert acolyte.min_health == 1
	blade = game.player1.give("GVG_050")
	blade.play()
	assert acolyte.health == 1
	assert acolyte.zone == Zone.PLAY
	assert len(game.player1.hand) == 2

def test_crackle():
	game = prepare_game()
	crackle = game.player1.give("GVG_038")
	crackle.play(target=game.player2.hero)
	assert game.player2.hero.health in (24, 25, 26, 27)
	assert game.player1.overloaded == 1

def test_crackle_malygos():
	game = prepare_game()
	malygos = game.player1.give("EX1_563")
	malygos.play()
	game.end_turn()
	game.end_turn()

	crackle = game.player1.give("GVG_038")
	crackle.play(target=game.player2.hero)
	assert game.player2.hero.health in (19, 20, 21, 22)
	assert game.player1.overloaded == 1

def test_crush():
	game = prepare_game()
	crush = game.player1.give("GVG_052")
	assert crush.cost == 7
	token = game.player1.give(SPELLBENDERT)
	token.play()
	assert crush.cost == 7
	game.player1.give(MOONFIRE).play(token)
	assert crush.cost == 3
	token.destroy()
	assert crush.cost == 7

def test_cobalt_guardian():
	game = prepare_game()
	cobalt = game.player1.give("GVG_062")
	cobalt.play()
	assert not cobalt.divine_shield
	game.player1.give(TARGET_DUMMY).play()
	assert cobalt.divine_shield
	game.player1.give(TARGET_DUMMY).play()
	assert cobalt.divine_shield

def test_cogmaster():
	game = prepare_game()
	cogmaster = game.player1.give("GVG_013")
	cogmaster.play()
	assert cogmaster.atk == 1
	dummy = game.player1.give(TARGET_DUMMY)
	dummy.play()
	assert cogmaster.atk == 3
	humility = game.player1.give("EX1_360")
	humility.play(target=cogmaster)
	assert cogmaster.atk == 3
	dummy.destroy()
	assert cogmaster.atk == 1
	game.player1.give(TARGET_DUMMY).play()
	assert cogmaster.atk == 3
	blessedchamp = game.player1.give("EX1_355")
	blessedchamp.play(target=cogmaster)
	assert cogmaster.atk == 4

def test_cogmasters_wrench():
	game = prepare_game()
	wrench = game.player1.summon("GVG_024")
	assert wrench.atk == game.player1.hero.atk == 1
	dummy = game.player1.give(TARGET_DUMMY)
	dummy.play()
	assert wrench.atk == game.player1.hero.atk == 3
	dummy.destroy()
	assert wrench.atk == game.player1.hero.atk == 1

def test_dr_boom():
	game = prepare_game()
	boom = game.player1.give("GVG_110")
	assert len(game.player1.field) == 0
	boom.play()
	assert len(game.player1.field) == 3
	assert len(game.player1.field.filter(id="GVG_110t")) == 2
	# Whirlwind the board
	game.player1.give("EX1_400").play()
	assert (30 - 2) >= game.player2.hero.health >= (30 - 8)

def test_druid_of_the_fang():
	game = prepare_game()
	fang = game.player1.give("GVG_080")
	assert not fang.powered_up
	fang.play()
	assert not fang.powered_up
	assert not fang.morphed
	assert fang in game.player1.field
	assert fang.id == "GVG_080"
	assert fang.atk == 4
	assert fang.health == 4
	game.end_turn()
	game.end_turn()

	fang2 = game.player1.give("GVG_080")
	assert not fang2.powered_up
	game.player1.give(CHICKEN).play()
	assert fang2.powered_up
	fang2.play()
	druid2 = fang2.morphed
	assert druid2 in game.player1.field
	assert druid2.id == "GVG_080t"
	assert druid2.atk == 7
	assert druid2.health == 7
	assert druid2.race == Race.BEAST

def test_echo_of_medivh():
	game = prepare_game()
	game.player1.give(WISP).play()
	game.player1.give(WISP).play()
	game.player1.give(TARGET_DUMMY).play()
	game.player1.give(GOLDSHIRE_FOOTMAN).play()
	game.end_turn()
	game.player2.give(SPELLBENDERT).play()
	game.end_turn()
	game.player1.discard_hand()
	echo = game.player1.give("GVG_005")
	echo.play()
	assert game.player1.hand == [WISP, WISP, TARGET_DUMMY, GOLDSHIRE_FOOTMAN]
	assert len(game.player1.field) == 4

def test_fel_cannon():
	game = prepare_game()
	cannon = game.player1.give("GVG_020")
	cannon.play()
	game.end_turn()
	game.end_turn()

	assert game.player1.hero.health == game.player2.hero.health == 30
	assert cannon.health == 5

	dummy1 = game.player1.give(TARGET_DUMMY)
	dummy1.play()
	game.end_turn()

	dummy2 = game.player2.give(TARGET_DUMMY)
	dummy2.play()
	wisp = game.player2.give(WISP)
	wisp.play()
	game.end_turn()

	assert not wisp.dead
	game.end_turn()

	assert dummy1.health == dummy2.health == 2
	assert not dummy1.dead
	assert not dummy2.dead
	assert wisp.dead

def test_fel_reaver():
	game = prepare_game()
	expected_size = len(game.player1.deck)
	felreaver = game.player1.give("GVG_016")
	felreaver.play()
	game.end_turn()

	for i in range(5):
		game.player2.give(WISP).play()
		expected_size -= 3
		assert len(game.player1.deck) == expected_size
		assert len(game.player2.deck) == 25

def test_floating_watcher():
	game = prepare_game(CardClass.WARLOCK, CardClass.WARLOCK)
	watcher = game.player1.give("GVG_100")
	watcher.play()
	assert watcher.atk == watcher.health == 4
	game.player1.give(MOONFIRE).play(target=game.player2.hero)
	assert watcher.atk == watcher.health == 4
	game.player1.give(MOONFIRE).play(target=game.player1.hero)
	assert watcher.atk == watcher.health == 4 + 2
	game.player1.hero.power.use()
	assert watcher.atk == watcher.health == 4 + 4

def test_floating_watcher_armor():
	game = prepare_game()
	watcher = game.player1.give("GVG_100")
	watcher.play()
	shieldblock = game.player1.give("EX1_606")
	shieldblock.play()
	assert watcher.atk == watcher.health == 4
	assert game.player1.hero.armor == 5
	assert not game.player1.hero.damaged
	flameimp = game.player1.give("EX1_319")
	flameimp.play()
	assert watcher.atk == watcher.health == 6
	assert game.player1.hero.armor == 2
	assert not game.player1.hero.damaged

def test_gahzrilla():
	game = prepare_game()
	gahz = game.player1.give("GVG_049")
	gahz.play()
	assert gahz.atk == 6
	game.player1.give(MOONFIRE).play(target=gahz)
	assert gahz.atk == 6 * 2
	timberwolf = game.player1.give("DS1_175")
	timberwolf.play()
	assert gahz.atk == (6 * 2) + 1
	# TODO: Buffs are always taken into account at the end
	# game.player1.give(MOONFIRE).play(target=gahz)
	# assert gahz.atk == (6*2*2) + 1

def test_gallywix():
	game = prepare_game()
	gallywix = game.player1.give("GVG_028")
	gallywix.play()
	game.end_turn()

	game.player1.discard_hand()
	game.player2.discard_hand()
	game.player2.give("CS2_029").play(target=game.player1.hero)
	assert len(game.player1.hand) == 1
	assert game.player1.hand[0].id == "CS2_029"
	assert len(game.player2.hand) == 1
	assert game.player2.hand[0].id == "GVG_028t"
	game.player2.hand[0].play()
	assert game.player2.temp_mana == 1
	assert len(game.player2.hand) == 0

def test_gazlowe():
	game = prepare_empty_game()
	game.player1.discard_hand()
	gazlowe = game.player1.give("GVG_117")
	gazlowe.play()
	assert len(game.player1.hand) == 0
	smite = game.player1.give("CS1_130")
	assert smite.cost == 1
	smite.play(target=gazlowe)
	assert len(game.player1.hand) == 1
	assert game.player1.hand[0].race == Race.MECHANICAL

def test_gazlowe_preparation():
	game = prepare_empty_game()
	game.player1.give("GVG_117").play()
	drainlife = game.player1.give("CS2_061")
	assert drainlife.cost == 3
	game.player1.give("EX1_145").play()
	assert drainlife.cost == 1
	drainlife.play(target=game.player2.hero)
	assert len(game.player1.hand) == 1
	assert game.player1.hand[0].race == Race.MECHANICAL

def test_gnomish_experimenter():
	game = prepare_empty_game()
	wisp = game.player1.give(WISP)
	wisp.shuffle_into_deck()
	gnomish = game.player1.give("GVG_092")
	gnomish.play()
	assert len(game.player1.hand) == 1
	assert wisp.morphed
	assert wisp.morphed.id == "GVG_092t"
	assert wisp.morphed in game.player1.hand

	gnomish2 = game.player1.give("GVG_092")
	gnomish2.play()
	assert len(game.player1.hand) == 1

def test_goblin_blastmage():
	game = prepare_game()
	blastmage1 = game.player1.give("GVG_004")
	assert not blastmage1.powered_up
	assert game.player1.hero.health == 30
	blastmage1.play()
	assert game.player1.hero.health == 30
	game.end_turn()
	game.end_turn()

	blastmage2 = game.player1.give("GVG_004")
	assert not blastmage2.powered_up
	clockwork = game.player1.give("GVG_082")
	clockwork.play()
	assert clockwork.race == Race.MECHANICAL
	assert blastmage2.powered_up
	blastmage2.play()
	assert game.player2.hero.health == 30 - 4
	game.end_turn()
	game.end_turn()

def test_grove_tender():
	game = prepare_game(game_class=Game)
	for i in range(3):
		game.end_turn()
		game.end_turn()

	assert game.player1.max_mana == 4
	assert game.player2.max_mana == 3
	grovetender1 = game.player1.give("GVG_032")
	grovetender1.play(choose="GVG_032a")
	assert game.player1.max_mana == 5
	assert game.player2.max_mana == 4
	assert game.player1.mana == 2
	assert game.player1.used_mana == 3
	game.end_turn()
	game.end_turn()

	game.player1.discard_hand()
	game.player2.discard_hand()
	grovetender2 = game.player1.give("GVG_032")
	grovetender2.play(choose="GVG_032b")
	assert len(game.player1.hand) == 1
	assert len(game.player2.hand) == 1

	assert game.player1.max_mana == 6
	assert game.player2.max_mana == 5
	game.player1.discard_hand()
	game.player2.discard_hand()
	game.player1.summon(FANDRAL_STAGHELM)
	game.player1.give("GVG_032").play()
	assert game.player1.max_mana == 7
	assert game.player2.max_mana == 6
	assert game.player1.mana == 6 - 3 - 3 + 1
	assert game.player1.used_mana == 3 + 3

def test_hobgoblin():
	game = prepare_game()
	wisp = game.player1.give(WISP)
	wisp.play()
	assert wisp.atk == 1
	assert wisp.health == 1
	hobgoblin = game.player1.give("GVG_104")
	hobgoblin.play()

	wolf1 = game.player1.give("DS1_175")
	wolf1.play()
	assert wolf1.atk == 3
	assert wolf1.health == 3

	wolf2 = game.player1.give("DS1_175")
	wolf2.play()
	assert wolf1.atk == 4
	assert wolf1.health == 3
	assert wolf2.atk == 4
	assert wolf2.health == 3

	loothoarder = game.player1.give("EX1_096")
	loothoarder.play()
	assert not loothoarder.buffs
	assert loothoarder.atk == 2
	assert loothoarder.health == 1

	# TODO: Test faceless-hobgoblin interaction
	# assert wisp.health == 1
	# assert wisp.atk == 1
	# faceless = game.player1.give("EX1_564")
	# faceless.play(target=wisp)
	# assert not faceless.buffs
	# assert faceless.atk == 1
	# assert faceless.health == 1

def test_implosion():
	game = prepare_game()
	statue = game.player1.give(ANIMATED_STATUE)
	statue.play()
	game.end_turn()

	implosion = game.player2.give("GVG_045")
	implosion.play(target=statue)
	statue.damage in (2, 3, 4)
	assert len(game.player2.field) == statue.damage
	assert game.player2.field.contains("GVG_045t")

def test_implosion_commanding_shout():
	game = prepare_game()
	wisp = game.player1.give(WISP)
	wisp.play()
	shout = game.player1.give("NEW1_036")
	shout.play()
	implosion = game.player1.give("GVG_045")
	implosion.play(target=wisp)
	assert not wisp.dead
	assert len(game.player1.field) in (3, 4, 5)

def test_implosion_divine_shield():
	game = prepare_game()
	wisp = game.player1.give(WISP)
	wisp.play()
	game.player1.give(HAND_OF_PROTECTION).play(target=wisp)
	assert wisp.divine_shield
	implosion = game.player1.give("GVG_045")
	implosion.play(target=wisp)
	assert not wisp.dead
	assert not wisp.divine_shield
	assert len(game.player1.field) == 1

def test_iron_juggernaut():
	game = prepare_empty_game()
	game.player2.discard_hand()
	juggernaut = game.player1.give("GVG_056")
	assert len(game.player2.deck) == 0
	juggernaut.play()

	assert game.player2.hero.health == 30
	assert len(game.player2.deck) == 1
	assert len(game.player2.hand) == 0
	game.end_turn()
	assert game.player2.hero.health == 20
	assert len(game.player2.deck) == 0
	assert len(game.player2.hand) == 0

def test_jeeves():
	game = prepare_game()
	game.player1.discard_hand()
	jeeves = game.player1.give("GVG_094")
	jeeves.play()
	assert len(game.player1.hand) == 0
	game.end_turn()

	assert len(game.player1.hand) == 3

def test_light_of_the_naaru():
	game = prepare_game()
	naaru1 = game.player1.give("GVG_012")
	naaru2 = game.player1.give("GVG_012")
	naaru3 = game.player1.give("GVG_012")
	assert game.player1.hero.health == 30
	naaru1.play(target=game.player1.hero)
	assert not game.player1.field
	assert game.player1.hero.health == 30

	game.player1.give(MOONFIRE).play(target=game.player1.hero)
	assert game.player1.hero.health == 29
	naaru2.play(target=game.player1.hero)
	assert not game.player1.field
	assert game.player1.hero.health == 30

	for i in range(5):
		game.player1.give(MOONFIRE).play(target=game.player1.hero)
	assert game.player1.hero.health == 25
	naaru3.play(target=game.player1.hero)
	assert len(game.player1.field) == 1
	assert game.player1.field[0].id == "EX1_001"
	assert game.player1.hero.health == 28

def test_lightbomb():
	game = prepare_game()

	wisp = game.player1.give(WISP)
	wisp.play()
	assert wisp.health == wisp.atk

	game.player1.give(LIGHTS_JUSTICE).play()
	assert game.player1.hero.atk > 0
	assert game.player1.hero.health == 30
	game.end_turn()

	dummy = game.player2.give(TARGET_DUMMY)
	dummy.play()
	assert dummy.health == 2
	assert dummy.atk == 0

	goldshire = game.player2.give(GOLDSHIRE_FOOTMAN)
	goldshire.play()
	assert goldshire.atk == 1
	assert goldshire.health == 2
	game.end_turn()

	lightbomb = game.player1.give("GVG_008")
	lightbomb.play()
	assert wisp.dead
	assert not dummy.dead
	assert dummy.health == 2
	assert goldshire.health == 1
	assert game.player1.hero.health == 30

def test_malganis():
	game = prepare_game(CardClass.HUNTER, CardClass.HUNTER)
	voidwalker = game.player1.give("CS2_065")
	voidwalker.play()
	malganis = game.player1.give("GVG_021")
	assert voidwalker.atk == 1
	assert voidwalker.health == 3
	malganis.play()
	assert voidwalker.atk == 1 + 2
	assert voidwalker.health == 3 + 2
	assert game.player1.hero.immune
	game.end_turn()

	game.player2.hero.power.use()
	assert game.player1.hero.health == 30
	malganis.destroy()
	assert voidwalker.atk == 1
	assert voidwalker.health == 3

def test_malorne():
	game = prepare_empty_game()
	assert len(game.player1.deck) == 0
	game.player1.give("GVG_035")

	for i in range(3):
		malorne = game.player1.hand[0]
		assert malorne.id == "GVG_035"
		malorne.play()
		assert len(game.player1.field) == 1
		assert len(game.player1.hand) == 0
		assert len(game.player1.deck) == 0
		malorne.destroy()
		assert len(game.player1.field) == 0
		assert len(game.player1.deck) == 1
		assert len(game.player1.hand) == 0
		game.end_turn()
		game.end_turn()

		assert len(game.player1.field) == 0
		assert len(game.player1.deck) == 0
		assert len(game.player1.hand) == 1

def test_malorne_slam():
	game = prepare_game()
	malorne = game.player1.give("GVG_035")
	malorne.play()
	game.end_turn()
	game.end_turn()

	game.player1.discard_hand()
	for _ in range(5):
		game.player1.give(MOONFIRE).play(target=malorne)
	assert malorne.health == 2
	slam = game.player1.give("EX1_391")
	slam.play(target=malorne)
	assert malorne.zone == Zone.DECK
	assert malorne in game.player1.deck
	assert not game.player1.hand

def test_mechwarper():
	game = prepare_game()
	mechwarper = game.player1.give("GVG_006")
	goldshire = game.player1.give(GOLDSHIRE_FOOTMAN)
	harvest = game.player1.give("EX1_556")
	clockwork = game.player1.give("GVG_082")
	clockwork2 = game.player1.give("GVG_082")
	assert harvest.cost == 3
	assert goldshire.cost == 1
	assert clockwork.cost == clockwork2.cost == 1

	mechwarper.play()
	assert harvest.cost == 3 - 1
	assert goldshire.cost == 1
	assert clockwork.cost == clockwork2.cost == 0

	clockwork.play()
	assert clockwork.cost == 1

	game.player1.give(SILENCE).play(target=mechwarper)
	assert harvest.cost == 3
	assert goldshire.cost == 1
	assert clockwork.cost == clockwork2.cost == 1

	mechwarper.destroy()
	assert harvest.cost == 3
	assert goldshire.cost == 1
	assert clockwork.cost == clockwork2.cost == 1

def test_mekgineer_thermaplugg():
	game = prepare_game()
	mekgineer = game.player1.give("GVG_116")
	mekgineer.play()

	assert len(game.player1.field) == 1
	assert len(game.player2.field) == 0
	wisp1 = game.player1.give(WISP)
	wisp1.play()
	game.player1.give(MOONFIRE).play(target=wisp1)
	assert wisp1.dead
	assert len(game.player1.field) == 1
	assert len(game.player2.field) == 0
	game.end_turn()

	wisp2 = game.player2.give(WISP)
	wisp2.play()
	game.player2.give(MOONFIRE).play(target=wisp2)
	assert wisp2.dead
	assert len(game.player1.field) == 2
	assert len(game.player1.field.filter(id="EX1_029")) == 1
	assert len(game.player2.field) == 0

def test_metaltooth_leaper():
	game = prepare_game()
	wisp = game.player1.give(WISP)
	wisp.play()
	dummy = game.player1.give(TARGET_DUMMY)
	dummy.play()
	metaltooth = game.player1.give("GVG_048")
	metaltooth.play()
	assert metaltooth.atk == 3
	assert metaltooth.health == 3
	assert wisp.atk == 1
	assert dummy.atk == 0 + 2

def test_micro_machine():
	game = prepare_game()
	micro = game.player1.give("GVG_103")
	micro.play()
	assert micro.atk == 1
	game.end_turn()

	assert micro.atk == 2
	game.end_turn()

	assert micro.atk == 3
	game.end_turn()

	assert micro.atk == 4

def test_mimirons_head():
	game = prepare_game()
	head = game.player1.give("GVG_111")
	head.play()
	game.end_turn()
	game.end_turn()

	assert not head.dead
	assert head.race == Race.MECHANICAL
	assert len(game.player1.field) == 1
	dummy1 = game.player1.give(TARGET_DUMMY)
	dummy1.play()
	dummy2 = game.player1.give(TARGET_DUMMY)
	dummy2.play()
	game.end_turn()

	assert not head.dead
	assert len(game.player1.field) == 3
	game.end_turn()

	assert head.dead
	assert len(game.player1.field) == 1
	voltron = game.player1.field[0]
	assert voltron.id == "GVG_111t"
	assert voltron.windfury == 3
	assert voltron.charge
	for i in range(4):
		assert voltron.can_attack()
		voltron.attack(game.player2.hero)
	assert not voltron.can_attack()

def test_mimirons_head_full_board():
	game = prepare_game()
	head = game.player1.give("GVG_111")
	head.play()
	for i in range(6):
		game.player1.give(TARGET_DUMMY).play()
	game.end_turn()
	game.end_turn()

	assert head.dead
	assert len(game.player1.field) == 1
	assert game.player1.field[0].id == "GVG_111t"

def test_mogor_the_ogre():
	game = prepare_game()
	mogor = game.player1.give("GVG_112").play()
	game.end_turn()

	wisp = game.player2.give(WISP).play()
	game.end_turn()
	game.end_turn()

	wisp.attack(game.player1.hero)
	assert (
		(mogor.health == 5 and wisp.dead) ^
		(game.player1.hero.health == 29 and not wisp.dead)
	)

def test_neptulon():
	game = prepare_game()
	game.player1.discard_hand()
	game.player2.discard_hand()
	assert len(game.player1.hand) == 0
	assert len(game.player2.hand) == 0
	game.player1.give("GVG_042").play()
	assert len(game.player1.hand) == 4
	assert len(game.player2.hand) == 0
	for i in range(4):
		assert game.player1.hand[i].race == Race.MURLOC
	assert game.player1.overloaded == 3

def test_powermace():
	game = prepare_game()

	wisp = game.player1.give(WISP)
	wisp.play()
	powermace1 = game.player1.give("GVG_036")
	powermace1.play()
	assert wisp.atk == 1
	assert wisp.health == 1
	powermace1.destroy()
	assert wisp.atk == 1
	assert wisp.health == 1

	dummy = game.player1.give(TARGET_DUMMY)
	dummy.play()
	powermace2 = game.player1.give("GVG_036")
	powermace2.play()
	assert dummy.atk == 0
	assert dummy.health == 2
	powermace2.destroy()
	assert dummy.atk == 0 + 2
	assert dummy.health == 2 + 2

def test_recombobulator():
	game = prepare_game()
	wisp = game.player1.give(WISP)
	wisp.play()
	recom = game.player1.give("GVG_108")
	recom.play(target=wisp)

	assert wisp not in game.player1.field
	assert game.player1.field[0].cost == 0
	assert game.player1.field[1] == recom

def test_recombobulator_molten_giant():
	game = prepare_game()
	game.player1.hero.set_current_health(15)

	molten = game.player1.give("EX1_620")
	assert molten.cost == 20 - 15
	molten.play()
	game.end_turn()
	game.end_turn()

	recom = game.player1.give("GVG_108")
	recom.play(target=molten)
	recom.destroy()

	assert molten not in game.player1.field
	assert game.player1.field[0].cost == molten.cost

def test_reversing_switch():
	game = prepare_game()
	switch = game.player1.give("PART_006")
	goldshire = game.player1.give(GOLDSHIRE_FOOTMAN)
	goldshire.play()
	game.end_turn()
	game.end_turn()

	switch.play(goldshire)
	assert goldshire.atk == 2

def test_sabotage():
	game = prepare_game()
	sabotage = game.player1.give("GVG_047")
	sabotage.play()

	sabotage2 = game.player1.give("GVG_047")
	sabotage2.play()
	game.end_turn()

	weapon = game.player2.give(LIGHTS_JUSTICE)
	weapon.play()
	wisp = game.player2.give(WISP)
	wisp.play()
	game.end_turn()

	sabotage3 = game.player1.give("GVG_047")
	sabotage3.play()
	assert not weapon.dead
	assert wisp.dead

	sabotage4 = game.player1.give("GVG_047")
	sabotage4.play()
	assert weapon.dead

def test_siege_engine():
	game = prepare_game(CardClass.WARRIOR, CardClass.WARRIOR)
	engine = game.player1.give("GVG_086")
	engine.play()
	assert engine.atk == 5
	game.player1.hero.power.use()
	assert game.player1.hero.armor == 2
	assert engine.atk == 6
	game.end_turn()
	game.player2.hero.power.use()
	assert engine.atk == 6
	game.end_turn()

	# Shield Block
	game.player1.give("EX1_606").play()
	assert game.player1.hero.armor == 7
	assert engine.atk == 7

def test_screwjank_clunker():
	game = prepare_game()
	screwjank = game.player1.give("GVG_055")
	assert not screwjank.targets
	screwjank.play()

	screwjank2 = game.player1.give("GVG_055")
	assert screwjank2.targets == [screwjank]
	screwjank2.play(target=screwjank)
	assert screwjank.atk == 2 + 2
	assert screwjank.health == 5 + 2

def test_siltfin_spiritwalker():
	game = prepare_game()
	game.player1.discard_hand()
	siltfin = game.player1.give("GVG_040")
	siltfin.play()
	murloc = game.player1.give(MURLOC)
	murloc.play()
	game.player1.give(MOONFIRE).play(target=murloc)
	assert len(game.player1.hand) == 1

def test_shrinkmeister():
	game = prepare_game()
	dummy = game.player1.give(TARGET_DUMMY)
	dummy.play()
	wisp = game.player1.give(WISP)
	wisp.play()
	boulderfist = game.player1.give("CS2_200")
	boulderfist.play()
	game.end_turn()

	assert dummy.atk == 0
	game.player2.give("GVG_011").play(target=dummy)
	assert dummy.buffs
	assert dummy.atk == 0

	assert wisp.atk == 1
	game.player2.give("GVG_011").play(target=wisp)
	assert wisp.buffs
	assert wisp.atk == 0

	assert boulderfist.atk == 6
	game.player2.give("GVG_011").play(target=boulderfist)
	assert boulderfist.buffs
	assert boulderfist.atk == 6 - 2
	game.end_turn()

	# ensure buffs are gone after end of turn
	assert not dummy.buffs
	assert dummy.atk == 0
	assert not wisp.buffs
	assert wisp.atk == 1
	assert not boulderfist.buffs
	assert boulderfist.atk == 6

def test_sneeds_old_shredder():
	game = prepare_game()
	sneeds = game.player1.give("GVG_114")
	sneeds.play()
	sneeds.destroy()
	assert len(game.player1.field) == 1
	pilot = game.player1.field[0]
	assert pilot.rarity == Rarity.LEGENDARY
	assert pilot.data.collectible

def test_tinkertown_technician():
	game = prepare_game()
	game.player1.discard_hand()
	game.player1.give(WISP).play()
	tech = game.player1.give("GVG_102")
	assert not tech.powered_up
	tech.play()
	assert tech.atk == tech.health == 3
	assert len(game.player1.hand) == 0

	dummy = game.player1.give(TARGET_DUMMY)
	dummy.play()
	tech2 = game.player1.give("GVG_102")
	assert tech2.powered_up
	tech2.play()
	assert tech2.atk == tech2.health == 4
	assert len(game.player1.hand) == 1
	assert game.player1.hand[0].type == CardType.SPELL

def test_tree_of_life():
	game = prepare_game()
	token1 = game.player1.give(SPELLBENDERT)
	token1.play()
	tree = game.player1.give("GVG_033")
	game.end_turn()

	token2 = game.player2.give(SPELLBENDERT)
	token2.play()
	game.end_turn()

	targets = (game.player1.hero, game.player2.hero, token1, token2)
	for target in targets:
		game.player1.give(MOONFIRE).play(target=target)

	assert token1.health == token2.health == 3 - 1
	assert game.player1.hero.health == game.player2.hero.health == 30 - 1
	tree.play()
	assert token1.health == token2.health == 3
	assert game.player1.hero.health == game.player2.hero.health == 30

def test_unstable_portal():
	game = prepare_game()
	game.player1.discard_hand()
	portal = game.player1.give("GVG_003")
	portal.play()
	assert len(game.player1.hand) == 1
	minion = game.player1.hand[0]
	assert minion.type == CardType.MINION
	assert minion.creator is portal
	assert minion.buffs

def test_velens_chosen():
	game = prepare_game()
	wisp = game.player1.give(WISP)
	wisp.play()
	game.player1.give("GVG_010").play(target=wisp)
	assert wisp.atk == 1 + 2
	assert wisp.health == 1 + 4
	assert wisp.spellpower == 0 + 1
	assert game.player1.spellpower == 1
	game.player1.give("GVG_010").play(target=wisp)
	assert wisp.atk == 1 + 2 + 2
	assert wisp.health == 1 + 4 + 4
	assert wisp.spellpower == 0 + 1 + 1
	assert game.player1.spellpower == 2
	game.end_turn()

	assert game.player2.spellpower == 0
	kobold = game.player2.give(KOBOLD_GEOMANCER)
	kobold.play()
	assert game.player2.spellpower == 1
	game.player2.give("GVG_010").play(target=kobold)
	assert kobold.spellpower == 2
	assert game.player2.spellpower == 2
	assert game.player1.spellpower == 2

def test_voljin():
	game = prepare_game()
	voljin = game.player1.give("GVG_014")
	statue = game.player1.summon(ANIMATED_STATUE)
	assert voljin.health == 2
	assert statue.health == 10
	voljin.play(target=statue)
	assert voljin.health == 10
	assert statue.health == 2

def test_voljin_stealth():
	game = prepare_game()
	tiger = game.player1.give("EX1_028")
	tiger.play()
	game.end_turn()

	voljin = game.player2.give("GVG_014")
	assert not voljin.targets
	voljin.play()
	assert not voljin.dead
	assert voljin.health == 2
	assert tiger.health == 5

def test_wee_spellstopper():
	game = prepare_game(CardClass.MAGE, CardClass.MAGE)
	outside = game.player1.give(WISP)
	outside.play(index=0)
	left = game.player1.give(TARGET_DUMMY)
	left.play(index=1)

	moonfire = game.player1.give(MOONFIRE)
	assert outside in moonfire.targets
	assert not left.cant_be_targeted_by_abilities
	assert left in moonfire.targets
	spellstopper = game.player1.give("GVG_122")
	spellstopper.play(index=2)
	assert outside in moonfire.targets
	assert left.cant_be_targeted_by_abilities
	assert left not in moonfire.targets


/*
 * GPIO driver for the ACCES PCI-IDIO-16
 * Copyright (C) 2017 William Breathitt Gray
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License, version 2, as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 */
#include <linux/bitmap.h>
#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/gpio/driver.h>
#include <linux/interrupt.h>
#include <linux/irqdesc.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/spinlock.h>
#include <linux/types.h>

/**
 * struct idio_16_gpio_reg - GPIO device registers structure
 * @out0_7:	Read: FET Drive Outputs 0-7
 *		Write: FET Drive Outputs 0-7
 * @in0_7:	Read: Isolated Inputs 0-7
 *		Write: Clear Interrupt
 * @irq_ctl:	Read: Enable IRQ
 *		Write: Disable IRQ
 * @filter_ctl:	Read: Activate Input Filters 0-15
 *		Write: Deactivate Input Filters 0-15
 * @out8_15:	Read: FET Drive Outputs 8-15
 *		Write: FET Drive Outputs 8-15
 * @in8_15:	Read: Isolated Inputs 8-15
 *		Write: Unused
 * @irq_status:	Read: Interrupt status
 *		Write: Unused
 */
struct idio_16_gpio_reg {
	u8 out0_7;
	u8 in0_7;
	u8 irq_ctl;
	u8 filter_ctl;
	u8 out8_15;
	u8 in8_15;
	u8 irq_status;
};

/**
 * struct idio_16_gpio - GPIO device private data structure
 * @chip:	instance of the gpio_chip
 * @lock:	synchronization lock to prevent I/O race conditions
 * @reg:	I/O address offset for the GPIO device registers
 * @irq_mask:	I/O bits affected by interrupts
 */
struct idio_16_gpio {
	struct gpio_chip chip;
	raw_spinlock_t lock;
	struct idio_16_gpio_reg __iomem *reg;
	unsigned long irq_mask;
};

static int idio_16_gpio_get_direction(struct gpio_chip *chip,
	unsigned int offset)
{
	if (offset > 15)
		return 1;

	return 0;
}

static int idio_16_gpio_direction_input(struct gpio_chip *chip,
	unsigned int offset)
{
	return 0;
}

static int idio_16_gpio_direction_output(struct gpio_chip *chip,
	unsigned int offset, int value)
{
	chip->set(chip, offset, value);
	return 0;
}

static int idio_16_gpio_get(struct gpio_chip *chip, unsigned int offset)
{
	struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip);
	unsigned long mask = BIT(offset);

	if (offset < 8)
		return !!(ioread8(&idio16gpio->reg->out0_7) & mask);

	if (offset < 16)
		return !!(ioread8(&idio16gpio->reg->out8_15) & (mask >> 8));

	if (offset < 24)
		return !!(ioread8(&idio16gpio->reg->in0_7) & (mask >> 16));

	return !!(ioread8(&idio16gpio->reg->in8_15) & (mask >> 24));
}

static int idio_16_gpio_get_multiple(struct gpio_chip *chip,
	unsigned long *mask, unsigned long *bits)
{
	struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip);
	size_t i;
	const unsigned int gpio_reg_size = 8;
	unsigned int bits_offset;
	size_t word_index;
	unsigned int word_offset;
	unsigned long word_mask;
	const unsigned long port_mask = GENMASK(gpio_reg_size - 1, 0);
	unsigned long port_state;
	void __iomem *ports[] = {
		&idio16gpio->reg->out0_7, &idio16gpio->reg->out8_15,
		&idio16gpio->reg->in0_7, &idio16gpio->reg->in8_15,
	};

	/* clear bits array to a clean slate */
	bitmap_zero(bits, chip->ngpio);

	/* get bits are evaluated a gpio port register at a time */
	for (i = 0; i < ARRAY_SIZE(ports); i++) {
		/* gpio offset in bits array */
		bits_offset = i * gpio_reg_size;

		/* word index for bits array */
		word_index = BIT_WORD(bits_offset);

		/* gpio offset within current word of bits array */
		word_offset = bits_offset % BITS_PER_LONG;

		/* mask of get bits for current gpio within current word */
		word_mask = mask[word_index] & (port_mask << word_offset);
		if (!word_mask) {
			/* no get bits in this port so skip to next one */
			continue;
		}

		/* read bits from current gpio port */
		port_state = ioread8(ports[i]);

		/* store acquired bits at respective bits array offset */
		bits[word_index] |= port_state << word_offset;
	}

	return 0;
}

static void idio_16_gpio_set(struct gpio_chip *chip, unsigned int offset,
	int value)
{
	struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip);
	unsigned int mask = BIT(offset);
	void __iomem *base;
	unsigned long flags;
	unsigned int out_state;

	if (offset > 15)
		return;

	if (offset > 7) {
		mask >>= 8;
		base = &idio16gpio->reg->out8_15;
	} else
		base = &idio16gpio->reg->out0_7;

	raw_spin_lock_irqsave(&idio16gpio->lock, flags);

	if (value)
		out_state = ioread8(base) | mask;
	else
		out_state = ioread8(base) & ~mask;

	iowrite8(out_state, base);

	raw_spin_unlock_irqrestore(&idio16gpio->lock, flags);
}

static void idio_16_gpio_set_multiple(struct gpio_chip *chip,
	unsigned long *mask, unsigned long *bits)
{
	struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip);
	unsigned long flags;
	unsigned int out_state;

	raw_spin_lock_irqsave(&idio16gpio->lock, flags);

	/* process output lines 0-7 */
	if (*mask & 0xFF) {
		out_state = ioread8(&idio16gpio->reg->out0_7) & ~*mask;
		out_state |= *mask & *bits;
		iowrite8(out_state, &idio16gpio->reg->out0_7);
	}

	/* shift to next output line word */
	*mask >>= 8;

	/* process output lines 8-15 */
	if (*mask & 0xFF) {
		*bits >>= 8;
		out_state = ioread8(&idio16gpio->reg->out8_15) & ~*mask;
		out_state |= *mask & *bits;
		iowrite8(out_state, &idio16gpio->reg->out8_15);
	}

	raw_spin_unlock_irqrestore(&idio16gpio->lock, flags);
}

static void idio_16_irq_ack(struct irq_data *data)
{
}

static void idio_16_irq_mask(struct irq_data *data)
{
	struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
	struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip);
	const unsigned long mask = BIT(irqd_to_hwirq(data));
	unsigned long flags;

	idio16gpio->irq_mask &= ~mask;

	if (!idio16gpio->irq_mask) {
		raw_spin_lock_irqsave(&idio16gpio->lock, flags);

		iowrite8(0, &idio16gpio->reg->irq_ctl);

		raw_spin_unlock_irqrestore(&idio16gpio->lock, flags);
	}
}

static void idio_16_irq_unmask(struct irq_data *data)
{
	struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
	struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip);
	const unsigned long mask = BIT(irqd_to_hwirq(data));
	const unsigned long prev_irq_mask = idio16gpio->irq_mask;
	unsigned long flags;

	idio16gpio->irq_mask |= mask;

	if (!prev_irq_mask) {
		raw_spin_lock_irqsave(&idio16gpio->lock, flags);

		ioread8(&idio16gpio->reg->irq_ctl);

		raw_spin_unlock_irqrestore(&idio16gpio->lock, flags);
	}
}

static int idio_16_irq_set_type(struct irq_data *data, unsigned int flow_type)
{
	/* The only valid irq types are none and both-edges */
	if (flow_type != IRQ_TYPE_NONE &&
		(flow_type & IRQ_TYPE_EDGE_BOTH) != IRQ_TYPE_EDGE_BOTH)
		return -EINVAL;

	return 0;
}

static struct irq_chip idio_16_irqchip = {
	.name = "pci-idio-16",
	.irq_ack = idio_16_irq_ack,
	.irq_mask = idio_16_irq_mask,
	.irq_unmask = idio_16_irq_unmask,
	.irq_set_type = idio_16_irq_set_type
};

static irqreturn_t idio_16_irq_handler(int irq, void *dev_id)
{
	struct idio_16_gpio *const idio16gpio = dev_id;
	unsigned int irq_status;
	struct gpio_chip *const chip = &idio16gpio->chip;
	int gpio;

	raw_spin_lock(&idio16gpio->lock);

	irq_status = ioread8(&idio16gpio->reg->irq_status);

	raw_spin_unlock(&idio16gpio->lock);

	/* Make sure our device generated IRQ */
	if (!(irq_status & 0x3) || !(irq_status & 0x4))
		return IRQ_NONE;

	for_each_set_bit(gpio, &idio16gpio->irq_mask, chip->ngpio)
		generic_handle_irq(irq_find_mapping(chip->irq.domain, gpio));

	raw_spin_lock(&idio16gpio->lock);

	/* Clear interrupt */
	iowrite8(0, &idio16gpio->reg->in0_7);

	raw_spin_unlock(&idio16gpio->lock);

	return IRQ_HANDLED;
}

#define IDIO_16_NGPIO 32
static const char *idio_16_names[IDIO_16_NGPIO] = {
	"OUT0", "OUT1", "OUT2", "OUT3", "OUT4", "OUT5", "OUT6", "OUT7",
	"OUT8", "OUT9", "OUT10", "OUT11", "OUT12", "OUT13", "OUT14", "OUT15",
	"IIN0", "IIN1", "IIN2", "IIN3", "IIN4", "IIN5", "IIN6", "IIN7",
	"IIN8", "IIN9", "IIN10", "IIN11", "IIN12", "IIN13", "IIN14", "IIN15"
};

static int idio_16_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
	struct device *const dev = &pdev->dev;
	struct idio_16_gpio *idio16gpio;
	int err;
	const size_t pci_bar_index = 2;
	const char *const name = pci_name(pdev);

	idio16gpio = devm_kzalloc(dev, sizeof(*idio16gpio), GFP_KERNEL);
	if (!idio16gpio)
		return -ENOMEM;

	err = pcim_enable_device(pdev);
	if (err) {
		dev_err(dev, "Failed to enable PCI device (%d)\n", err);
		return err;
	}

	err = pcim_iomap_regions(pdev, BIT(pci_bar_index), name);
	if (err) {
		dev_err(dev, "Unable to map PCI I/O addresses (%d)\n", err);
		return err;
	}

	idio16gpio->reg = pcim_iomap_table(pdev)[pci_bar_index];

	/* Deactivate input filters */
	iowrite8(0, &idio16gpio->reg->filter_ctl);

	idio16gpio->chip.label = name;
	idio16gpio->chip.parent = dev;
	idio16gpio->chip.owner = THIS_MODULE;
	idio16gpio->chip.base = -1;
	idio16gpio->chip.ngpio = IDIO_16_NGPIO;
	idio16gpio->chip.names = idio_16_names;
	idio16gpio->chip.get_direction = idio_16_gpio_get_direction;
	idio16gpio->chip.direction_input = idio_16_gpio_direction_input;
	idio16gpio->chip.direction_output = idio_16_gpio_direction_output;
	idio16gpio->chip.get = idio_16_gpio_get;
	idio16gpio->chip.get_multiple = idio_16_gpio_get_multiple;
	idio16gpio->chip.set = idio_16_gpio_set;
	idio16gpio->chip.set_multiple = idio_16_gpio_set_multiple;

	raw_spin_lock_init(&idio16gpio->lock);

	err = devm_gpiochip_add_data(dev, &idio16gpio->chip, idio16gpio);
	if (err) {
		dev_err(dev, "GPIO registering failed (%d)\n", err);
		return err;
	}

	/* Disable IRQ by default and clear any pending interrupt */
	iowrite8(0, &idio16gpio->reg->irq_ctl);
	iowrite8(0, &idio16gpio->reg->in0_7);

	err = gpiochip_irqchip_add(&idio16gpio->chip, &idio_16_irqchip, 0,
		handle_edge_irq, IRQ_TYPE_NONE);
	if (err) {
		dev_err(dev, "Could not add irqchip (%d)\n", err);
		return err;
	}

	err = devm_request_irq(dev, pdev->irq, idio_16_irq_handler, IRQF_SHARED,
		name, idio16gpio);
	if (err) {
		dev_err(dev, "IRQ handler registering failed (%d)\n", err);
		return err;
	}

	return 0;
}

static const struct pci_device_id idio_16_pci_dev_id[] = {
	{ PCI_DEVICE(0x494F, 0x0DC8) }, { 0 }
};
MODULE_DEVICE_TABLE(pci, idio_16_pci_dev_id);

static struct pci_driver idio_16_driver = {
	.name = "pci-idio-16",
	.id_table = idio_16_pci_dev_id,
	.probe = idio_16_probe
};

module_pci_driver(idio_16_driver);

MODULE_AUTHOR("William Breathitt Gray <vilhelm.gray@gmail.com>");
MODULE_DESCRIPTION("ACCES PCI-IDIO-16 GPIO driver");
MODULE_LICENSE("GPL v2");


<!DOCTYPE HTML>

<title>WatchBuilder.WatchFactory (weblogic-kubernetes-operator 2.3.0 API)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="dc.created" content="2019-08-27">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../jquery/jquery-ui.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

All Classes

SEARCH:
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">

JavaScript is disabled on your browser.

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

Package oracle.kubernetes.operator.builders

Interface WatchBuilder.WatchFactory

Enclosing class:

WatchBuilder

public static interface WatchBuilder.WatchFactory

Method Summary

All Methods Instance Methods Abstract Methods

Modifier and Type
Method
Description

<T> WatchI<T>
createWatch(Pool<io.kubernetes.client.ApiClient> pool,
           CallParams callParams,
           Class<?> responseBodyType,
           BiFunction<io.kubernetes.client.ApiClient,CallParams,com.squareup.okhttp.Call> function)

Method Detail

createWatch

<T> WatchI<T> createWatch(Pool<io.kubernetes.client.ApiClient> pool,
                          CallParams callParams,
                          Class<?> responseBodyType,
                          BiFunction<io.kubernetes.client.ApiClient,CallParams,com.squareup.okhttp.Call> function)
                   throws io.kubernetes.client.ApiException

Throws:

io.kubernetes.client.ApiException

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

All Classes

JavaScript is disabled on your browser.

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

Copyright © 2017–2019. All rights reserved.


//hong QQ:1410919373
package com.zlchat.utils {
    import com.zlchat.ui.*;
    import flash.events.*;
    import fl.data.*;
    import flash.net.*;
    import com.zlchat.events.*;
    import flash.utils.*;
    import flash.media.*;
    import flash.system.*;
    import flash.external.*;

    public class VideoConnection extends NetConnection {

        public function VideoConnection(){
        }
		public function onBWDone():void{};
	}
}//package com.zlchat.utils


/*
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import "fmt"

// MatchTaint checks if the taint matches taintToMatch. Taints are unique by key:effect,
// if the two taints have same key:effect, regard as they match.
func (t *Taint) MatchTaint(taintToMatch *Taint) bool {
	return t.Key == taintToMatch.Key && t.Effect == taintToMatch.Effect
}

// taint.ToString() converts taint struct to string in format '<key>=<value>:<effect>', '<key>=<value>:', '<key>:<effect>', or '<key>'.
func (t *Taint) ToString() string {
	if len(t.Effect) == 0 {
		if len(t.Value) == 0 {
			return fmt.Sprintf("%v", t.Key)
		}
		return fmt.Sprintf("%v=%v:", t.Key, t.Value)
	}
	if len(t.Value) == 0 {
		return fmt.Sprintf("%v:%v", t.Key, t.Effect)
	}
	return fmt.Sprintf("%v=%v:%v", t.Key, t.Value, t.Effect)
}


---
title: <switches> 的 <add> 元素
ms.date: 03/30/2017
f1_keywords:
- http://schemas.microsoft.com/.NetConfiguration/v2.0#configuration/system.diagnostics/switches/add
helpviewer_keywords:
- <add> element for <switches>
- add element for <switches>
ms.assetid: 712ac3a7-7abf-4a9e-8db4-acd241c2f369
ms.openlocfilehash: 5be39425363cb6d2a0eca6a0fa3f4154ce857bb5
ms.sourcegitcommit: 5b475c1855b32cf78d2d1bbb4295e4c236f39464
ms.translationtype: MT
ms.contentlocale: zh-CN
ms.lasthandoff: 09/24/2020
ms.locfileid: "91173934"
---
# \<switches> 的 \<add> 元素

指定对跟踪开关设置的级别。

[**\<configuration>**](../configuration-element.md)\
  [**\<system.diagnostics>**](system-diagnostics-element.md)\
    [**\<switches>**](switches-element.md)\
      **\<add>**

## 语法

```xml
<add name="switch name"
     value="value"/>
```

## 特性和元素

 下列各节描述了特性、子元素和父元素。

### 特性

|属性|描述|
|---------------|-----------------|
|name|必需的特性。

 指定开关的名称。 此属性的值对应于传递给 switch 构造函数的 *displayName* 参数。|
|**value**|必需的特性。

 指定开关的级别。|

### 子元素

 无。

### 父元素

|元素|描述|
|-------------|-----------------|
|`configuration`|公共语言运行时和 .NET Framework 应用程序所使用的每个配置文件中的根元素。|
|`switches`|包含跟踪开关和对该跟踪开关设置的级别。|
|`system.diagnostics`|指定用于收集、存储和路由消息的跟踪侦听器以及对跟踪开关设置的级别。|

## 备注

 可以通过将跟踪开关置于配置文件中来更改其级别。 如果开关是 <xref:System.Diagnostics.BooleanSwitch> ，则可以将其打开或关闭。 如果开关是 <xref:System.Diagnostics.TraceSwitch> ，则可以为其分配不同的级别，以指定应用程序输出的跟踪或调试消息的类型。

## 示例

 下面的示例演示如何使用 **\<add>** 元素将 `General` 跟踪开关设置为 <xref:System.Diagnostics.TraceLevel> 级别，并启用 `Data` 布尔型跟踪开关。

```xml
<configuration>
   <system.diagnostics>
      <switches>
         <add name="General" value="4" />
         <add name="Data" value="1" />
      </switches>
   </system.diagnostics>
</configuration>
```

## 请参阅

- <xref:System.Diagnostics.Switch>
- <xref:System.Diagnostics.TraceSwitch>
- <xref:System.Diagnostics.BooleanSwitch>
- [跟踪和调试设置架构](index.md)


2
4
2
2
2
2
4
4
4
0
2
6
4
4
0
2
4
2
2
4
6
2
2
4
2
2
2
4
0
6
0
2
2
4
2
0
2
2
0
4
2
4
2
0
2
2
4
2
2
2
2
2
2
2
6
2
4
4
2
2
0
2
4
0
2
4
0
2
2
2
2
2
2
2
2
2
2
2
2
2
4
0
2
6
4
2
2
2
2
4
4
0
2
2
0
2
2
4
4
2
2
2
4
4
2
4
2
4
4
2
2
4
2
0
2
2
4
4
2
2
2
2
2
2
2
4
4
2
2
2
2
2
2
2
2
0
4
2
2
2
4
2
4
2
2
2
2
4
0
2
4
0
8
2
2
2
6
2
4
2
2
4
4
4
2
2
2
2
6
2
4
0
2
2
4
2
2
0
4
2
2
4
2
2
2
4
2
2
2
4
4
2
4
4
4
2
0
2
4
6
4
2
2
0
0
2
2
2
0
2
0
2
2
2
2
2
0
2
4
2
0
4
2
2
2
2
2
2
2
2
0
4
0
4
2
4
4
6
2
0
0
4
2
4
2
6
0
2
2
2
2
2
0
4
2
2
2
2
0
4
2
2
0
2
6
2
2
0
4
0
2
2
2
4
2
4
2
0
0
2
2
2
4
0
2
2
4
2


package com.sequenceiq.cloudbreak.converter.v4.stacks;

import org.springframework.stereotype.Component;

import com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response;
import com.sequenceiq.cloudbreak.cloud.model.StackTags;
import com.sequenceiq.cloudbreak.converter.AbstractConversionServiceAwareConverter;

@Component
public class StackTagsToTagsV4ResponseConverter extends AbstractConversionServiceAwareConverter<StackTags, TagsV4Response> {

    @Override
    public TagsV4Response convert(StackTags source) {
        TagsV4Response response = new TagsV4Response();
        response.setApplication(source.getApplicationTags());
        response.setDefaults(source.getDefaultTags());
        response.setUserDefined(source.getUserDefinedTags());
        return response;
    }

}


// Copyright (C) 2017  Davis E. King (davis@dlib.net)
// License: Boost Software License   See LICENSE.txt for the full license.
#undef DLIB_UPPER_bOUND_FUNCTION_ABSTRACT_Hh_
#ifdef DLIB_UPPER_bOUND_FUNCTION_ABSTRACT_Hh_

#include "../matrix.h"
#include <limits>

namespace dlib
{

// ----------------------------------------------------------------------------------------

    struct function_evaluation
    {
        /*!
            WHAT THIS OBJECT REPRESENTS
                This object records the output of a real valued function in response to
                some input.

                In particular, if you have a function F(x) then the function_evaluation is
                simply a struct that records x and the scalar value F(x).
        !*/

        function_evaluation() = default;
        function_evaluation(const matrix<double,0,1>& x, double y) :x(x), y(y) {}

        matrix<double,0,1> x;
        double y = std::numeric_limits<double>::quiet_NaN();
    };

// ----------------------------------------------------------------------------------------

    class upper_bound_function
    {
        /*!
            WHAT THIS OBJECT REPRESENTS
                This object represents a piecewise linear non-parametric function that can
                be used to define an upper bound on some more complex and unknown function.
                To describe this precisely, lets assume there is a function F(x) which you
                are capable of sampling from but otherwise know nothing about, and that you
                would like to find an upper bounding function U(x) such that U(x) >= F(x)
                for any x.  It would also be good if U(x)-F(x) was minimal.  I.e. we would
                like U(x) to be a tight upper bound, not something vacuous like U(x) =
                infinity.

                The upper_bound_function class is a tool for creating this kind of upper
                bounding function from a set of function_evaluations of F(x).  We do this
                by considering only U(x) of the form:
                    U = [](matrix<double,0,1> x) {
                       double min_ub = infinity;
                       for (size_t i = 0; i < POINTS.size(); ++i) {
                            function_evaluation p = POINTS[i]
                            double local_bound = p.y + sqrt(noise_terms[i] + trans(p.x-x)*M*(p.x-x))
                            min_ub = min(min_ub, local_bound)
                        }
                        return min_ub;
                    }
                Where POINTS is an array of function_evaluation instances drawn from F(x),
                M is a diagonal matrix, and noise_terms is an array of scalars.

                To create an upper bound U(x), the upper_bound_function takes a POINTS array
                containing evaluations of F(x) as input and solves the following quadratic
                program to find the parameters of U(x):

                    min_{M,noise_terms}:  sum(squared(M)) + sum(squared(noise_terms/relative_noise_magnitude))
                    s.t.   U(POINTS[i].x) >= POINTS[i].y,  for all i
                           noise_terms[i] >= 0
                           min(M) >= 0
                           M is a diagonal matrix

                Therefore, the quadratic program finds the U(x) that always upper bounds
                F(x) on the supplied POINTS, but is otherwise as small as possible.

                The inspiration for the upper_bound_function object came from the AdaLIPO
                algorithm from this excellent paper:
                    Global optimization of Lipschitz functions
                    Malherbe, Cédric and Vayatis, Nicolas
                    International Conference on Machine Learning - 2017
                In that paper, they propose to use a simpler U(x) where noise_terms is
                always 0 and M is a diagonal matrix where each diagonal element is the same
                value.  Therefore, there is only a single scalar parameter for U(x) in
                their formulation of the problem.  This causes difficulties if F(x) is
                stochastic or has discontinuities since, without the noise term, M will
                become really huge and the upper bound becomes vacuously large.  It is also
                problematic if the gradient of F(x) with respect to x contains elements of
                widely varying magnitude since the simpler formulation of U(x) assumes a
                uniform rate of change regardless of which dimension is varying.
        !*/

    public:

        upper_bound_function(
        );
        /*!
            ensures
                - #num_points() == 0
                - #dimensionality() == 0
        !*/

        explicit upper_bound_function(
            const std::vector<function_evaluation>& points,
            const double relative_noise_magnitude = 0.001,
            const double solver_eps = 0.0001
        );
        /*!
            requires
                - all the x vectors in points must have the same non-zero dimensionality.
                - relative_noise_magnitude >= 0
                - solver_eps > 0
            ensures
                - Creates an upper bounding function U(x), as described above, assuming that
                  the given points are drawn from F(x).
                - Uses the provided relative_noise_magnitude when solving the QP, as
                  described above.  Note that relative_noise_magnitude can be set to 0.  If
                  you do this then all the noise terms are constrained to 0.  You should
                  only do this if you know F(x) is non-stochastic and continuous
                  everywhere.
                - When solving the QP used to find the parameters of U(x), the upper
                  bounding function, we solve the QP to solver_eps accuracy.   It's
                  possible that large enough solver_eps can lead to upper bounds that don't
                  upper bound all the supplied points.  But for reasonable epsilon values
                  this shouldn't be a problem.
                - #num_points() == points.size()
                - #dimensionality() == points[0].x.size()
        !*/

        upper_bound_function(
            const double relative_noise_magnitude,
            const double solver_eps
        );
        /*!
            requires
                - relative_noise_magnitude >= 0
                - solver_eps > 0
            ensures
                - #num_points() == 0
                - #dimensionality() == 0
                - This destructor is the same as calling the above constructor with points.size()==0
        !*/

        void add (
            const function_evaluation& point
        );
        /*!
            requires
                - num_points() == 0 || point.x.size() == dimensionality()
                - point.x.size() != 0
            ensures
                - Adds point to get_points().
                - Incrementally updates the upper bounding function with the given function
                  evaluation.  That is, we assume that F(point.x)==point.y and solve the QP
                  described above to find the new U(x) that upper bounds all the points
                  this object knows about (i.e. all the points in get_points() and the new point).
                - Calling add() is much faster than recreating the upper_bound_function
                  from scratch with all the points.  This is because we warm start with the
                  previous solution to the QP.  This is done by discarding any non-active
                  constraints and solving the QP again with only the previously active
                  constraints and the new constraints formed by all the pairs of the new
                  point and the old points.  This means the QP solved by add() is much
                  smaller than the QP that would be solved by a fresh call to the
                  upper_bound_function constructor.
        !*/

        const std::vector<function_evaluation>& get_points(
        ) const;
        /*!
            ensures
                - returns the points from F(x) used to define this upper bounding function.
                  These are all the function_evaluation objects given to this object via
                  its constructor and add().
        !*/

        long num_points(
        ) const;
        /*!
            ensures
                - returns the number of points used to define the upper bounding function.
                  (i.e. returns get_points().size())
        !*/

        long dimensionality(
        ) const;
        /*!
            ensures
                - returns the dimensionality of the input vectors to the upper bounding function.
        !*/

        double operator() (
            const matrix<double,0,1>& x
        ) const;
        /*!
            requires
                - num_points() > 0
                - x.size() == dimensionality()
            ensures
                - return U(x)
                  (i.e. returns the upper bound on F(x) at x given by our upper bounding function)
        !*/

    };

// ----------------------------------------------------------------------------------------

}

#endif // DLIB_UPPER_bOUND_FUNCTION_ABSTRACT_Hh_


<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="240dp"
    android:height="180dp"
    android:viewportWidth="400"
    android:viewportHeight="300">
  <path
      android:pathData="M0,0h400v300h-400z"
      android:fillColor="#3a75c4"/>
  <path
      android:pathData="M0,0h400v200h-400z"
      android:fillColor="#fcd116"/>
  <path
      android:pathData="M0,0h400v100h-400z"
      android:fillColor="#009e60"/>
</vector>


# Tenko parser autogenerated test case

- From: tests/testcases/strict_mode/directive_headers/func_decl/autogen.md
- Path: tests/testcases/strict_mode/directive_headers/func_decl/gen/obj_method_as_func_name_w_directive/eval.md

> :: strict mode : directive headers : func decl : gen : obj method as func name w directive
>
> ::> eval

## Input

`````js
f = {
  eval(b){
    "use strict";
  }
}
`````

## Output

_Note: the whole output block is auto-generated. Manual changes will be overwritten!_

Below follow outputs in five parsing modes: sloppy, sloppy+annexb, strict script, module, module+annexb.

Note that the output parts are auto-generated by the test runner to reflect actual result.

### Sloppy mode

Parsed with script goal and as if the code did not start with strict mode header.

`````
ast: {
  type: 'Program',
  loc:{start:{line:1,column:0},end:{line:5,column:1},source:''},
  body: [
    {
      type: 'ExpressionStatement',
      loc:{start:{line:1,column:0},end:{line:5,column:1},source:''},
      expression: {
        type: 'AssignmentExpression',
        loc:{start:{line:1,column:0},end:{line:5,column:1},source:''},
        left: {
          type: 'Identifier',
          loc:{start:{line:1,column:0},end:{line:1,column:1},source:''},
          name: 'f'
        },
        operator: '=',
        right: {
          type: 'ObjectExpression',
          loc:{start:{line:1,column:4},end:{line:5,column:1},source:''},
          properties: [
            {
              type: 'Property',
              loc:{start:{line:2,column:2},end:{line:4,column:3},source:''},
              key: {
                type: 'Identifier',
                loc:{start:{line:2,column:2},end:{line:2,column:6},source:''},
                name: 'eval'
              },
              kind: 'init',
              method: true,
              computed: false,
              value: {
                type: 'FunctionExpression',
                loc:{start:{line:2,column:2},end:{line:4,column:3},source:''},
                generator: false,
                async: false,
                id: null,
                params: [
                  {
                    type: 'Identifier',
                    loc:{start:{line:2,column:7},end:{line:2,column:8},source:''},
                    name: 'b'
                  }
                ],
                body: {
                  type: 'BlockStatement',
                  loc:{start:{line:2,column:9},end:{line:4,column:3},source:''},
                  body: [
                    {
                      type: 'ExpressionStatement',
                      loc:{start:{line:3,column:4},end:{line:3,column:17},source:''},
                      expression: {
                        type: 'Literal',
                        loc:{start:{line:3,column:4},end:{line:3,column:16},source:''},
                        value: 'use strict',
                        raw: '"use strict"'
                      },
                      directive: 'use strict'
                    }
                  ]
                }
              },
              shorthand: false
            }
          ]
        }
      }
    }
  ]
}

tokens (14x):
       IDENT PUNC_EQ PUNC_CURLY_OPEN ID_eval PUNC_PAREN_OPEN IDENT
       PUNC_PAREN_CLOSE PUNC_CURLY_OPEN STRING_DOUBLE PUNC_SEMI
       PUNC_CURLY_CLOSE PUNC_CURLY_CLOSE ASI
`````

### Strict mode

Parsed with script goal but as if it was starting with `"use strict"` at the top.

_Output same as sloppy mode._

### Module goal

Parsed with the module goal.

_Output same as sloppy mode._

### Sloppy mode with AnnexB

Parsed with script goal with AnnexB rules enabled and as if the code did not start with strict mode header.

_Output same as sloppy mode._

### Module goal with AnnexB

Parsed with the module goal with AnnexB rules enabled.

_Output same as sloppy mode._

## AST Printer

Printer output different from input [sloppy][annexb:no]:

````js
f = {eval(b){"use strict";}};
````

Produces same AST


RUN: llvm-readobj --coff-imports %p/Inputs/imports.exe.coff-i386 | FileCheck -check-prefix=X86 %s
RUN: llvm-readobj --coff-imports %p/Inputs/imports.exe.coff-x86-64 | FileCheck -check-prefix=X64  %s

X86:      Import {
X86-NEXT:   Name: KERNEL32.dll
X86-NEXT:   ImportLookupTableRVA: 0x2108
X86-NEXT:   ImportAddressTableRVA: 0x2000
X86-NEXT:   Symbol: ExitProcess (337)
X86-NEXT:   Symbol: GetProcAddress (669)
X86-NEXT:   Symbol: FreeLibrary (414)
X86-NEXT:   Symbol: GetLastError (592)
X86-NEXT:   Symbol: RaiseException (1087)
X86-NEXT:   Symbol: LoadLibraryExA (934)
X86-NEXT: }
X86-NEXT: Import {
X86-NEXT:   Name: USER32.dll
X86-NEXT:   ImportLookupTableRVA: 0x2124
X86-NEXT:   ImportAddressTableRVA: 0x201C
X86-NEXT:   Symbol: MessageBoxA (582)
X86-NEXT: }
X86-NEXT: Import {
X86-NEXT:   Name: mydll.dll
X86-NEXT:   ImportLookupTableRVA: 0x212C
X86-NEXT:   ImportAddressTableRVA: 0x2024
X86-NEXT:   Symbol: Func1 (0)
X86-NEXT:   Symbol: Func2 (1)
X86-NEXT:   Symbol:  (3)
X86-NEXT: }
X86-NEXT: DelayImport {
X86-NEXT:   Name: lazyload.dll
X86-NEXT:   Attributes: 0x1
X86-NEXT:   ModuleHandle: 0x301C
X86-NEXT:   ImportAddressTable: 0x3010
X86-NEXT:   ImportNameTable: 0x2090
X86-NEXT:   BoundDelayImportTable: 0x20AC
X86-NEXT:   UnloadDelayImportTable: 0x0
X86-NEXT:   Import {
X86-NEXT:     Symbol: Func5 (0)
X86-NEXT:     Address: 0x401073
X86-NEXT:   }
X86-NEXT:   Import {
X86-NEXT:     Symbol: Func4 (0)
X86-NEXT:     Address: 0x401052
X86-NEXT:   }
X86-NEXT: }

X64:      Import {
X64-NEXT:   Name: KERNEL32.dll
X64-NEXT:   ImportLookupTableRVA: 0x2170
X64-NEXT:   ImportAddressTableRVA: 0x2000
X64-NEXT:   Symbol: ExitProcess (343)
X64-NEXT:   Symbol: GetProcAddress (676)
X64-NEXT:   Symbol: FreeLibrary (420)
X64-NEXT:   Symbol: GetLastError (598)
X64-NEXT:   Symbol: RaiseException (1091)
X64-NEXT:   Symbol: LoadLibraryExA (937)
X64-NEXT: }
X64-NEXT: Import {
X64-NEXT:   Name: USER32.dll
X64-NEXT:   ImportLookupTableRVA: 0x21A8
X64-NEXT:   ImportAddressTableRVA: 0x2038
X64-NEXT:   Symbol: MessageBoxA (586)
X64-NEXT: }
X64-NEXT: Import {
X64-NEXT:   Name: mydll.dll
X64-NEXT:   ImportLookupTableRVA: 0x21B8
X64-NEXT:   ImportAddressTableRVA: 0x2048
X64-NEXT:   Symbol: Func1 (0)
X64-NEXT:   Symbol: Func2 (1)
X64-NEXT:   Symbol:  (3)
X64-NEXT: }
X64-NEXT: DelayImport {
X64-NEXT:   Name: lazyload.dll
X64-NEXT:   Attributes: 0x1
X64-NEXT:   ModuleHandle: 0x3028
X64-NEXT:   ImportAddressTable: 0x3010
X64-NEXT:   ImportNameTable: 0x20E0
X64-NEXT:   BoundDelayImportTable: 0x2108
X64-NEXT:   UnloadDelayImportTable: 0x0
X64-NEXT:   Import {
X64-NEXT:     Symbol: Func5 (0)
X64-NEXT:     Address: 0x1400010F1
X64-NEXT:   }
X64-NEXT:   Import {
X64-NEXT:     Symbol: Func4 (0)
X64-NEXT:     Address: 0x140001066
X64-NEXT:   }
X64-NEXT: }


# -*- coding: utf-8 -*-
import re
from pathlib import Path

ROOT = Path(__file__).parent

with open(str(ROOT / 'html_style.css'), 'r') as f:
    style = f.read()
# end with

def get_value():
    return _minify(style)
# end def

def _minify(css):
    result = ''

    # remove comments - this will break IE<6 comment hacks
    css = re.sub(r'/\*[\s\S]*?\*/', "", css)

    # url() doesn't need quotes
    #css = re.sub(r'url\((["\'])([^)]*)\1\)', r'url(\2)', css)

    # spaces may be safely collapsed as generated content will collapse them anyway
    css = re.sub(r'\s+', ' ', css)

    # shorten collapsable colors: #aabbcc to #abc
    css = re.sub(
        r'#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3(\s|;)', r'#\1\2\3\4', css)

    # fragment values can loose zeros
    css = re.sub(r':\s*0(\.\d+([cm]m|e[mx]|in|p[ctx]))\s*;', r':\1;', css)

    for rule in re.findall(r'([^{]+){([^}]*)}', css):
        # we don't need spaces around operators
        selectors = [re.sub(r'(?<=[\[\(>+=])\s+|\s+(?=[=~^$*|>+\]\)])',
                            r'', selector.strip()) for selector in rule[0].split(',')]
        # order is important, but we still want to discard repetitions
        properties = {}
        porder = []
        for prop in re.findall(r'(.*?):(.*?)(;|$)', rule[1]):
            key = prop[0].strip().lower()
            if key not in porder:
                porder.append(key)
            properties[key] = prop[1].strip()
            # output rule if it contains any declarations
            if properties:
                result += "%s{%s}" % (','.join(selectors), ''.join(
                    ['%s:%s;' % (key, properties[key]) for key in porder])[:-1])

    return result
# end def


package org.jetbrains.plugins.scala.lang.refactoring.extractTrait;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.ui.PackageNameReferenceEditorCombo;
import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.ui.DocumentAdapter;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.scala.ScalaBundle;
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.ScTemplateDefinition;

import javax.swing.*;
import javax.swing.event.DocumentEvent;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;

import static org.jetbrains.plugins.scala.lang.refactoring.ScalaNamesValidator$.MODULE$;

/**
 * Nikolay.Tropin
 * 2014-05-23
 */
public class ScalaExtractTraitDialog extends DialogWrapper {

  private static final String REFACTORING_NAME = ScalaBundle.message("extract.trait.name");
  private static final String DESTINATION_PACKAGE_RECENT_KEY = "ExtractTrait.RECENT_KEYS";

  private final ScTemplateDefinition mySourceClass;
  private final Project myProject;
  private final List<ScalaExtractMemberInfo> myMembers;
  private JPanel contentPane;
  private JTextField mySourceClassFld;
  private JTextField traitNameFld;
  private JLabel sourceNameLbl;
  private JLabel traitNameLbl;
  private JPanel memberSelectionPane;
  private JPanel packageSelectionPane;
  private JLabel packageLbl;
  private PackageNameReferenceEditorCombo myPackageNameField;

  public ScalaExtractTraitDialog(Project project, ScTemplateDefinition sourceClass) {
    super(project, false);
    mySourceClass = sourceClass;
    myProject = mySourceClass.getProject();
    myMembers = ExtractSuperUtil.possibleMembersToExtract(sourceClass);
    setTitle(ScalaBundle.message("extract.trait.title"));
    init();
    setupDialog();
    updateOkStatus();
  }

  public List<ScalaExtractMemberInfo> getSelectedMembers() {
    ArrayList<ScalaExtractMemberInfo> result = new ArrayList<ScalaExtractMemberInfo>();
    for (ScalaExtractMemberInfo info : myMembers) {
      if (info.isChecked()) {
        result.add(info);
      }
    }
    return result;
  }

  public String getTraitName() {
    return traitNameFld.getText();
  }

  public String getPackageName() {
    return myPackageNameField.getText();
  }

  private void setupDialog() {
    setOKButtonText("Refactor");
    setOKButtonMnemonic('R');
    sourceNameLbl.setText(ScalaBundle.message("extract.trait.top.label.text"));
    traitNameLbl.setText(ScalaBundle.message("extract.trait.name"));
    packageLbl.setText(ScalaBundle.message("extract.trait.package.label"));
    mySourceClassFld.setText(ExtractSuperUtil.classPresentableName(mySourceClass));

    memberSelectionPane.add(createMemberSelectionPanel(), new GridConstraints());
    myPackageNameField = createPackageNameField();
    packageSelectionPane.add(myPackageNameField, BorderLayout.CENTER);

    traitNameFld.getDocument().addDocumentListener(new DocumentAdapter() {
      @Override
      protected void textChanged(DocumentEvent e) {
        updateOkStatus();
      }
    });
  }

  private JPanel createMemberSelectionPanel() {
    String title = ScalaBundle.message("members.to.extract");
    String abstractHeader = ScalaBundle.message("extract.abstracts");
    return new ScalaExtractMembersSelectionPanel(title, myMembers, abstractHeader);
  }

  protected PackageNameReferenceEditorCombo createPackageNameField() {
    String name = ExtractSuperUtil.packageName(mySourceClass);
    return new PackageNameReferenceEditorCombo(name, myProject, DESTINATION_PACKAGE_RECENT_KEY,
        RefactoringBundle.message("choose.destination.package"));
  }

  private void updateOkStatus() {
    setOKActionEnabled(MODULE$.isIdentifier(getTraitName()));
  }

  @Override
  protected void doOKAction() {
    String pckgWarning = ExtractSuperUtil.checkPackage(getPackageName(), getTraitName(), mySourceClass);
    if (pckgWarning != null) {
      showErrorMessage(pckgWarning);
      return;
    }

    super.doOKAction();
  }

  private void showErrorMessage(String message) {
    if (ApplicationManager.getApplication().isUnitTestMode()) throw new RuntimeException(message);
    CommonRefactoringUtil.showErrorMessage(REFACTORING_NAME, message, null, myProject);
  }

  @Nullable
  @Override
  protected JComponent createCenterPanel() {
    return contentPane;
  }

  @Override
  protected JComponent createContentPane() {
    return contentPane;
  }

  @Nullable
  @Override
  public JComponent getPreferredFocusedComponent() {
    return traitNameFld;
  }

  {
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
    $$$setupUI$$$();
  }

  /**
   * Method generated by IntelliJ IDEA GUI Designer
   * >>> IMPORTANT!! <<<
   * DO NOT edit this method OR call it in your code!
   *
   * @noinspection ALL
   */
  private void $$$setupUI$$$() {
    contentPane = new JPanel();
    contentPane.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1));
    final JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1));
    contentPane.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
    mySourceClassFld = new JTextField();
    mySourceClassFld.setEditable(false);
    mySourceClassFld.setEnabled(true);
    panel1.add(mySourceClassFld, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
    sourceNameLbl = new JLabel();
    sourceNameLbl.setText("Extract trait from:");
    panel1.add(sourceNameLbl, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    traitNameLbl = new JLabel();
    traitNameLbl.setText("Trait name:");
    panel1.add(traitNameLbl, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    traitNameFld = new JTextField();
    panel1.add(traitNameFld, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
    final Spacer spacer1 = new Spacer();
    contentPane.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
    memberSelectionPane = new JPanel();
    memberSelectionPane.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    contentPane.add(memberSelectionPane, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
    final JPanel panel2 = new JPanel();
    panel2.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
    contentPane.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
    packageSelectionPane = new JPanel();
    packageSelectionPane.setLayout(new BorderLayout(0, 0));
    panel2.add(packageSelectionPane, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
    packageLbl = new JLabel();
    packageLbl.setText("Package for new trait:");
    panel2.add(packageLbl, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
  }

  /**
   * @noinspection ALL
   */
  public JComponent $$$getRootComponent$$$() {
    return contentPane;
  }
}


// This work is licensed under the Creative Commons Attribution 3.0 Unported License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/
// or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View,
// California, 94041, USA.

// Persistence Of Vision raytracer sample file.
// File by Dieter Bayer.
//
// -w320 -h240
// -w800 -h600 +a0.3

#version 3.6;

global_settings {
  assumed_gamma 1.0
}

#include "colors.inc"

camera {
   location  <0, 20, -100>
   angle 85 // direction <0,  0,    0.7>
   up        <0,  1,    0>
   right   x*image_width/image_height
}

background { color SkyBlue }

// declare rainbow's colours

#declare r_violet1 = colour red 1.0 green 0.5 blue 1.0 filter 1.0;
#declare r_violet2 = colour red 1.0 green 0.5 blue 1.0 filter 0.8;
#declare r_indigo  = colour red 0.5 green 0.5 blue 1.0 filter 0.8;
#declare r_blue    = colour red 0.2 green 0.2 blue 1.0 filter 0.8;
#declare r_cyan    = colour red 0.2 green 1.0 blue 1.0 filter 0.8;
#declare r_green   = colour red 0.2 green 1.0 blue 0.2 filter 0.8;
#declare r_yellow  = colour red 1.0 green 1.0 blue 0.2 filter 0.8;
#declare r_orange  = colour red 1.0 green 0.5 blue 0.2 filter 0.8;
#declare r_red1    = colour red 1.0 green 0.2 blue 0.2 filter 0.8;
#declare r_red2    = colour red 1.0 green 0.2 blue 0.2 filter 1.0;

// create the rainbow

rainbow {
  angle 42.5
  width 5
  distance 1.0e7
  direction <-0.2, -0.2, 1>
  jitter 0.01
  colour_map {
    [0.000  colour r_violet1]
    [0.100  colour r_violet2]
    [0.214  colour r_indigo]
    [0.328  colour r_blue]
    [0.442  colour r_cyan]
    [0.556  colour r_green]
    [0.670  colour r_yellow]
    [0.784  colour r_orange]
    [0.900  colour r_red1]
  }
}

rainbow {
  angle 37
  width 5
  distance 1.0e7
  direction <-0.2, -0.2, 1>
  jitter 0.01
  colour_map {
    [0.000  colour r_violet1]
    [0.100  colour r_violet2]
    [0.214  colour r_indigo]
    [0.328  colour r_blue]
    [0.442  colour r_cyan]
    [0.556  colour r_green]
    [0.670  colour r_yellow]
    [0.784  colour r_orange]
    [0.900  colour r_red1]
  }
}

sky_sphere {
  pigment {
    gradient y
    color_map {
      [0 colour SkyBlue]
      [1 colour MidnightBlue]
    }
    scale 2
    translate <-1, -1, -1>
  }
}

/* Put down the beloved famous raytrace green/yellow checkered floor */
plane { y, -10
   pigment {
      checker colour Yellow colour Green
      scale 20
   }
   finish {
      ambient 0.2
      diffuse 0.8
   }
}

sphere { <0, 25, 0>, 40

   pigment {Red}
   finish {
      ambient 0.2
      diffuse 0.6
      phong 1.0
      phong_size 20
   }
}

sphere { <-100, 150, 200>,  20
   pigment {Magenta}
   finish {
      ambient 0.2
      diffuse 0.6
      phong 1.0
      phong_size 20
   }
}

sphere { <100, 25, 100>, 30
   pigment {Red}
   finish {
      ambient 0.2
      diffuse 0.6
      phong 1.0
      phong_size 20
   }
}

light_source {<100, 120, 40> colour White}


; Joomla! Project
; Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8

COM_POSTINSTALL="Post-installation Messages"
COM_POSTINSTALL_BTN_HIDE="Hide this message"
COM_POSTINSTALL_BTN_RESET="Reset Messages"
COM_POSTINSTALL_CONFIGURATION="Post-installation Messages: Options"
COM_POSTINSTALL_LBL_MESSAGES="Post-installation and Upgrade Messages"
COM_POSTINSTALL_LBL_NOMESSAGES_DESC="You have read all the messages."
COM_POSTINSTALL_LBL_NOMESSAGES_TITLE="No Messages"
COM_POSTINSTALL_LBL_RELEASENEWS="Release news from the Joomla! Project"
COM_POSTINSTALL_LBL_SINCEVERSION="Since version %s"
COM_POSTINSTALL_MESSAGES_FOR="Showing messages for"
COM_POSTINSTALL_MESSAGES_TITLE="Post-installation Messages for %s"
COM_POSTINSTALL_XML_DESCRIPTION="Displays post-installation and post-upgrade messages for Joomla and its extensions."


package com.twitter.util.tunable

import org.scalatest.funsuite.AnyFunSuite

class ServiceLoadedTunableTestClient1 extends ServiceLoadedTunableMap with TunableMap.Proxy {

  private val tunableMap = TunableMap.newMutable()

  tunableMap.put("tunableId1", "foo")
  tunableMap.put("tunableId2", 5)

  protected def underlying: TunableMap = tunableMap
  def id: String = "client1"
}

class ServiceLoadedTunableTestClient2 extends ServiceLoadedTunableMap with TunableMap.Proxy {
  protected def underlying: TunableMap = NullTunableMap
  def id: String = "client2"
}

class ServiceLoadedTunableTestClient2Dup extends ServiceLoadedTunableMap with TunableMap.Proxy {
  protected def underlying: TunableMap = NullTunableMap
  def id: String = "client2"
}

class ServiceLoadedTunableMapTest extends AnyFunSuite {

  test(
    "IllegalArgumentException thrown when there is more than one ServiceLoadedTunableMap " +
      "for a given serviceName/id"
  ) {

    val ex = intercept[IllegalStateException] {
      ServiceLoadedTunableMap("client2")
    }
    assert(ex.getMessage.contains("Found multiple `ServiceLoadedTunableMap`s for client2"))
  }

  test("NullTunableMap returned when no matches") {
    intercept[IllegalStateException] {
      val tunableMap = ServiceLoadedTunableMap("Non-existent-id")
      assert(tunableMap eq NullTunableMap)
    }
  }

  test("TunableMap returned when there is one match for id") {
    intercept[IllegalStateException] {

      val tunableMap = ServiceLoadedTunableMap("client1")

      assert(tunableMap.entries.size == 2)
      assert(tunableMap(TunableMap.Key[String]("tunableId1"))() == Some("foo"))
      assert(tunableMap(TunableMap.Key[Int]("tunableId2"))() == Some(5))
    }
  }
}