text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MattermostDriverMaker.Model
{
	enum MmInType
	{
		None,

		Body,
		Path,
		Query,
		FormData,
	}
}

redpajama_set_name: RedPajamaGithub


text:
   SELECT USER FROM HU.ECCO;
-- RERUN if USER value does not match preceding AUTHORIZATION comment

-- date_time print

-- TEST:0230 Transactions serializable - assign sequential key!

      SELECT COUNT(*)
               FROM TT;
-- PASS:0230 If count = 11?

      SELECT COUNT(DISTINCT ANUM)
               FROM TT;
-- PASS:0230 If count = 11?

      COMMIT WORK;

-- END TEST >>> 0230 <<< END TEST

-- *************************************************////END-OF-MODULE


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CloudBread.Models
{
    public class RowcountResult
    {
        public string result { get; set; }
    }
}


text:
<bill session="110" type="s" number="2689" updated="2009-01-09T17:27:46-05:00">
	<status><introduced date="1204606800" datetime="2008-03-04"/></status>

	<introduced date="1204606800" datetime="2008-03-04"/>
	<titles>
		<title type="official" as="introduced">A bill to amend section 411h of title 37, United States Code, to provide travel and transportation allowances for family members of members of the uniformed services with serious inpatient psychiatric conditions.</title>
	</titles>
	<sponsor id="300090"/>
	<cosponsors>
		<cosponsor id="300059" joined="2008-04-14"/>
		<cosponsor id="300013" joined="2008-04-24"/>
		<cosponsor id="300023" joined="2008-04-17"/>
		<cosponsor id="300083" joined="2008-04-14"/>
		<cosponsor id="300091" joined="2008-07-29"/>
		<cosponsor id="300078" joined="2008-03-04"/>
		<cosponsor id="300036" joined="2008-04-29"/>
		<cosponsor id="300021" joined="2008-04-24"/>
		<cosponsor id="300006" joined="2008-03-04"/>
		<cosponsor id="400194" joined="2008-04-16"/>
		<cosponsor id="300100" joined="2008-05-07"/>
	</cosponsors>
	<actions>
		<action date="1204606800" datetime="2008-03-04"><text>Read twice and referred to the Committee on Armed Services.</text></action>
	</actions>
	<committees>

	</committees>
	<relatedbills>

	</relatedbills>
	<subjects>

	</subjects>
	<amendments>

	</amendments>

	3/4/2008--Introduced.
Authorizes the provision by the Secretary of the military department concerned of a travel and transportation allowance for up to three family members of a member of the Armed Forces who is hospitalized in a military medical facility in the United States for a serious psychiatric condition, as long as such transportation is provided pursuant to travel orders issued upon the recommendation of a physician that the family's presence would be helpful and beneficial to the member's treatment and recovery.

</bill>


text:
require 'rails_helper'

module MidasGenie
  describe Survey do
    describe '# Associations' do
      it { should have_many(:midas_survey_sections) }
      it { should have_many(:midas_sections).through(:midas_survey_sections) }
      it { should have_many(:midas_section_questions).through(:midas_sections) }
      it { should have_many(:midas_questions).through(:midas_section_questions) }
    end

    describe '# Validations' do
      it { should validate_presence_of(:title) }
    end
  end
end


text:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://www.mendix.com/package/1.0/">
    <clientModule name="GridSelector" version="2.3.2" xmlns="http://www.mendix.com/clientModule/1.0/">
        <widgetFiles>
            <widgetFile path="GridSelector/CheckboxGrid.xml"/>
            <widgetFile path="GridSelector/RadioGrid.xml"/>
        </widgetFiles>
        <files>
            <file path="GridSelector/"/>
        </files>
    </clientModule>
</package>


text:
using System;
using System.Diagnostics.Contracts;
using System.Linq.Expressions;
using System.Reactive.Linq;
using System.Reflection;

namespace Qactive
{
  // HACK: Rx's private IQbservable implementation (ObservableQuery<TSource>) compiles the expression and subscribes all at once; however, compilation
  // demands full trust. We must assert full trust for the Compile invocation so that it can create a dynamic assembly, but we don't want to assert full
  // trust around the call to Subscribe, which would potentially allow clients' queries to execute unrestricted. This class separates compilation from
  // subscription using reflection on Rx's underlying query implementation. If any of the implementation details change, then this class must be recompiled,
  // with one potential exception: If Rx were to adopt the ISecureQbservable<TSource> interface defined in Qactive, then we could remove the definition
  // from this library, and the use of reflection, and simply rely on a cast instead.
  internal sealed class RxSecureQbservable<TSource> : ISecureQbservable<TSource>
  {
    private static readonly Type rxQuery = typeof(Qbservable).GetAssembly().GetType("System.Reactive.ObservableQuery`1", throwOnError: true).MakeGenericType(typeof(TSource));
    private static readonly FieldInfo rxQuerySource = rxQuery.GetField("_source", BindingFlags.NonPublic | BindingFlags.Instance);

    private static readonly Type rxRewriter = rxQuery.GetNestedType("ObservableRewriter", BindingFlags.NonPublic).MakeGenericType(typeof(TSource));
    private static readonly MethodInfo rxRewriterVisit = rxRewriter.GetMethod("Visit", new[] { typeof(Expression) });

    private readonly IQbservable<TSource> original;

    public RxSecureQbservable(IQbservable<TSource> original)
    {
      Contract.Requires(original != null);

      this.original = original;
    }

    [ContractInvariantMethod]
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Required for code contracts.")]
    private void ObjectInvariant()
    {
      Contract.Invariant(original != null);
    }

    public static bool IsRxQuery(IQbservable<TSource> query)
    {
      Contract.Requires(query != null);

      return rxQuery.IsAssignableFrom(query.GetType());
    }

    public Type ElementType => original.ElementType;

    public Expression Expression => original.Expression;

    public IQbservableProvider Provider => original.Provider;

    public IDisposable Subscribe(IObserver<TSource> observer) => original.Subscribe(observer);

    public void PrepareUnsafe()
    {
      if (rxQuerySource.GetValue(original) == null)
      {
        var observableRewriter = Activator.CreateInstance(rxRewriter);
        var body = (Expression)rxRewriterVisit.Invoke(observableRewriter, new[] { original.Expression });
        var expression = Expression.Lambda<Func<IObservable<TSource>>>(body, new ParameterExpression[0]);
        var compiled = expression.Compile();

        rxQuerySource.SetValue(original, compiled());
      }
    }
  }
}


text:
package kv_test

import (
	"bytes"
	"encoding/json"
	"net/http"
	"testing"

	"github.com/cockroachdb/cockroach/client"
	"github.com/cockroachdb/cockroach/kv"
	"github.com/cockroachdb/cockroach/proto"
	"github.com/cockroachdb/cockroach/rpc"
	"github.com/cockroachdb/cockroach/util"
	gogoproto "github.com/gogo/protobuf/proto"
	yaml "gopkg.in/yaml.v1"
)

func createTestClient(addr string) *client.KV {
	transport := &http.Transport{TLSClientConfig: rpc.LoadInsecureTLSConfig().Config()}
	return client.NewKV(nil, client.NewHTTPSender(addr, transport))
}

// TestKVDBCoverage verifies that all methods may be invoked on the
// key value database.
func TestKVDBCoverage(t *testing.T) {
	addr, server, _ := startServer(t)
	defer server.Close()

	kvClient := createTestClient(addr)
	key := proto.Key("a")
	value1 := []byte("value1")
	value2 := []byte("value2")
	value3 := []byte("value3")

	// Put first value at key.
	putReq := &proto.PutRequest{Value: proto.Value{Bytes: value1}}
	putReq.Key = key
	putResp := &proto.PutResponse{}
	if err := kvClient.Call(proto.Put, putReq, putResp); err != nil || putResp.Error != nil {
		t.Fatalf("%s, %s", err, putResp.GoError())
	}

	// Verify put with Contains.
	containsReq := &proto.ContainsRequest{}
	containsReq.Key = key
	containsResp := &proto.ContainsResponse{}
	if err := kvClient.Call(proto.Contains, containsReq, containsResp); err != nil || containsResp.Error != nil {
		t.Fatalf("%s, %s", err, containsResp.GoError())
	}
	if !containsResp.Exists {
		t.Error("expected contains to be true")
	}

	// Conditional put should succeed, changing value1 to value2.
	cPutReq := &proto.ConditionalPutRequest{
		Value:    proto.Value{Bytes: value2},
		ExpValue: &proto.Value{Bytes: value1},
	}
	cPutReq.Key = key
	cPutResp := &proto.ConditionalPutResponse{}
	if err := kvClient.Call(proto.ConditionalPut, cPutReq, cPutResp); err != nil || cPutResp.Error != nil {
		t.Fatalf("%s, %s", err, cPutResp.GoError())
	}

	// Verify get by looking up conditional put value.
	getReq := &proto.GetRequest{}
	getReq.Key = key
	getResp := &proto.GetResponse{}
	if err := kvClient.Call(proto.Get, getReq, getResp); err != nil || getResp.Error != nil {
		t.Fatalf("%s, %s", err, getResp.GoError())
	}
	if !bytes.Equal(getResp.Value.Bytes, value2) {
		t.Errorf("expected get to return %q; got %q", value2, getResp.Value.Bytes)
	}

	// Increment.
	incrReq := &proto.IncrementRequest{Increment: 10}
	incrReq.Key = proto.Key("i")
	incrResp := &proto.IncrementResponse{}
	if err := kvClient.Call(proto.Increment, incrReq, incrResp); err != nil || incrResp.Error != nil {
		t.Fatalf("%s, %s", err, incrResp.GoError())
	}
	if incrResp.NewValue != incrReq.Increment {
		t.Errorf("expected increment new value of %d; got %d", incrReq.Increment, incrResp.NewValue)
	}

	// Delete conditional put value.
	delReq := &proto.DeleteRequest{}
	delReq.Key = key
	delResp := &proto.DeleteResponse{}
	if err := kvClient.Call(proto.Delete, delReq, delResp); err != nil || delResp.Error != nil {
		t.Fatalf("%s, %s", err, delResp.GoError())
	}
	if err := kvClient.Call(proto.Contains, containsReq, containsResp); err != nil || containsResp.Error != nil {
		t.Fatalf("%s, %s", err, containsResp.GoError())
	}
	if containsResp.Exists {
		t.Error("expected contains to be false after delete")
	}

	// Put values in anticipation of scan & delete range.
	keyValues := []proto.KeyValue{
		{Key: proto.Key("a"), Value: proto.Value{Bytes: value1}},
		{Key: proto.Key("b"), Value: proto.Value{Bytes: value2}},
		{Key: proto.Key("c"), Value: proto.Value{Bytes: value3}},
	}
	for _, kv := range keyValues {
		putReq.Key, putReq.Value = kv.Key, kv.Value
		if err := kvClient.Call(proto.Put, putReq, putResp); err != nil || putResp.Error != nil {
			t.Fatalf("%s, %s", err, putResp.GoError())
		}
	}
	scanReq := &proto.ScanRequest{}
	scanReq.Key = proto.Key("a")
	scanReq.EndKey = proto.Key("c").Next()
	scanResp := &proto.ScanResponse{}
	if err := kvClient.Call(proto.Scan, scanReq, scanResp); err != nil || scanResp.Error != nil {
		t.Fatalf("%s, %s", err, scanResp.GoError())
	}
	if len(scanResp.Rows) != len(keyValues) {
		t.Fatalf("expected %d rows in scan; got %d", len(keyValues), len(scanResp.Rows))
	}
	for i, kv := range keyValues {
		if !bytes.Equal(scanResp.Rows[i].Value.Bytes, kv.Value.Bytes) {
			t.Errorf("%d: key %q, values %q != %q", i, kv.Key, scanResp.Rows[i].Value.Bytes, kv.Value.Bytes)
		}
	}

	deleteRangeReq := &proto.DeleteRangeRequest{}
	deleteRangeReq.Key = proto.Key("a")
	deleteRangeReq.EndKey = proto.Key("c").Next()
	deleteRangeResp := &proto.DeleteRangeResponse{}
	if err := kvClient.Call(proto.DeleteRange, deleteRangeReq, deleteRangeResp); err != nil || deleteRangeResp.Error != nil {
		t.Fatalf("%s, %s", err, deleteRangeResp.GoError())
	}
	if deleteRangeResp.NumDeleted != int64(len(keyValues)) {
		t.Fatalf("expected %d rows in deleterange; got %d", len(keyValues), deleteRangeResp.NumDeleted)
	}
}

// TestKVDBInternalMethods verifies no internal methods are available
// HTTP DB interface.
func TestKVDBInternalMethods(t *testing.T) {
	addr, server, _ := startServer(t)
	defer server.Close()

	testCases := []struct {
		method string
		args   proto.Request
		reply  proto.Response
	}{
		{proto.InternalRangeLookup, &proto.InternalRangeLookupRequest{}, &proto.InternalRangeLookupResponse{}},
		{proto.InternalGC, &proto.InternalGCRequest{}, &proto.InternalGCResponse{}},
		{proto.InternalHeartbeatTxn, &proto.InternalHeartbeatTxnRequest{}, &proto.InternalHeartbeatTxnResponse{}},
		{proto.InternalPushTxn, &proto.InternalPushTxnRequest{}, &proto.InternalPushTxnResponse{}},
		{proto.InternalResolveIntent, &proto.InternalResolveIntentRequest{}, &proto.InternalResolveIntentResponse{}},
		{proto.InternalMerge, &proto.InternalMergeRequest{}, &proto.InternalMergeResponse{}},
		{proto.InternalTruncateLog, &proto.InternalTruncateLogRequest{}, &proto.InternalTruncateLogResponse{}},
	}
	// Verify non-public methods experience bad request errors.
	kvClient := createTestClient(addr)
	for i, test := range testCases {
		test.args.Header().Key = proto.Key("a")
		err := kvClient.Call(test.method, test.args, test.reply)
		if err == nil {
			t.Errorf("%d: unexpected success calling %s", i, test.method)
		} else if err.Error() != "404 Not Found" {
			t.Errorf("%d: expected 404; got %s", i, err)
		}
	}
}

// TestKVDBEndTransactionWithTriggers verifies that triggers are
// disallowed on call to EndTransaction.
func TestKVDBEndTransactionWithTriggers(t *testing.T) {
	addr, server, _ := startServer(t)
	defer server.Close()

	kvClient := createTestClient(addr)
	txnOpts := &client.TransactionOptions{Name: "test"}
	err := kvClient.RunTransaction(txnOpts, func(txn *client.KV) error {
		// Make an EndTransaction request which would fail if not
		// stripped. In this case, we set the start key to "bar" for a
		// split of the default range; start key must be "" in this case.
		return txn.Call(proto.EndTransaction, &proto.EndTransactionRequest{
			RequestHeader: proto.RequestHeader{Key: proto.Key("foo")},
			Commit:        true,
			InternalCommitTrigger: &proto.InternalCommitTrigger{
				SplitTrigger: &proto.SplitTrigger{
					UpdatedDesc: proto.RangeDescriptor{StartKey: proto.Key("bar")},
				},
			},
		}, &proto.EndTransactionResponse{})
	})
	if err == nil {
		t.Errorf("expected 400 bad request error on commit")
	}
}

// TestKVDBContentTypes verifies all combinations of request /
// response content encodings are supported.
func TestKVDBContentType(t *testing.T) {
	addr, server, _ := startServer(t)
	defer server.Close()

	putReq := &proto.PutRequest{
		RequestHeader: proto.RequestHeader{
			Key: proto.Key("a"),
		},
		Value: proto.Value{Bytes: []byte("value")},
	}

	testCases := []struct {
		cType, accept, expCType string
		expErr                  bool
	}{
		{util.JSONContentType, util.JSONContentType, util.JSONContentType, false},
		{util.ProtoContentType, util.JSONContentType, util.JSONContentType, false},
		{util.YAMLContentType, util.JSONContentType, "", true},
		{util.JSONContentType, util.ProtoContentType, util.ProtoContentType, false},
		{util.ProtoContentType, util.ProtoContentType, util.ProtoContentType, false},
		{util.YAMLContentType, util.ProtoContentType, "", true},
		{util.JSONContentType, util.YAMLContentType, util.JSONContentType, false},
		{util.ProtoContentType, util.YAMLContentType, util.ProtoContentType, false},
		{util.YAMLContentType, util.YAMLContentType, "", true},
		{util.JSONContentType, "", util.JSONContentType, false},
		{util.ProtoContentType, "", util.ProtoContentType, false},
		{util.YAMLContentType, "", "", true},
	}
	for i, test := range testCases {
		var body []byte
		var err error
		switch test.cType {
		case util.JSONContentType:
			body, err = json.Marshal(putReq)
		case util.ProtoContentType:
			body, err = gogoproto.Marshal(putReq)
		case util.YAMLContentType:
			body, err = yaml.Marshal(putReq)
		}
		if err != nil {
			t.Fatalf("%d: %s", i, err)
		}
		// Send a Put request but with non-canonical capitalization.
		httpReq, err := http.NewRequest("POST", "http://"+addr+kv.DBPrefix+"Put", bytes.NewReader(body))
		if err != nil {
			t.Fatalf("%d: %s", i, err)
		}
		httpReq.Header.Add(util.ContentTypeHeader, test.cType)
		if test.accept != "" {
			httpReq.Header.Add(util.AcceptHeader, test.accept)
		}
		resp, err := http.DefaultClient.Do(httpReq)
		if err != nil {
			t.Fatalf("%d: %s", i, err)
		}
		if !test.expErr && resp.StatusCode != 200 {
			t.Fatalf("%d: HTTP response status code != 200; got %d", i, resp.StatusCode)
		} else if test.expErr {
			if resp.StatusCode != 400 {
				t.Fatalf("%d: expected client request error; got %d", i, resp.StatusCode)
			}
			continue
		}
		if cType := resp.Header.Get(util.ContentTypeHeader); cType != test.expCType {
			t.Errorf("%d: expected content type %s; got %s", i, test.expCType, cType)
		}
	}
}

// TestKVDBTransaction verifies that transactions work properly over
// the KV DB endpoint.
func TestKVDBTransaction(t *testing.T) {
	addr, server, _ := startServer(t)
	defer server.Close()

	kvClient := createTestClient(addr)

	key := proto.Key("db-txn-test")
	value := []byte("value")
	// Use snapshot isolation so non-transactional read can always push.
	txnOpts := &client.TransactionOptions{
		Name:      "test",
		Isolation: proto.SNAPSHOT,
	}
	err := kvClient.RunTransaction(txnOpts, func(txn *client.KV) error {
		pr := &proto.PutResponse{}
		if err := txn.Call(proto.Put, proto.PutArgs(key, value), pr); err != nil {
			t.Fatal(err)
		}

		// Attempt to read outside of txn.
		gr := &proto.GetResponse{}
		if err := kvClient.Call(proto.Get, proto.GetArgs(key), gr); err != nil {
			t.Fatal(err)
		}
		if gr.Value != nil {
			t.Errorf("expected nil value; got %+v", gr.Value)
		}

		// Read within the transaction.
		if err := txn.Call(proto.Get, proto.GetArgs(key), gr); err != nil {
			t.Fatal(err)
		}
		if gr.Value == nil || !bytes.Equal(gr.Value.Bytes, value) {
			t.Errorf("expected value %q; got %q", value, gr.Value.Bytes)
		}
		return nil
	})
	if err != nil {
		t.Errorf("expected success on commit; got %s", err)
	}

	// Verify the value is now visible after commit.
	gr := &proto.GetResponse{}
	if err = kvClient.Call(proto.Get, proto.GetArgs(key), gr); err != nil {
		t.Errorf("expected success reading value; got %s", err)
	}
	if gr.Value == nil || !bytes.Equal(gr.Value.Bytes, value) {
		t.Errorf("expected value %q; got %q", value, gr.Value.Bytes)
	}
}


text:
/// <reference path="../../typings/globals/jasmine/index.d.ts" />

import {KotlinSerializer} from '../../src/kotlin/serializer';
import {
  AnnotationKt,
  BodyKt,
  ClassKt,
  ClassMemberKt,
  ConstructorPropertyKt,
  CompanionObjectKt,
  DynamicLineKt,
  ExtendsKt,
  ExtensionFunctionKt,
  FileKt,
  FileMemberKt,
  FunctionCallKt,
  FunctionKt,
  FunctionSignatureKt,
  IfBlockKt,
  InitBlockKt,
  InstantiateClassKt,
  InterfaceKt,
  ImplementsKt,
  LineKt,
  ObjectKt,
  ParameterKt,
  PrimaryConstructorKt,
  PropertyKt,
  TextKt,
  TryBlockKt,
  TypeSignatureKt,
  VisibilityKt,
  WhenCaseKt,
  WhenKt,
  WhileBlockKt
} from '../../src/kotlin/lang';

function createFile() {
  return new FileKt('com.example.package', 'Test');
}

describe('KotlinSerializer', () => {

  const serializer = new KotlinSerializer();

  describe('indent()', () => {
    it('should indent multiple line', () => {
      expect(serializer.indent('a\nb\n')).toBe('    a\n    b\n')
    });
    it('should not indent empty lines', () => {
      expect(serializer.indent('a\n\nb\n')).toBe('    a\n\n    b\n')
    });
  });

  describe('getVisibilityPrefix()', () => {
    it('should return empty string for public visibility', () => {
      expect(serializer.getVisibilityPrefix(VisibilityKt.Public)).toBe('');
    });
    it('should return the correct prefix for private visibility', () => {
      expect(serializer.getVisibilityPrefix(VisibilityKt.Private)).toBe('private ');
    });
    it('should return the correct prefix for protected visibility', () => {
      expect(serializer.getVisibilityPrefix(VisibilityKt.Protected)).toBe('protected ');
    });
    it('should return the correct prefix for protected internal', () => {
      expect(serializer.getVisibilityPrefix(VisibilityKt.Internal)).toBe('internal ');
    });
    it('should throw an error for unsupported visibility values', () => {
      expect(() => serializer.getVisibilityPrefix(-1))
          .toThrowError('Unexpected visibility value: -1');
    });
  });

  describe('serializeTypeSignature()', () => {
    it('should support simple types', () => {
      const fileKt = createFile();
      const typeSignatureKt = new TypeSignatureKt('com.example.Type');

      expect(serializer.serializeTypeSignature(fileKt, typeSignatureKt)).toBe('Type');
      expect(fileKt.importMapping['com.example.Type']).toBe('Type');
    });

    it('should support fully qualified types', () => {
      const fileKt = createFile();
      fileKt.tryImport('com.example.other.Type');
      const typeSignatureKt = new TypeSignatureKt('com.example.Type');

      expect(serializer.serializeTypeSignature(fileKt, typeSignatureKt)).toBe('com.example.Type');
      expect(fileKt.importMapping['com.example.Type']).toBeUndefined();
    });

    it('should support nullable types', () => {
      const fileKt = createFile();
      const typeSignatureKt = new TypeSignatureKt('com.example.Type');
      typeSignatureKt.isNullable = true;

      expect(serializer.serializeTypeSignature(fileKt, typeSignatureKt)).toBe('Type?');
      expect(fileKt.importMapping['com.example.Type']).toBe('Type');
    });

    it('should support generic types', () => {
      const fileKt = createFile();
      const typeSignatureKt = new TypeSignatureKt('java.util.Map');
      typeSignatureKt.addGenericParameter('java.lang.String');
      typeSignatureKt.addGenericParameterNullable('java.lang.Integer');

      expect(serializer.serializeTypeSignature(fileKt, typeSignatureKt)).toBe('Map\<String, Integer?>');
      expect(fileKt.importMapping['java.util.Map']).toBe('Map');
      expect(fileKt.importMapping['java.lang.String']).toBe('String');
      expect(fileKt.importMapping['java.lang.Integer']).toBe('Integer');
    });

    it('should support nested generic types', () => {
      const fileKt = createFile();
      const nestedSignatureKt = new TypeSignatureKt('java.util.Map');
      nestedSignatureKt.addGenericParameter('java.lang.String');
      nestedSignatureKt.addGenericParameterNullable('java.lang.Integer');

      const typeSignatureKt = new TypeSignatureKt('java.util.List');
      typeSignatureKt.genericParameters.push(nestedSignatureKt);

      expect(serializer.serializeTypeSignature(fileKt, typeSignatureKt)).toBe('List\<Map\<String, Integer?>>');
      expect(fileKt.importMapping['java.util.List']).toBe('List');
      expect(fileKt.importMapping['java.util.Map']).toBe('Map');
      expect(fileKt.importMapping['java.lang.String']).toBe('String');
      expect(fileKt.importMapping['java.lang.Integer']).toBe('Integer');
    });
  });

  describe('serializeAnnotationParameter()', () => {
    it('should support default parameter', () => {
      const fileKt = createFile();
      const annotationKt = new AnnotationKt('com.example.Ann1');
      annotationKt.addSimpleParameter('value', '"test1"');
      const parameterKt = annotationKt.parameters[0];

      expect(serializer.serializeAnnotationParameter(fileKt, annotationKt, parameterKt))
          .toBe('"test1"');
    });

    it('should support explicit parameter', () => {
      const fileKt = createFile();
      const annotationKt = new AnnotationKt('com.example.Ann1');
      annotationKt.addSimpleParameter('param1', '"test1"');
      const parameterKt = annotationKt.parameters[0];

      expect(serializer.serializeAnnotationParameter(fileKt, annotationKt, parameterKt))
          .toBe('param1 = "test1"');
    });

    it('should support multiple parameters', () => {
      const fileKt = createFile();
      const annotationKt = new AnnotationKt('com.example.Ann1');
      annotationKt.addSimpleParameter('value', '"test1"');
      annotationKt.addSimpleParameter('param2', '"test2"');
      const parameterKt1 = annotationKt.parameters[0];
      const parameterKt2 = annotationKt.parameters[1];

      expect(serializer.serializeAnnotationParameter(fileKt, annotationKt, parameterKt1))
          .toBe('value = "test1"');
      expect(serializer.serializeAnnotationParameter(fileKt, annotationKt, parameterKt2))
          .toBe('param2 = "test2"');
    });
  });

  describe('serializeAnnotation()', () => {
    it('should support annotation without parameters', () => {
      const fileKt = createFile();
      const annotationKt = new AnnotationKt('com.example.Ann1');

      expect(serializer.serializeAnnotation(fileKt, annotationKt)).toBe('@Ann1');
    });

    it('should support fully qualified annotation', () => {
      const fileKt = createFile();
      fileKt.importMapping['com.example.other.Ann1'] = 'Ann1';
      const annotationKt = new AnnotationKt('com.example.Ann1');

      expect(serializer.serializeAnnotation(fileKt, annotationKt)).toBe('@com.example.Ann1');
    });

    it('should support parameters', () => {
      const fileKt = createFile();
      const annotationKt = new AnnotationKt('com.example.Ann1');
      annotationKt.addSimpleParameter('value', '"test1"');
      annotationKt.addSimpleParameter('param2', '"test2"');

      expect(serializer.serializeAnnotation(fileKt, annotationKt))
          .toBe('@Ann1(value = "test1", param2 = "test2")');
    });
  });

  describe('serializeParameterKt()', () => {
    it('should support simple parameters', () => {
      const fileKt = createFile();
      const parameterKt = new ParameterKt('param1');
      parameterKt.type = new TypeSignatureKt('kotlin.String');

      expect(serializer.serializeParameterKt(fileKt, parameterKt))
          .toBe('param1: String');
    });

    it('should support annotated parameters', () => {
      const fileKt = createFile();
      const parameterKt = new ParameterKt('param1');
      parameterKt.addAnnotation('com.example.Ann1');
      parameterKt.addAnnotation('com.example.Ann2', annotation => {
        annotation.addSimpleParameter('value', '"test1"');
      });
      parameterKt.type = new TypeSignatureKt('kotlin.String');

      expect(serializer.serializeParameterKt(fileKt, parameterKt))
          .toBe('@Ann1 @Ann2("test1") param1: String');
    });

    it('should support defaultValues', () => {
      const fileKt = createFile();
      const parameterKt = new ParameterKt('param1');
      parameterKt.type = new TypeSignatureKt('kotlin.String');
      parameterKt.defaultValue = '"test1"';

      expect(serializer.serializeParameterKt(fileKt, parameterKt))
          .toBe('param1: String = "test1"');
    });

    it('should support immutable properties', () => {
      const fileKt = createFile();
      const propertyKt = new ConstructorPropertyKt('param1');
      propertyKt.type = new TypeSignatureKt('kotlin.String');

      expect(serializer.serializeParameterKt(fileKt, propertyKt))
          .toBe('val param1: String');
    });

    it('should support mutable properties', () => {
      const fileKt = createFile();
      const propertyKt = new ConstructorPropertyKt('param1');
      propertyKt.isMutable = true;
      propertyKt.type = new TypeSignatureKt('kotlin.String');

      expect(serializer.serializeParameterKt(fileKt, propertyKt))
          .toBe('var param1: String');
    });

    it('should support propertyKt visibility', () => {
      const fileKt = createFile();
      const propertyKt = new ConstructorPropertyKt('param1');
      propertyKt.type = new TypeSignatureKt('kotlin.String');
      propertyKt.visibility = VisibilityKt.Private;

      expect(serializer.serializeParameterKt(fileKt, propertyKt))
          .toBe('private val param1: String');
    });
  });

  describe('serializeProperty()', () => {

    it('should support immutable properties', () => {
      const fileKt = createFile();
      const propertyKt = new PropertyKt('prop1');
      propertyKt.type = new TypeSignatureKt('kotlin.String');

      expect(serializer.serializeProperty(fileKt, propertyKt)).toBe('val prop1: String\n');
    });

    it('should support mutable properties', () => {
      const fileKt = createFile();
      const propertyKt = new PropertyKt('prop1');
      propertyKt.isMutable = true;
      propertyKt.type = new TypeSignatureKt('kotlin.String');

      expect(serializer.serializeProperty(fileKt, propertyKt)).toBe('var prop1: String\n');
    });

    it('should support overrides', () => {
      const fileKt = createFile();
      const propertyKt = new PropertyKt('prop1');
      propertyKt.overrides = true;
      propertyKt.type = new TypeSignatureKt('kotlin.String');

      expect(serializer.serializeProperty(fileKt, propertyKt)).toBe('override val prop1: String\n');
    });

    it('should support defaultValues', () => {
      const fileKt = createFile();
      const propertyKt = new PropertyKt('prop1');
      propertyKt.type = new TypeSignatureKt('kotlin.String');
      propertyKt.setSimpleDefaultValue('"test1"');

      expect(serializer.serializeProperty(fileKt, propertyKt))
          .toBe('val prop1: String = "test1"\n');
    });

    it('should support defaultValues with wrapped assignment', () => {
      const fileKt = createFile();
      const propertyKt = new PropertyKt('prop1');
      propertyKt.type = new TypeSignatureKt('kotlin.String');
      propertyKt.setSimpleDefaultValue('"test1"');
      propertyKt.wrapAssignment = true;

      expect(serializer.serializeProperty(fileKt, propertyKt))
          .toBe(`\
val prop1: String
        = "test1"
`);
    });

    it('should support propertyKt visibility', () => {
      const fileKt = createFile();
      const propertyKt = new PropertyKt('prop1');
      propertyKt.type = new TypeSignatureKt('kotlin.String');
      propertyKt.visibility = VisibilityKt.Private;

      expect(serializer.serializeProperty(fileKt, propertyKt)).toBe('private val prop1: String\n');
    });

    it('should support getters', () => {
      const fileKt = createFile();
      const propertyKt = new PropertyKt('prop1');
      propertyKt.type = new TypeSignatureKt('kotlin.String');
      propertyKt.setGetter(bodyKt => {
        bodyKt.writeLn('return "test1"');
      });

      expect(serializer.serializeProperty(fileKt, propertyKt))
          .toBe(`\
val prop1: String
    get() {
        return "test1"
    }
`);
    });
  });

  describe('serializeInitBlock()', () => {

    it('should support init block', () => {
      const fileKt = createFile();
      const bodyKt = new BodyKt();
      bodyKt.writeLn('throw RuntimeException()');
      const initBlockKt = new InitBlockKt(bodyKt);

      expect(serializer.serializeInitBlock(fileKt, initBlockKt))
          .toBe(`\
init {
    throw RuntimeException()
}
`);
    });
  });

  describe('serializeFunctionSignature()', () => {

    it('should support simple functions', () => {
      const fileKt = createFile();
      const functionKt = new FunctionSignatureKt('test1');

      expect(serializer.serializeFunctionSignature(fileKt, functionKt))
          .toBe(`\
fun test1()
`);
    });

    it('should support annotated functions', () => {
      const fileKt = createFile();
      const functionKt = new FunctionSignatureKt('test1');
      functionKt.addAnnotation('com.example.Ann1');
      functionKt.addAnnotation('com.example.Ann2', annotation => {
        annotation.addSimpleParameter('value', '"test1"');
      });

      expect(serializer.serializeFunctionSignature(fileKt, functionKt))
          .toBe(`\
@Ann1
@Ann2("test1")
fun test1()
`);
    });

    it('should support single parameter', () => {
      const fileKt = createFile();
      const functionKt = new FunctionSignatureKt('test1');
      functionKt.addParameter('param1', 'kotlin.String');

      expect(serializer.serializeFunctionSignature(fileKt, functionKt))
          .toBe('fun test1(param1: String)\n');
    });

    it('should support always wrap parameter', () => {
      const fileKt = createFile();
      const functionKt = new FunctionSignatureKt('test1');
      functionKt.alwaysWrapParameters = true;
      functionKt.addParameter('param1', 'kotlin.String');

      expect(serializer.serializeFunctionSignature(fileKt, functionKt))
          .toBe(`fun test1(
        param1: String)
`);
    });

    it('should support wrap after parameters', () => {
      const fileKt = createFile();
      const functionKt = new FunctionSignatureKt('test1');
      functionKt.wrapAfterParameters = true;
      functionKt.addParameter('param1', 'kotlin.String');

      expect(serializer.serializeFunctionSignature(fileKt, functionKt))
          .toBe('fun test1(param1: String\n)\n');
    });

    it('should support parameters', () => {
      const fileKt = createFile();
      const functionKt = new FunctionSignatureKt('test1');
      functionKt.addParameter('param1', 'kotlin.String');
      functionKt.addParameterNullable('param2', 'kotlin.String');
      functionKt.addParameter('param3', 'kotlin.String', (parameterKt, typeSignatureKt) => {
        parameterKt.defaultValue = '"test2"';
        typeSignatureKt.isNullable = true;
      });

      expect(serializer.serializeFunctionSignature(fileKt, functionKt))
          .toBe(`\
fun test1(
        param1: String,
        param2: String?,
        param3: String? = "test2")
`);
    });

    it('should return type', () => {
      const fileKt = createFile();
      const functionKt = new FunctionSignatureKt('test1');
      functionKt.setReturnTypeNullable('kotlin.String');

      expect(serializer.serializeFunctionSignature(fileKt, functionKt))
          .toBe(`\
fun test1(): String?
`);
    });
  });

  describe('serializeFunction()', () => {

    it('should support simple function', () => {
      const fileKt = createFile();
      const functionKt = new FunctionKt('test1');
      functionKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeFunction(fileKt, functionKt))
          .toBe(`\
fun test1() {
    throw RuntimeException()
}
`);
    });

    it('should support annotated functions', () => {
      const fileKt = createFile();
      const functionKt = new FunctionKt('test1');
      functionKt.addAnnotation('com.example.Ann1');
      functionKt.addAnnotation('com.example.Ann2', annotation => {
        annotation.addSimpleParameter('value', '"test1"');
      });
      functionKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeFunction(fileKt, functionKt))
          .toBe(`\
@Ann1
@Ann2("test1")
fun test1() {
    throw RuntimeException()
}
`);
    });

    it('should support overrides', () => {
      const fileKt = createFile();
      const functionKt = new FunctionKt('test1');
      functionKt.overrides = true;
      functionKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeFunction(fileKt, functionKt))
          .toBe(`\
override fun test1() {
    throw RuntimeException()
}
`);
    });

    it('should support parameters', () => {
      const fileKt = createFile();
      const functionKt = new FunctionKt('test1');
      functionKt.addParameter('param1', 'kotlin.String');
      functionKt.addParameterNullable('param2', 'kotlin.String');
      functionKt.addParameter('param3', 'kotlin.String', (parameterKt, typeSignatureKt) => {
        parameterKt.defaultValue = '"test2"';
        typeSignatureKt.isNullable = true;
      });
      functionKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeFunction(fileKt, functionKt))
          .toBe(`\
fun test1(
        param1: String,
        param2: String?,
        param3: String? = "test2") {
    throw RuntimeException()
}
`);
    });

    it('should return type', () => {
      const fileKt = createFile();
      const functionKt = new FunctionKt('test1');
      functionKt.setReturnTypeNullable('kotlin.String');
      functionKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeFunction(fileKt, functionKt))
          .toBe(`\
fun test1(): String? {
    throw RuntimeException()
}
`);
    });
  });

  describe('serializeExtensionFunction()', () => {

    it('should support simple function', () => {
      const fileKt = createFile();
      const functionKt = new ExtensionFunctionKt('test1');
      functionKt.extendedType = new TypeSignatureKt('kotlin.String');
      functionKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeExtensionFunction(fileKt, functionKt))
          .toBe(`\
fun String.test1() {
    throw RuntimeException()
}
`);
    });

    it('should support parameters', () => {
      const fileKt = createFile();
      const functionKt = new ExtensionFunctionKt('test1');
      functionKt.extendedType = new TypeSignatureKt('kotlin.String');
      functionKt.addParameter('param1', 'kotlin.String');
      functionKt.addParameterNullable('param2', 'kotlin.String');
      functionKt.addParameter('param3', 'kotlin.String', (parameterKt, typeSignatureKt) => {
        parameterKt.defaultValue = '"test2"';
        typeSignatureKt.isNullable = true;
      });
      functionKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeExtensionFunction(fileKt, functionKt))
          .toBe(`\
fun String.test1(
        param1: String,
        param2: String?,
        param3: String? = "test2") {
    throw RuntimeException()
}
`);
    });

    it('should return type', () => {
      const fileKt = createFile();
      const functionKt = new ExtensionFunctionKt('test1');
      functionKt.extendedType = new TypeSignatureKt('kotlin.String');
      functionKt.setReturnTypeNullable('kotlin.String');
      functionKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeExtensionFunction(fileKt, functionKt))
          .toBe(`\
fun String.test1(): String? {
    throw RuntimeException()
}
`);
    });
  });

  describe('serializeClassMember()', () => {

    it('should support properties', () => {
      const fileKt = createFile();
      const propertyKt = new PropertyKt('prop1');
      propertyKt.type = new TypeSignatureKt('kotlin.String');

      expect(serializer.serializeClassMember(fileKt, propertyKt)).toBe('val prop1: String\n');
    });

    it('should support init block', () => {
      const fileKt = createFile();
      const bodyKt = new BodyKt();
      bodyKt.writeLn('throw RuntimeException()');
      const initBlockKt = new InitBlockKt(bodyKt);

      expect(serializer.serializeClassMember(fileKt, initBlockKt))
          .toBe(`\
init {
    throw RuntimeException()
}
`);
    });

    it('should support functions', () => {
      const fileKt = createFile();
      const functionKt = new FunctionKt('test1');
      functionKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeClassMember(fileKt, functionKt))
          .toBe(`\
fun test1() {
    throw RuntimeException()
}
`);
    });

    it('should throw error for unsupported type', () => {
      class ExampleUnsupportedType implements ClassMemberKt { }

      const fileKt = createFile();
      const unsupported = new ExampleUnsupportedType();

      expect(() => serializer.serializeClassMember(fileKt, unsupported))
          .toThrowError('Unexpected ClassMember type: ExampleUnsupportedType');
    });
  });

  describe('serializePrimaryConstructor()', () => {

    it('should return empty string for null constructor', () => {
      const fileKt = createFile();

      expect(serializer.serializePrimaryConstructor(fileKt, null)).toBe('');
    });

    it('should return empty string for empty public constructor', () => {
      const fileKt = createFile();
      const constructorKt = new PrimaryConstructorKt();

      expect(serializer.serializePrimaryConstructor(fileKt, constructorKt)).toBe('');
    });

    it('should support constructor visibility', () => {
      const fileKt = createFile();
      const constructorKt = new PrimaryConstructorKt();
      constructorKt.visibility = VisibilityKt.Private;

      expect(serializer.serializePrimaryConstructor(fileKt, constructorKt))
          .toBe(' private constructor()');
    });

    it('should support single constructor parameter', () => {
      const fileKt = createFile();
      const constructorKt = new PrimaryConstructorKt();
      constructorKt.addParameter('name1', 'kotlin.String');

      expect(serializer.serializePrimaryConstructor(fileKt, constructorKt))
          .toBe('(name1: String)');
    });

    it('should support always wrap parameter', () => {
      const fileKt = createFile();
      const constructorKt = new PrimaryConstructorKt();
      constructorKt.alwaysWrapParameters = true;
      constructorKt.addParameter('name1', 'kotlin.String');

      expect(serializer.serializePrimaryConstructor(fileKt, constructorKt))
          .toBe(`(
        name1: String)`);
    });

    it('should support constructor parameters', () => {
      const fileKt = createFile();
      const constructorKt = new PrimaryConstructorKt();
      constructorKt.addParameter('name1', 'kotlin.String');
      constructorKt.addParameter('name2', 'kotlin.String', typeSignatureKt => {
        typeSignatureKt.isNullable = true;
      });
      constructorKt.addProperty('name3', 'kotlin.String');
      constructorKt.addProperty('name4', 'kotlin.String', (constructorPropertyKt, typeSignatureKt) => {
        constructorPropertyKt.isMutable = true;
        typeSignatureKt.isNullable = true;
      });

      expect(serializer.serializePrimaryConstructor(fileKt, constructorKt))
          .toBe(`(
        name1: String,
        name2: String?,
        val name3: String,
        var name4: String?)`);
    });
  });

  describe('serializeCompanionObjectMember()', () => {

    it('should support functions', () => {
      const fileKt = createFile();
      const functionKt = new FunctionKt('test1');
      functionKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeCompanionObjectMember(fileKt, functionKt))
          .toBe(`\
fun test1() {
    throw RuntimeException()
}
`);
    });

    it('should throw error for unsupported type', () => {
      class ExampleUnsupportedType implements ClassMemberKt { }

      const fileKt = createFile();
      const unsupported = new ExampleUnsupportedType();

      expect(() => serializer.serializeCompanionObjectMember(fileKt, unsupported))
          .toThrowError('Unexpected CompanionObjectMember type: ExampleUnsupportedType');
    });
  });

  describe('serializeCompanionObject()', () => {

    it('should support members', () => {
      const fileKt = createFile();
      const companionObjectKt = new CompanionObjectKt();
      companionObjectKt.addFunction('test1', bodyKt => {
        bodyKt.writeLn('throw RuntimeException()');
      });
      companionObjectKt.addFunction('test2', bodyKt => {
        bodyKt.writeLn('throw RuntimeException()');
      });

      expect(serializer.serializeCompanionObject(fileKt, companionObjectKt))
          .toBe(`\
companion object {

    fun test1() {
        throw RuntimeException()
    }

    fun test2() {
        throw RuntimeException()
    }
}
`);
    });
  });

  describe('serializeClassImplementsOrExtends()', () => {

    it('should support implements', () => {
      const fileKt = createFile();
      const implementsKt = new ImplementsKt(new TypeSignatureKt('com.example.TestInterface'));

      expect(serializer.serializeClassImplementsOrExtends(fileKt, implementsKt))
          .toBe('TestInterface');
    });

    it('should support extends', () => {
      const fileKt = createFile();
      const implementsKt = new ExtendsKt(new TypeSignatureKt('com.example.TestClass'));

      expect(serializer.serializeClassImplementsOrExtends(fileKt, implementsKt))
          .toBe('TestClass()');
    });

    it('should support extends with arguments', () => {
      const fileKt = createFile();
      const implementsKt = new ExtendsKt(new TypeSignatureKt('com.example.TestClass'));
      implementsKt.addSimpleArgument('test1', '"value1"');
      implementsKt.addSimpleArgument('test2', '"value2"');

      expect(serializer.serializeClassImplementsOrExtends(fileKt, implementsKt))
          .toBe('TestClass(test1 = "value1", test2 = "value2")');
    });

    it('should support extends with wrap arguments', () => {
      const fileKt = createFile();
      const implementsKt = new ExtendsKt(new TypeSignatureKt('com.example.TestClass'));
      implementsKt.addSimpleArgument('test1', '"value1"');
      implementsKt.addSimpleArgument('test2', '"value2"');
      implementsKt.wrapArguments = true;

      expect(serializer.serializeClassImplementsOrExtends(fileKt, implementsKt))
          .toBe(`TestClass(
        test1 = "value1",
        test2 = "value2")`);
    });
  });

  describe('serializeClass()', () => {

    it('should support empty classes', () => {
      const fileKt = createFile();
      const classKt = new ClassKt('TestClass');

      expect(serializer.serializeClass(fileKt, classKt))
          .toBe('class TestClass\n');
    });

    it('should support empty objects', () => {
      const fileKt = createFile();
      const classKt = new ObjectKt('TestObject');

      expect(serializer.serializeClass(fileKt, classKt))
          .toBe('object TestObject\n');
    });

    it('should support data classes', () => {
      const fileKt = createFile();
      const classKt = new ClassKt('TestClass');
      classKt.dataClass = true;
      classKt.setPrimaryConstructor(constructor => {
        constructor.addProperty('test1', 'kotlin.String');
      });

      expect(serializer.serializeClass(fileKt, classKt))
          .toBe(`\
data class TestClass(val test1: String)
`);
    });

    it('should support annotations', () => {
      const fileKt = createFile();
      const classKt = new ClassKt('TestClass');

      classKt.addAnnotation('com.example.Ann1');
      classKt.addAnnotation('com.example.Ann2', annotationKt => {
        annotationKt.addSimpleParameter('value', '"test1"');
      });

      expect(serializer.serializeClass(fileKt, classKt))
          .toBe(`\
@Ann1
@Ann2("test1")
class TestClass
`);
    });

    it('should support extends', () => {
      const fileKt = createFile();
      const classKt = new ClassKt('TestClass');
      classKt.extendsClass('com.example.TestClass2');
      classKt.extendsClass('com.example.TestClass3', (extendsKt, typeSignatureKt) => {
        extendsKt.addSimpleArgument('name1', '"value1"');
        typeSignatureKt.addGenericParameter('kotlin.String')
      });

      expect(serializer.serializeClass(fileKt, classKt))
          .toBe(`\
class TestClass : TestClass2(), TestClass3\<String>(name1 = "value1")
`);
    });

    it('should support implements', () => {
      const fileKt = createFile();
      const classKt = new ClassKt('TestClass');
      classKt.implementsInterface('com.example.TestInterface1');
      classKt.implementsInterface('com.example.TestInterface2', typeSignatureKt => {
        typeSignatureKt.addGenericParameter('kotlin.String')
      });

      expect(serializer.serializeClass(fileKt, classKt))
          .toBe(`\
class TestClass : TestInterface1, TestInterface2\<String>
`);
    });

    it('should support members of class', () => {
      const fileKt = createFile();
      const classKt = new ClassKt('TestClass');
      classKt.addProperty('prop1', 'kotlin.String', (propertyKt, typeSignatureKt) => {
        propertyKt.isMutable = true;
        typeSignatureKt.isNullable = true;
      });
      classKt.addProperty('prop2', 'kotlin.String', (propertyKt, typeSignatureKt) => {
        propertyKt.isMutable = true;
        typeSignatureKt.isNullable = true;
      });
      classKt.addInitBlock(bodyKt => {
        bodyKt.writeLn('throw RuntimeException()');
      });
      classKt.addFunction('test1', bodyKt => {
        bodyKt.writeLn('throw RuntimeException()');
      });
      classKt.addFunction('test2', bodyKt => {
        bodyKt.writeLn('throw RuntimeException()');
      });

      expect(serializer.serializeClass(fileKt, classKt))
          .toBe(`\
class TestClass {

    var prop1: String?
    var prop2: String?

    init {
        throw RuntimeException()
    }

    fun test1() {
        throw RuntimeException()
    }

    fun test2() {
        throw RuntimeException()
    }
}
`);
    });
    it('should support members of object', () => {
      const fileKt = createFile();
      const objectKt = new ObjectKt('TestClass');
      objectKt.addProperty('prop1', 'kotlin.String', (propertyKt, typeSignatureKt) => {
        propertyKt.isMutable = true;
        typeSignatureKt.isNullable = true;
      });
      objectKt.addProperty('prop2', 'kotlin.String', (propertyKt, typeSignatureKt) => {
        propertyKt.isMutable = true;
        typeSignatureKt.isNullable = true;
      });
      objectKt.addFunction('test1', bodyKt => {
        bodyKt.writeLn('throw RuntimeException()');
      });
      objectKt.addFunction('test2', bodyKt => {
        bodyKt.writeLn('throw RuntimeException()');
      });

      expect(serializer.serializeClass(fileKt, objectKt))
          .toBe(`\
object TestClass {

    var prop1: String?
    var prop2: String?

    fun test1() {
        throw RuntimeException()
    }

    fun test2() {
        throw RuntimeException()
    }
}
`);
    });
  });

  it('should support companion object', () => {
    const fileKt = createFile();
    const classKt = new ClassKt('TestClass');
    classKt.setCompanionObject(companionObjectKt => {
      companionObjectKt.addFunction('test1', bodyKt => {
        bodyKt.writeLn('throw RuntimeException()');
      });
      companionObjectKt.addFunction('test2', bodyKt => {
        bodyKt.writeLn('throw RuntimeException()');
      });
    });

    expect(classKt.companionObject).toBeDefined();

    expect(serializer.serializeClass(fileKt, classKt))
        .toBe(`\
class TestClass {

    companion object {

        fun test1() {
            throw RuntimeException()
        }

        fun test2() {
            throw RuntimeException()
        }
    }
}
`);
  });

  describe('serializeInterface()', () => {

    it('should support empty interfaces', () => {
      const fileKt = createFile();
      const classKt = new InterfaceKt('TestInterface');

      expect(serializer.serializeInterface(fileKt, classKt))
          .toBe('interface TestInterface\n');
    });

    it('should support annotations', () => {
      const fileKt = createFile();
      const interfaceKt = new InterfaceKt('TestInterface');
      interfaceKt.addAnnotation('com.example.Ann1');
      interfaceKt.addAnnotation('com.example.Ann2', annotationKt => {
        annotationKt.addSimpleParameter('value', '"test1"');
      });

      expect(serializer.serializeInterface(fileKt, interfaceKt))
          .toBe(`\
@Ann1
@Ann2("test1")
interface TestInterface
`);
    });

    it('should support function signatures', () => {
      const fileKt = createFile();
      const interfaceKt = new InterfaceKt('TestInterface');
      interfaceKt.addFunctionSignature('test1');
      interfaceKt.addFunctionSignature('test2', functionSignatureKt => {
        functionSignatureKt.setReturnType('kotlin.String');
      });

      expect(serializer.serializeInterface(fileKt, interfaceKt))
          .toBe(`\
interface TestInterface {

    fun test1()

    fun test2(): String
}
`);
    });

  });

  describe('serializeFileMember()', () => {

    it('should support classes', () => {
      const fileKt = createFile();
      const classKt = new ClassKt('TestClass');

      expect(serializer.serializeFileMember(fileKt, classKt))
          .toBe('class TestClass\n');
    });

    it('should support objects', () => {
      const fileKt = createFile();
      const objectKt = new ObjectKt('TestObject');

      expect(serializer.serializeFileMember(fileKt, objectKt))
          .toBe('object TestObject\n');
    });

    it('should support interfaces', () => {
      const fileKt = createFile();
      const interfaceKt = new InterfaceKt('TestInterface');

      expect(serializer.serializeFileMember(fileKt, interfaceKt))
          .toBe('interface TestInterface\n');
    });

    it('should support extension functions', () => {
      const fileKt = createFile();
      const functionKt = new ExtensionFunctionKt('test1');
      functionKt.extendedType = new TypeSignatureKt('kotlin.String');
      functionKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeFileMember(fileKt, functionKt))
          .toBe(`\
fun String.test1() {
    throw RuntimeException()
}
`);
    });

    it('should support functions', () => {
      const fileKt = createFile();
      const functionKt = new FunctionKt('test1');
      functionKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeFileMember(fileKt, functionKt))
          .toBe(`\
fun test1() {
    throw RuntimeException()
}
`);
    });

    it('should throw error for unsupported type', () => {
      class UnsupportedFileFileMemberTest implements FileMemberKt {
        name: string;
      }
      const fileKt = createFile();
      const unsupported = new UnsupportedFileFileMemberTest();

      expect(() => {serializer.serializeFileMember(fileKt, unsupported)})
          .toThrowError('Unexpected FileMember type: UnsupportedFileFileMemberTest');
    });

  });

  describe('serializeFileMember()', () => {

    it('should support many members', () => {
      const fileKt = createFile();
      fileKt.addClass('TestClass', classKt => {
        classKt.implementsInterface('com.example.Test1');
      });
      fileKt.addObject('TestObject', objectKt => {
        objectKt.implementsInterface('com.example.Test1');
      });
      fileKt.addInterface('TestInterface', interfaceKt => {
        interfaceKt.addAnnotation('com.example.Ann1');
      });
      fileKt.addFunction('test1', bodyKt => {
        bodyKt.writeLn('throw RuntimeException()')
      });
      fileKt.addExtensionFunction('test2', 'kotlin.String', bodyKt => {
        bodyKt.writeLn('throw RuntimeException()');
      });

      expect(serializer.serializeFileMembers(fileKt))
          .toBe(`\
class TestClass : Test1

object TestObject : Test1

@Ann1
interface TestInterface

fun test1() {
    throw RuntimeException()
}

fun String.test2() {
    throw RuntimeException()
}
`);
    });

  });

  describe('serializeImports()', () => {

    it('should support simple import', () => {
      const fileKt = createFile();
      fileKt.importMapping['com.example.TestClass'] = 'TestClass';

      expect(serializer.serializeImports(fileKt))
          .toBe('import com.example.TestClass\n');
    });

    it('should support default imports (kotlin)', () => {
      const fileKt = createFile();
      fileKt.importMapping['kotlin.String'] = 'String';

      expect(serializer.serializeImports(fileKt))
          .toBe('');
    });

    it('should support default imports (kotlin.collections.List)', () => {
      const fileKt = createFile();
      fileKt.importMapping['kotlin.collections.List'] = 'List';

      expect(serializer.serializeImports(fileKt))
          .toBe('');
    });

    it('should support aliases', () => {
      const fileKt = createFile();
      fileKt.importMapping['com.example.TestClass'] = 'TestClass2';

      expect(serializer.serializeImports(fileKt))
          .toBe('import com.example.TestClass as TestClass2\n');
    });

    it('should sort imports', () => {
      const fileKt = createFile();
      fileKt.importMapping['com.example.B'] = 'B';
      fileKt.importMapping['com.example.C'] = 'C';
      fileKt.importMapping['com.example.A'] = 'A';

      expect(serializer.serializeImports(fileKt))
          .toBe(`\
import com.example.A
import com.example.B
import com.example.C
`);
    });
  });

  describe('serializeIfBlock()', () => {

    it('should render if block', () => {
      const fileKt = createFile();
      const ifBlockKt = new IfBlockKt(() => 'true');
      ifBlockKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeIfBlock(fileKt, ifBlockKt))
          .toBe(`\
if (true) {
    throw RuntimeException()
}
`);
    });

    it('should render if with else', () => {
      const fileKt = createFile();
      const ifBlockKt = new IfBlockKt(() => 'true');
      ifBlockKt.body.writeLn('throw RuntimeException()');
      ifBlockKt.setElse(elseBlockKt => {
        elseBlockKt.writeLn('return true');
      });

      expect(serializer.serializeIfBlock(fileKt, ifBlockKt))
          .toBe(`\
if (true) {
    throw RuntimeException()
} else {
    return true
}
`);
    });

  });

  describe('serializeWhileBlock()', () => {

    it('should render while block', () => {
      const fileKt = createFile();
      const whileBlockKt = new WhileBlockKt(() => 'true');
      whileBlockKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeWhileBlock(fileKt, whileBlockKt))
          .toBe(`\
while (true) {
    throw RuntimeException()
}
`);
    });

  });

  describe('serializeWhen()', () => {

    it('should render when statement', () => {
      const fileKt = createFile();
      const whenKt = new WhenKt('test1');

      whenKt.addCase(() => '"test2"', caseBodyKt => {
        caseBodyKt.writeLn('return "test3"');
      });
      whenKt.addCase(() => '"test4"', caseBodyKt => {
        caseBodyKt.writeLn('return "test5"');
      });
      whenKt.setElse(elseBodyKt => {
        elseBodyKt.writeLn('throw RuntimeException()');
      });

      expect(serializer.serializeWhen(fileKt, whenKt))
          .toBe(`\
when (test1) {

    "test2" -> {
        return "test3"
    }
    "test4" -> {
        return "test5"
    }
    else -> {
        throw RuntimeException()
    }
}
`);
    });

    it('should render when without else', () => {
      const fileKt = createFile();
      const whenKt = new WhenKt('test1');

      whenKt.addCase(() => '"test2"', caseBodyKt => {
        caseBodyKt.writeLn('return "test3"');
      });
      whenKt.addCase(() => '"test4"', caseBodyKt => {
        caseBodyKt.writeLn('return "test5"');
      });

      expect(serializer.serializeWhen(fileKt, whenKt))
          .toBe(`\
when (test1) {

    "test2" -> {
        return "test3"
    }
    "test4" -> {
        return "test5"
    }
}
`);
    });

  });

  describe('serializeTryBlock()', () => {

    it('should render try-catch', () => {
      const fileKt = createFile();
      const tryBlockKt = new TryBlockKt();
      tryBlockKt.body.writeLn('return true');
      tryBlockKt.setCatch('e', 'kotlin.RuntimeException', catchBlockKt => {
        catchBlockKt.writeLn('return false')
      });

      expect(serializer.serializeTryBlock(fileKt, tryBlockKt))
          .toBe(`\
try {
    return true
} catch (e: RuntimeException) {
    return false
}
`);
    });

    it('should throw error without catch-block', () => {
      const fileKt = createFile();
      const tryBlockKt = new TryBlockKt();
      tryBlockKt.body.writeLn('return true');

      expect(() => serializer.serializeTryBlock(fileKt, tryBlockKt))
          .toThrowError('Catch block is required');
    });
  });

  describe('serializeFunctionCall()', () => {

    it('should support omitting optional variable name', () => {
      const fileKt = createFile();
      const functionCallKt = new FunctionCallKt('', 'test1');

      expect(serializer.serializeFunctionCall(fileKt, functionCallKt))
          .toBe('test1()\n');
    });

    it('should support including optional variable name', () => {
      const fileKt = createFile();
      const functionCallKt = new FunctionCallKt('var1', 'test1');

      expect(serializer.serializeFunctionCall(fileKt, functionCallKt))
          .toBe('var1.test1()\n');
    });

    it('should support single args', () => {
      const fileKt = createFile();
      const functionCallKt = new FunctionCallKt('', 'test1');
      functionCallKt.addSimpleArgument('arg1', 'arg1');

      expect(serializer.serializeFunctionCall(fileKt, functionCallKt))
          .toBe('test1(arg1)\n');
    });

    it('should support multiple args', () => {
      const fileKt = createFile();
      const functionCallKt = new FunctionCallKt('', 'test1');
      functionCallKt.addSimpleArgument('arg1', 'arg1');
      functionCallKt.addSimpleArgument('arg2', 'arg2');

      expect(serializer.serializeFunctionCall(fileKt, functionCallKt))
          .toBe(`\
test1(
        arg1 = arg1,
        arg2 = arg2)
`);
    });
  });

  describe('serializeInstantiateClass()', () => {

    it('should support no args', () => {
      const fileKt = createFile();
      const instantiateClassKt = new InstantiateClassKt('com.example.TestClass');

      expect(serializer.serializeInstantiateClass(fileKt, instantiateClassKt))
          .toBe('TestClass()\n');
    });

    it('should support single args', () => {
      const fileKt = createFile();
      const instantiateClassKt = new InstantiateClassKt('com.example.TestClass');
      instantiateClassKt.addSimpleArgument('arg1', 'arg1');

      expect(serializer.serializeInstantiateClass(fileKt, instantiateClassKt))
          .toBe('TestClass(arg1)\n');
    });

    it('should support multiple args', () => {
      const fileKt = createFile();
      const instantiateClassKt = new InstantiateClassKt('com.example.TestClass');
      instantiateClassKt.addSimpleArgument('arg1', 'arg1');
      instantiateClassKt.addSimpleArgument('arg2', 'arg2');

      expect(serializer.serializeInstantiateClass(fileKt, instantiateClassKt))
          .toBe(`\
TestClass(
        arg1 = arg1,
        arg2 = arg2)
`);
    });
  });

  describe('serializeBodyContent()', () => {

    it('should render text', () => {
      const fileKt = createFile();
      const textKt = new TextKt('test1');

      expect(serializer.serializeBodyContent(fileKt, textKt))
          .toBe('test1');
    });

    it('should render line', () => {
      const fileKt = createFile();
      const lineKt = new LineKt('test1');

      expect(serializer.serializeBodyContent(fileKt, lineKt))
          .toBe('test1\n');
    });

    it('should render dynamic line', () => {
      const fileKt = createFile();
      const lineKt = new DynamicLineKt(nestedFileKt => nestedFileKt.tryImport('kotlin.String'));

      expect(serializer.serializeBodyContent(fileKt, lineKt))
          .toBe('String\n');
    });

    it('should render if block', () => {
      const fileKt = createFile();
      const ifBlockKt = new IfBlockKt(() => 'true');
      ifBlockKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeBodyContent(fileKt, ifBlockKt))
          .toBe(`\
if (true) {
    throw RuntimeException()
}
`);
    });

    it('should render while block', () => {
      const fileKt = createFile();
      const whileBlockKt = new WhileBlockKt(() => 'true');
      whileBlockKt.body.writeLn('throw RuntimeException()');

      expect(serializer.serializeBodyContent(fileKt, whileBlockKt))
          .toBe(`\
while (true) {
    throw RuntimeException()
}
`);
    });

    it('should render when statement', () => {
      const fileKt = createFile();
      const whenKt = new WhenKt('test1');

      whenKt.addCase(() => '"test2"', caseBodyKt => {
        caseBodyKt.writeLn('return "test3"');
      });
      whenKt.addCase(() => '"test4"', caseBodyKt => {
        caseBodyKt.writeLn('return "test5"');
      });
      whenKt.setElse(elseBodyKt => {
        elseBodyKt.writeLn('throw RuntimeException()');
      });

      expect(serializer.serializeBodyContent(fileKt, whenKt))
          .toBe(`\
when (test1) {

    "test2" -> {
        return "test3"
    }
    "test4" -> {
        return "test5"
    }
    else -> {
        throw RuntimeException()
    }
}
`);
    });

    it('should render try-catch', () => {
      const fileKt = createFile();
      const tryBlockKt = new TryBlockKt();
      tryBlockKt.body.writeLn('return true');
      tryBlockKt.setCatch('e', 'kotlin.RuntimeException', catchBlockKt => {
        catchBlockKt.writeLn('return false')
      });

      expect(serializer.serializeBodyContent(fileKt, tryBlockKt))
          .toBe(`\
try {
    return true
} catch (e: RuntimeException) {
    return false
}
`);
    });

    it('should render function call', () => {
      const fileKt = createFile();
      const functionCallKt = new FunctionCallKt('var1', 'test1');
      functionCallKt.addSimpleArgument('arg1', 'arg1');
      functionCallKt.addSimpleArgument('arg2', 'arg2');

      expect(serializer.serializeBodyContent(fileKt, functionCallKt))
          .toBe(`\
var1.test1(
        arg1 = arg1,
        arg2 = arg2)
`);
    });

    it('should render class instantiation', () => {
      const fileKt = createFile();
      const instantiateClassKt = new InstantiateClassKt('com.example.TestClass');
      instantiateClassKt.addSimpleArgument('arg1', 'arg1');

      expect(serializer.serializeBodyContent(fileKt, instantiateClassKt))
          .toBe('TestClass(arg1)\n');
    });

    it('should throw error for unsupported type', () => {
      const fileKt = createFile();

      class UnsupportedTypeTest { }
      const unsupportedType = new UnsupportedTypeTest();

      expect(() => serializer.serializeBodyContent(fileKt, unsupportedType))
          .toThrowError('Unsupported BodyContentKt type: UnsupportedTypeTest');
    });
  });

  describe('serializeBody()', () => {

    it('should render multiple items', () => {
      const fileKt = createFile();

      const bodyKt = new BodyKt();
      bodyKt.write('test1');
      bodyKt.writeLn('test2');

      expect(serializer.serializeBody(fileKt, bodyKt))
          .toBe('test1test2\n');
    });

  });

  describe('serializeFileBody()', () => {

    it('should support many members', () => {
      const fileKt = createFile();
      fileKt.addClass('TestClass', classKt => {
        classKt.implementsInterface('com.example.Test1');
      });
      fileKt.addObject('TestObject', objectKt => {
        objectKt.implementsInterface('com.example.Test1');
      });
      fileKt.addInterface('TestInterface', interfaceKt => {
        interfaceKt.addAnnotation('com.example.Ann1');
      });
      fileKt.addFunction('test1', bodyKt => {
        bodyKt.writeLn('throw RuntimeException()');
      });
      fileKt.addExtensionFunction('test2', 'kotlin.String', bodyKt => {
        bodyKt.writeLn('throw RuntimeException()');
      });

      expect(serializer.serializeFileBody(fileKt))
          .toBe(`\
class TestClass : Test1

object TestObject : Test1

@Ann1
interface TestInterface

fun test1() {
    throw RuntimeException()
}

fun String.test2() {
    throw RuntimeException()
}
`);
    });

  });

  describe('serializeFile()', () => {

    it('should support empty file', () => {
      const fileKt = createFile();

      expect(serializer.serializeFile(fileKt))
          .toBe(`\
package com.example.package
`);
    });

    it('should support license header', () => {
      const fileKt = createFile();
      fileKt.licenseHeader = `\
/*
 * Test1
 *
`;

      expect(serializer.serializeFile(fileKt))
          .toBe(`\
/*
 * Test1
 *
package com.example.package
`);
    });

    it('should support license header (add trailing new line)', () => {
      const fileKt = createFile();
      fileKt.licenseHeader = `\
/*
 * Test1
 *`;

      expect(serializer.serializeFile(fileKt))
          .toBe(`\
/*
 * Test1
 *
package com.example.package
`);
    });

    it('should support many members', () => {
      const fileKt = createFile();
      fileKt.addClass('TestClass', classKt => {
        classKt.implementsInterface('com.example.Test1');
      });
      fileKt.addObject('TestObject', objectKt => {
        objectKt.implementsInterface('com.example.Test1');
      });
      fileKt.addInterface('TestInterface', interfaceKt => {
        interfaceKt.addAnnotation('com.example.Ann1');
      });
      fileKt.addFunction('test1', bodyKt => {
        bodyKt.writeLn('throw RuntimeException()');
      });
      fileKt.addExtensionFunction('test2', 'kotlin.String', bodyKt => {
        bodyKt.writeLn('throw RuntimeException()');
      });

      expect(serializer.serializeFile(fileKt))
          .toBe(`\
package com.example.package

import com.example.Ann1
import com.example.Test1

class TestClass : Test1

object TestObject : Test1

@Ann1
interface TestInterface

fun test1() {
    throw RuntimeException()
}

fun String.test2() {
    throw RuntimeException()
}
`);
    });

  });
});


text:
#define _USE_MATH_DEFINES
#include <math.h>
#ifndef M_PI
#define M_PI       3.1415926535897931160E0
#define M_PI_2     1.5707963267948965580E0
#endif

class GaussFunction {

public:

  GaussFunction(double mean, double sig, double constant) :
    theMean(mean), theSigma(sig), theConstant(constant) {}

  ~GaussFunction() {}

  double m() const {return theMean;}
  double s() const {return theSigma;}
  double c() const {return theConstant;}

  double operator()(double x) const {

    return c()*exp(-0.5*(x-m())*(x-m())/(s()*s()))/(sqrt(2.*M_PI)*s());
  }

private:

  double theMean;
  double theSigma;
  double theConstant;
};

#endif // MN_GaussFunction_H_


text:
from __future__ import unicode_literals

from .base import *

WSGI_APPLICATION = 'wsgi.heroku.application'

WSGI_APPLICATION = 'wsgi.heroku.application'

ADMIN_MEDIA_PREFIX = ''.join([STATIC_URL, 'admin/'])

import dj_database_url
DATABASE_URL = os.environ['DATABASE_URL']
DATABASES = {
    'default': dj_database_url.parse(DATABASE_URL),
}
DATABASES['default']['CONN_MAX_AGE'] = None

SECRET_KEY = os.environ['SECRET_KEY']

CONFIGURED_ALLOWED_HOSTS = os.environ['ALLOWED_HOSTS'].split(',')
for host in CONFIGURED_ALLOWED_HOSTS:
    if host:
        ALLOWED_HOSTS.append(host)

SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# djangosecure settings
SECURE_FRAME_DENY = True
SECURE_HSTS_SECONDS = True
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_BROWSER_XSS_FILTER = True
SECURE_SSL_REDIRECT = True
SECURE_CONTENT_TYPE_NOSNIFF = True


text:
var Kanae;
(function (Kanae) {
    var Upload;
    (function (Upload) {
        var Application = (function () {
            function Application() {
                this.requestValidationToken = '';
                this.postUrl = '';
                this.viewModel = {
                    progresses: ko.observableArray()
                };
                this.start();
            }
            Application.prototype.start = function () {
                var _this = this;
                if (!this.isBrowserSupport()) {
                    return;
                }
                document.addEventListener('DOMContentLoaded', function () { return _this.onPageReady(); });
            };
            Application.prototype.onPageReady = function () {
                var _this = this;
                var formE = document.getElementById('upload-form');
                var inputFileE = formE.querySelector('input[type="file"]');
                inputFileE.multiple = true;
                this.postUrl = formE.action;
                this.requestValidationToken = formE.querySelector('input[name="__RequestVerificationToken"]').value;
                formE.querySelector('input[type="submit"]').addEventListener('click', function (e) {
                    e.preventDefault();
                    for (var i = 0; i < inputFileE.files.length; i++) {
                        _this.upload(inputFileE.files[i]);
                    }
                    formE.reset();
                });
                document.addEventListener('dragenter', function (e) { return e.preventDefault(); });
                document.addEventListener('dragover', function (e) { return e.preventDefault(); });
                document.addEventListener('dragleave', function (e) { return e.preventDefault(); });
                document.addEventListener('drop', function (e) {
                    e.preventDefault();
                    for (var i = 0; i < e.dataTransfer.files.length; i++) {
                        _this.upload(e.dataTransfer.files[i]);
                    }
                });
                // ペースト
                document.body.addEventListener("paste", function (e) { return _this.handlePaste(e); });
                window.addEventListener("keydown", function (e) {
                    if (document.queryCommandSupported('paste') && e.keyCode == 86 && e.ctrlKey) {
                        document.execCommand('paste');
                    }
                });
                ko.applyBindings(this.viewModel, document.querySelector('#upload-progresses-container'));
            };
            Application.prototype.handlePaste = function (e) {
                var _this = this;
                e.preventDefault();
                var clipboardData = window.clipboardData || e.clipboardData;
                var itemsOrFiles = clipboardData.items || clipboardData.files;
                for (var i = 0; i < itemsOrFiles.length; i++) {
                    var fileOrItem = itemsOrFiles[i];
                    if (fileOrItem.type.match(/^image\//)) {
                        var file = fileOrItem.getAsFile ? fileOrItem.getAsFile() : fileOrItem;
                        setTimeout(function () { return _this.upload(file); }, 1);
                    }
                }
            };
            Application.prototype.upload = function (file) {
                var progressItem = new UploadProgressItem(file.name || 'Untitled');
                this.viewModel.progresses.unshift(progressItem);
                var xhr = new XMLHttpRequest();
                var formData = new FormData();
                xhr.addEventListener('progress', function (e) {
                    //console.log('%d/%d (%d)', e.loaded, e.total, e.loaded / e.total);
                    if (e.lengthComputable) {
                        progressItem.percent((e.loaded / e.total) * 100);
                    }
                    else {
                        progressItem.percent(null);
                    }
                });
                xhr.addEventListener('load', function (e) {
                    progressItem.percent(100);
                    progressItem.imageUrl(JSON.parse(xhr.responseText).Url);
                    progressItem.editUrl(JSON.parse(xhr.responseText).EditUrl);
                });
                formData.append('withXhr', 'true');
                formData.append('uploadedFile', file);
                formData.append('__RequestVerificationToken', this.requestValidationToken);
                xhr.open('POST', this.postUrl, true);
                xhr.send(formData);
            };
            Application.prototype.isBrowserSupport = function () {
                return (window.FormData);
            };
            Application.Current = new Application();
            return Application;
        })();
        Upload.Application = Application;
        var UploadProgressItem = (function () {
            function UploadProgressItem(name) {
                this.percent = ko.observable(null);
                this.name = ko.observable(name);
                this.imageUrl = ko.observable('');
                this.editUrl = ko.observable('');
            }
            return UploadProgressItem;
        })();
        Upload.UploadProgressItem = UploadProgressItem;
    })(Upload = Kanae.Upload || (Kanae.Upload = {}));
})(Kanae || (Kanae = {}));
//# sourceMappingURL=upload.js.map


text:
@interface ZCLoadImageHelper : NSObject

+ (void) loadImagesForView:(UIView *) view;

@end


text:
<!DOCTYPE html>

        <audio controls></audio>

Test HTMLMediaElement canPlayType() method with multiple audio mpeg MIME types.

These tests may be expected to fail if the WebKit port does not support the format.


text:
    This tests that setInnerText converts newlines to <br> elements correctly. If the test is successful, the text "SUCCESS" should be shown below.

FAILURE


text:
#import "CCBModalSheetController.h"

@interface PlayerConsolePairingWindow : CCBModalSheetController
{
    int pairing;
}

@property (nonatomic,assign) int pairing;

@end


text:
#pragma once

struct Value
{
	/*
		type 1 - string
		type 2 - bool
		type 3 - number
		type 4 - list
	*/
	unsigned int m_uiType;
	void* m_pValue;
};

struct StringValue
{
	const zString m_szValue;
};

struct BoolValue
{
	bool m_bValue;
};

struct NumberValue
{
	long m_lValue;
};

struct ListValue
{
	struct Value* m_pVal;
	struct ListValue* m_pNext;
};

struct Param
{
	zString m_szKey;
	struct Value* m_pVal;
	struct Param* m_pNext;
};

struct Value* search_parameter(struct Param* p_pParameters, const zString p_cszName);
bool* search_parameter_bool(struct Param* p_pParameters, const zString p_cszName);
long* search_parameter_number(struct Param* p_pParameters, const zString p_cszName);
zString search_parameter_str(struct Param* p_pParameters, const zString p_cszName);


text:
<!DOCTYPE html>
<title>CSS Writing Modes Test: outline layout and non-replaced inline and vertical-lr writing-mode</title>
<link rel="match" href="reference/outline-inline-vlr-006.html" />
<link rel="author" title="Koji Ishii" href="mailto:kojiishi@gmail.com" />
<link rel="help" title="7.1. Principles of Layout in Vertical Writing Modes" href="http://www.w3.org/TR/css-writing-modes-3/#vertical-layout" />
<link rel="help" title="18.4 Dynamic outlines: the 'outline' property" href="http://www.w3.org/TR/2011/REC-CSS2-20110607/ui.html#dynamic-outlines" />
<meta content="ahem" name="flags" />

Test passes if inside of blue rectangles are orange.

12345 67890


text:
/*
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0?
Find all unique triplets in the array which gives the sum of zero.

Note:
Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ¡Ü b ¡Ü c)
The solution set must not contain duplicate triplets.
    For example, given array S = {-1 0 1 2 -1 -4},

    A solution set is:
    (-1, 0, 1)
    (-1, -1, 2)
*/

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ThreeSum {
	public List<List<Integer>> threeSum(int[] num) {
		Arrays.sort(num);
		List<List<Integer>> res = new ArrayList<>();
		int i;
		for (i = 0; i < num.length - 2; i++) {
			if (i > 0 && num[i] == num[i - 1])
				continue;
			int leftCur = i + 1, rightCur = num.length - 1;
			int sum;
			while (leftCur < rightCur) {
				if (leftCur != i + 1 && num[leftCur] == num[leftCur - 1]) {
					leftCur++;
					continue;
				}
				if (rightCur != num.length - 1
						&& num[rightCur] == num[rightCur + 1]) {
					rightCur--;
					continue;
				}
				sum = num[i] + num[leftCur] + num[rightCur];
				if (sum == 0) {
					List<Integer> triplet = new ArrayList<>();
					triplet.add(num[i]);
					triplet.add(num[leftCur++]);
					triplet.add(num[rightCur--]);
					res.add(triplet);
				}
				if (sum < 0)
					leftCur++;
				else if (sum > 0)
					rightCur--;

			}

		}
		return res;
	}
}


text:
<?php namespace Nimo;

use Interop\Http\Server\MiddlewareInterface;
use Nimo\Handlers\CallableHandler;
use Nimo\Middlewares\CallableMiddleware;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

/**
 * User: mcfog
 * Date: 15/9/4
 */
class MiddlewareStack extends AbstractMiddleware
{
    /**
     * @var CallableHandler
     */
    protected $nextHandler;
    /**
     * @var MiddlewareInterface[]
     */
    protected $stack = [];
    protected $index;

    public function __construct()
    {
        $this->nextHandler = CallableHandler::wrap(function (ServerRequestInterface $request) {
            return $this->loop($request);
        });
    }

    /**
     * append $middleware
     * return $this
     * note this method would modify $this
     *
     * @param mixed $middleware
     * @return $this
     */
    public function append($middleware)
    {
        $this->stack[] = CallableMiddleware::wrap($middleware);
        return $this;
    }

    /**
     * prepend $middleware
     * return $this
     * note this method would modify $this
     *
     * @param $middleware
     * @return $this
     */
    public function prepend($middleware)
    {
        array_unshift($this->stack, CallableMiddleware::wrap($middleware));
        return $this;
    }

    protected function main(): ResponseInterface
    {
        $this->index = 0;

        return $this->loop($this->request);
    }

    /**
     * @param ServerRequestInterface $request
     * @return ResponseInterface
     */
    protected function loop(ServerRequestInterface $request)
    {
        if (!isset($this->stack[$this->index])) {
            return $this->delegate($request);
        }

        return $this->stack[$this->index++]->process($request, $this->nextHandler);
    }
}


text:
{% load videostore_extras %}

We'll pay you just to get started. The first time you hit {{ 'VIDEO_BONUS_MINS'|settings_value }} minutes of uploaded video, you get paid ${{ 'VIDEO_BONUS'|settings_value }}.

Total video uploaded	Total payment

{{ 'VIDEO_BONUS_MINS'|settings_value }} minutes	${{ 'VIDEO_BONUS'|settings_value }}


text:
require 'test_helper'

module ExceptionLogger
  class LoggedExceptionsHelperTest < ActionView::TestCase
  end
end


text:
from unittest import TestCase

from django.core.urlresolvers import resolve
from django.conf import settings
from django.http import HttpRequest
from mock import call, Mock, MagicMock, patch, sentinel
from purl import URL

from .forms import OAuth2CallbackForm
from .utils import (
    FACEBOOK,
    FacebookClient,
    GOOGLE,
    GoogleClient,
    OAuth2RequestAuthorizer,
    OAuth2Client,
    parse_response)
from .views import oauth_callback, change_email

JSON_MIME_TYPE = 'application/json; charset=UTF-8'
URLENCODED_MIME_TYPE = 'application/x-www-form-urlencoded; charset=UTF-8'

class SessionMock(Mock):

    def __setitem__(self, key, value):
        pass

def test_facebook_login_url():
    facebook_client = FacebookClient(local_host='localhost')
    facebook_login_url = URL(facebook_client.get_login_uri())
    query = facebook_login_url.query_params()
    callback_url = URL(query['redirect_uri'][0])
    func, _args, kwargs = resolve(callback_url.path())
    assert func is oauth_callback
    assert kwargs['service'] == FACEBOOK
    assert query['scope'][0] == FacebookClient.scope
    assert query['client_id'][0] == str(FacebookClient.client_id)

def test_google_login_url():
    google_client = GoogleClient(local_host='local_host')
    google_login_url = URL(google_client.get_login_uri())
    params = google_login_url.query_params()
    callback_url = URL(params['redirect_uri'][0])
    func, _args, kwargs = resolve(callback_url.path())
    assert func is oauth_callback
    assert kwargs['service'] == GOOGLE
    assert params['scope'][0] == GoogleClient.scope
    assert params['client_id'][0] == str(GoogleClient.client_id)

def test_parse_json():
    response = MagicMock()
    response.headers = {'Content-Type': JSON_MIME_TYPE}
    response.json.return_value = sentinel.json_content
    content = parse_response(response)
    assert content == sentinel.json_content

def test_parse_urlencoded():
    response = MagicMock()
    response.headers = {'Content-Type': URLENCODED_MIME_TYPE}
    response.text = 'key=value&multi=a&multi=b'
    content = parse_response(response)
    assert content == {'key': 'value', 'multi': ['a', 'b']}

class Client(OAuth2Client):
    """OAuth2Client configured for testing purposes."""
    service = sentinel.service

    client_id = sentinel.client_id
    client_secret = sentinel.client_secret

    auth_uri = sentinel.auth_uri
    token_uri = sentinel.token_uri
    user_info_uri = sentinel.user_info_uri

    scope = sentinel.scope

    def get_redirect_uri(self):
        return sentinel.redirect_uri

    def extract_error_from_response(self, response_content):
        return 'some error'

class BaseCommunicationTestCase(TestCase):

    def setUp(self):
        self.parse_mock = patch(
            'saleor.registration.utils.parse_response').start()
        self.requests_mock = patch(
            'saleor.registration.utils.requests').start()
        self.requests_mock.codes.ok = sentinel.ok

    def tearDown(self):
        patch.stopall()

class AccessTokenTestCase(BaseCommunicationTestCase):
    """Tests obtaining access_token."""

    def setUp(self):
        super(AccessTokenTestCase, self).setUp()

        self.parse_mock.return_value = {'access_token': sentinel.access_token}

        self.access_token_response = MagicMock()
        self.requests_mock.post.return_value = self.access_token_response

    def test_token_is_obtained_on_construction(self):
        """OAuth2 client asks for access token if interim code is available"""
        self.access_token_response.status_code = sentinel.ok
        Client(local_host='http://localhost', code=sentinel.code)
        self.requests_mock.post.assert_called_once()

    def test_token_success(self):
        """OAuth2 client properly obtains access token"""
        client = Client(local_host='http://localhost')
        self.access_token_response.status_code = sentinel.ok
        access_token = client.get_access_token(code=sentinel.code)
        self.assertEquals(access_token, sentinel.access_token)
        self.requests_mock.post.assert_called_once_with(
            sentinel.token_uri,
            data={'grant_type': 'authorization_code',
                  'client_id': sentinel.client_id,
                  'client_secret': sentinel.client_secret,
                  'code': sentinel.code,
                  'redirect_uri': sentinel.redirect_uri,
                  'scope': sentinel.scope},
            auth=None)

    def test_token_failure(self):
        """OAuth2 client properly reacts to access token fetch failure"""
        client = Client(local_host='http://localhost')
        self.access_token_response.status_code = sentinel.fail
        self.assertRaises(ValueError, client.get_access_token,
                          code=sentinel.code)

class UserInfoTestCase(BaseCommunicationTestCase):
    """Tests obtaining user data."""

    def setUp(self):
        super(UserInfoTestCase, self).setUp()

        self.user_info_response = MagicMock()
        self.requests_mock.get.return_value = self.user_info_response

    def test_user_info_success(self):
        """OAuth2 client properly fetches user info"""
        client = Client(local_host='http://localhost')
        self.parse_mock.return_value = sentinel.user_info
        self.user_info_response.status_code = sentinel.ok
        user_info = client.get_user_info()
        self.assertEquals(user_info, sentinel.user_info)

    def test_user_data_failure(self):
        """OAuth2 client reacts well to user info fetch failure"""
        client = Client(local_host='http://localhost')
        self.assertRaises(ValueError, client.get_user_info)

    def test_google_user_data_email_not_verified(self):
        """Google OAuth2 client checks for email verification"""
        self.user_info_response.status_code = sentinel.ok
        self.parse_mock.return_value = {'verified_email': False}
        google_client = GoogleClient(local_host='http://localhost')
        self.assertRaises(ValueError, google_client.get_user_info)

    def test_facebook_user_data_account_not_verified(self):
        """Facebook OAuth2 client checks for account verification"""
        self.user_info_response.status_code = sentinel.ok
        self.parse_mock.return_value = {'verified': False}
        facebook_client = FacebookClient(local_host='http://localhost')
        self.assertRaises(ValueError, facebook_client.get_user_info)

class AuthorizerTestCase(TestCase):

    def test_authorizes(self):
        """OAuth2 authorizer sets proper auth headers"""
        authorizer = OAuth2RequestAuthorizer(access_token='token')
        request = Mock(headers={})
        authorizer(request)
        self.assertEquals('Bearer token', request.headers['Authorization'])

class CallbackTestCase(TestCase):

    def setUp(self):
        patcher = patch(
            'saleor.registration.forms.get_client_class_for_service')
        self.getter_mock = patcher.start()
        patcher = patch('saleor.registration.forms.authenticate')
        self.authenticate_mock = patcher.start()

        self.client_class = self.getter_mock()
        self.client = self.client_class()
        self.client.get_user_info.return_value = {'id': sentinel.id,
                                                  'email': sentinel.email}

        self.form = OAuth2CallbackForm(service=sentinel.service,
                                       local_host=sentinel.local_host,
                                       data={'code': 'test_code'})
        self.assertTrue(self.form.is_valid(), self.form.errors)

    @patch('saleor.registration.forms.ExternalUserData')
    @patch('saleor.registration.forms.User')
    def test_new_user(self, user_mock, external_data_mock):
        """OAuth2 callback creates a new user with proper external data"""
        user_mock.objects.get_or_create.return_value = sentinel.user, None
        self.authenticate_mock.side_effect = [None, sentinel.authed_user]

        user = self.form.get_authenticated_user()

        self.assertEquals(self.authenticate_mock.mock_calls,
                          [call(service=sentinel.service,
                                username=sentinel.id),
                           call(user=sentinel.user)])
        external_data_mock.objects.create.assert_called_once_with(
            service=sentinel.service, username=sentinel.id, user=sentinel.user)
        self.assertEquals(user, sentinel.authed_user)

    def test_existing_user(self):
        """OAuth2 recognizes existing user via external data credentials"""
        self.authenticate_mock.return_value = sentinel.authed_user

        user = self.form.get_authenticated_user()

        self.assertEquals(user, sentinel.authed_user)
        self.authenticate_mock.assert_called_once_with(
            service=sentinel.service, username=sentinel.id)

    def tearDown(self):
        patch.stopall()

class EmailChangeTestCase(TestCase):

    @patch('saleor.registration.views.now')
    @patch('saleor.registration.views.EmailChangeRequest.objects.get')
    def test_another_user_logged_out(self, get, now):

        # user requests email change
        user = Mock()
        token_object = Mock()
        token_object.token = 'sometokencontent'
        token_object.user = user
        get.return_value = token_object

        # another user is logged in
        another_user = Mock()
        request = Mock()
        request.user = another_user
        request.session = SessionMock()

        # first user clicks link in his email
        result = change_email(request, token_object.token)
        self.assertEquals(result.status_code, 302)
        get.assert_called_once_with(
            token=token_object.token, valid_until__gte=now())
        self.assertFalse(request.user.is_authenticated())
        token_object.delete.assert_not_called()

    @patch('saleor.registration.views.now')
    @patch('saleor.registration.views.EmailChangeRequest.objects.get')
    def test_user_logged_in(self, get, now):

        # user requests email change
        user = Mock()
        token_object = Mock()
        token_object.token = 'sometokencontent'
        token_object.user = user
        get.return_value = token_object

        # user is logged in
        request = MagicMock(HttpRequest)
        request._messages = Mock()
        request.user = user

        # user clicks link in his email
        result = change_email(request, token_object.token)
        self.assertEquals(result.status_code, 302)
        get.assert_called_once_with(
            token=token_object.token, valid_until__gte=now())
        # user stays logged in
        self.assertTrue(request.user.is_authenticated())
        # token is deleted
        token_object.delete.assert_called_once_with()
        user.save.assert_called_once_with()
        # user email gets changed
        self.assertEqual(user.email, token_object.email)

class OAuthClientTestCase(TestCase):
    def setUp(self):
        self.fake_client_id = 'test'
        self.fake_client_secret = 'testsecret'

    def test_google_secrets_override(self):
        client = GoogleClient(local_host='http://localhost',
                              client_id=self.fake_client_id,
                              client_secret=self.fake_client_secret)
        self.assertEqual(client.client_id, self.fake_client_id)
        self.assertEqual(client.client_secret, self.fake_client_secret)

    def test_google_secrets_fallback(self):
        client = GoogleClient(local_host='http://localhost')
        self.assertEqual(client.client_id, settings.GOOGLE_CLIENT_ID)
        self.assertEqual(client.client_secret, settings.GOOGLE_CLIENT_SECRET)

    def test_facebook_secrets_override(self):
        client = FacebookClient(local_host='http://localhost',
                                client_id=self.fake_client_id,
                                client_secret=self.fake_client_secret)
        self.assertEqual(client.client_id, self.fake_client_id)
        self.assertEqual(client.client_secret, self.fake_client_secret)

    def test_facebook_secrets_fallback(self):
        client = FacebookClient(local_host='http://localhost')
        self.assertEqual(client.client_id, settings.FACEBOOK_APP_ID)
        self.assertEqual(client.client_secret, settings.FACEBOOK_SECRET)


text:
module Api
  module V1
    class ConferencesController < Api::BaseController
      load_resource find_by: :short_title
      respond_to :json

      # Disable forgery protection for any json requests. This is required for jsonp support
      skip_before_action :verify_authenticity_token

      def index
        render json: @conferences, serializer: ConferencesArraySerializer, callback: params['callback']
      end

      def show
        render json: [@conference], serializer: ConferencesArraySerializer, callback: params['callback']
      end
    end
  end
end