text:
package commitlog

import (
	"time"

	"github.com/opentracing/opentracing-go"
	opentracinglog "github.com/opentracing/opentracing-go/log"
	"github.com/uber-go/tally"
	"go.uber.org/zap"

	"github.com/m3db/m3/src/dbnode/tracepoint"
	"github.com/m3db/m3/src/x/clock"
	"github.com/m3db/m3/src/x/context"
	"github.com/m3db/m3/src/x/instrument"
)

type instrumentationContext struct {
	opts                       Options
	nowFn                      clock.NowFn
	log                        *zap.Logger
	start                      time.Time
	span                       opentracing.Span
	bootstrapSnapshotsDuration tally.Timer
	bootstrapCommitLogDuration tally.Timer
	profiler                   instrument.Profiler
}

func newInstrumentationContext(
	opts Options,
	nowFn clock.NowFn,
	log *zap.Logger,
	span opentracing.Span,
	scope tally.Scope,
	profiler instrument.Profiler,
) *instrumentationContext {
	return &instrumentationContext{
		opts:                       opts,
		nowFn:                      nowFn,
		log:                        log,
		span:                       span,
		profiler:                   profiler,
		bootstrapSnapshotsDuration: scope.Timer("snapshots-duration"),
		bootstrapCommitLogDuration: scope.Timer("commitlog-duration"),
	}
}

const (
	snapshotsProfileName = "commitlog-snapshots"
	readProfileName      = "commitlog-read"
)

func (i *instrumentationContext) finish() {
	i.span.Finish()
}

func (i *instrumentationContext) startCPUProfile(name string) {
	err := i.profiler.StartCPUProfile(name)
	if err != nil {
		i.log.Error("unable to start cpu profile", zap.Error(err))
	}
}

func (i *instrumentationContext) stopCPUProfile() {
	if err := i.profiler.StopCPUProfile(); err != nil {
		i.log.Error("unable to stop cpu profile", zap.Error(err))
	}
}

func (i *instrumentationContext) writeHeapProfile(name string) {
	err := i.profiler.WriteHeapProfile(name)
	if err != nil {
		i.log.Error("unable to write heap profile", zap.Error(err))
	}
}

func (i *instrumentationContext) bootstrapSnapshotsStarted() {
	i.log.Info("read snapshots start")
	i.span.LogFields(opentracinglog.String("event", "read_snapshots_start"))
	i.start = i.nowFn()
	i.startCPUProfile(snapshotsProfileName)
	i.writeHeapProfile(snapshotsProfileName)
}

func (i *instrumentationContext) bootstrapSnapshotsCompleted() {
	duration := i.nowFn().Sub(i.start)
	i.bootstrapSnapshotsDuration.Record(duration)
	i.log.Info("read snapshots done", zap.Duration("took", duration))
	i.span.LogFields(opentracinglog.String("event", "read_snapshots_done"))
	i.stopCPUProfile()
	i.writeHeapProfile(snapshotsProfileName)
}

func (i *instrumentationContext) readCommitLogStarted() {
	i.log.Info("read commit log start")
	i.span.LogFields(opentracinglog.String("event", "read_commitlog_start"))
	i.start = i.nowFn()
	i.startCPUProfile(readProfileName)
	i.writeHeapProfile(readProfileName)
}

func (i *instrumentationContext) readCommitLogCompleted() {
	duration := i.nowFn().Sub(i.start)
	i.bootstrapCommitLogDuration.Record(duration)
	i.log.Info("read commit log done", zap.Duration("took", duration))
	i.span.LogFields(opentracinglog.String("event", "read_commitlog_done"))
	i.stopCPUProfile()
	i.writeHeapProfile(readProfileName)
}

type instrumentation struct {
	opts     Options
	profiler instrument.Profiler
	scope    tally.Scope
	log      *zap.Logger
	nowFn    clock.NowFn
}

func newInstrumentation(opts Options, scope tally.Scope, log *zap.Logger) *instrumentation {
	return &instrumentation{
		opts:     opts,
		profiler: opts.ResultOptions().InstrumentOptions().Profiler(),
		scope:    scope,
		log:      log,
		nowFn:    opts.ResultOptions().ClockOptions().NowFn(),
	}
}

func (i *instrumentation) commitLogBootstrapperSourceReadStarted(
	ctx context.Context,
) *instrumentationContext {
	_, span, _ := ctx.StartSampledTraceSpan(tracepoint.BootstrapperCommitLogSourceRead)
	return newInstrumentationContext(
		i.opts,
		i.nowFn,
		i.log,
		span,
		i.scope,
		i.profiler,
	)
}


text:
"""Main 'schevo' script runner."""

# Copyright (c) 2001-2009 ElevenCraft Inc.
# See LICENSE for details.

import pkg_resources

from schevo.script.command import CommandSet

# Get version information from installed package.
dist = pkg_resources.get_distribution('Schevo')
NAME = dist.project_name
VERSION = dist.version

class Main(CommandSet):

    name = '%s %s' % (NAME, VERSION)

    def __init__(self):
        commands = self.commands = {}
        for p in pkg_resources.iter_entry_points('schevo.schevo_command'):
            name = p.name
            command = p.load()
            commands[name] = command

start = Main()

def start_hotshot():
    import hotshot
    import hotshot.stats
    import os
    import schevo
    filename = 'schevo.prof'
    prof = hotshot.Profile(filename)
    prof.runcall(start)
    prof.close()
    stats = hotshot.stats.load(filename)
    # Print reports including all code, even dependencies.
    stats.sort_stats('cumulative', 'calls')
    stats.print_stats(50)
    stats.sort_stats('time', 'calls')
    stats.print_stats(50)
    # Print reports showing only Schevo code.
    stats.sort_stats('cumulative', 'calls')
    schevo_package_path = os.path.dirname(schevo.__file__)
    schevo_package_path = schevo_package_path.replace('\\', '\\\\')
    # Hotshot stores a lowercase form of the path so we need to
    # lowercase our path or the regular expression will fail.
    schevo_package_path = schevo_package_path.lower()
    stats.print_stats(schevo_package_path, 50)
    stats.sort_stats('time', 'calls')
    stats.print_stats(schevo_package_path, 50)

redpajama_set_name: RedPajamaGithub


text:
namespace Google.Cloud.Container.V1.Snippets
{
    // [START container_v1_generated_ClusterManager_UpdateCluster_sync_flattened2]
    using Google.Cloud.Container.V1;

    public sealed partial class GeneratedClusterManagerClientSnippets
    {
        /// <summary>Snippet for UpdateCluster</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public void UpdateCluster2()
        {
            // Create client
            ClusterManagerClient clusterManagerClient = ClusterManagerClient.Create();
            // Initialize request argument(s)
            string name = "";
            ClusterUpdate update = new ClusterUpdate();
            // Make the request
            Operation response = clusterManagerClient.UpdateCluster(name, update);
        }
    }
    // [END container_v1_generated_ClusterManager_UpdateCluster_sync_flattened2]
}


text:
package org.camunda.bpm.model.cmmn.instance.camunda;

import org.camunda.bpm.model.cmmn.instance.CmmnModelElementInstance;

/**
 * @author Roman Smirnov
 *
 */
public interface CamundaString extends CmmnModelElementInstance {
}


text:
Roboto 2.0

            The standard font Material Design uses is Roboto. We have included the font files with our framework.

We bundle our framework with the latest iteration of Roboto Google has released. It comes with 5 different font weights you can use: 100, 300, 400, 500, 600.

 Here is an image from Google's Roboto Specimen document displaying the different font weights.

Removing Roboto

In case you don't want to use Roboto on your webpage, fear not. Simply change the font stack by modifying the code below to your liking and add it to your custom css.

  html {
    font-family: GillSans, Calibri, Trebuchet, sans-serif;
  }

Headers

We provide some basic styling on header tags. In the example, you can see the the 6 header tags' different sizes.

Heading h1

Heading h2

Heading h3

Heading h4

Heading h5

Heading h6

Blockquotes

            Blockquotes are mainly used to give emphasis to a quote or citation. You can also use these for some extra text hierarchy and emphasis.

            This is an example quotation that uses the blockquote tag.

Here is another line to make it look bigger.

    <blockquote>
      This is an example quotation that uses the blockquote tag.
    </blockquote>

Flow Text

          Toggle flow-text

          One common flaw we've seen in many frameworks is a lack of support for truly responsive text. While elements on the page resize fluidly, text still resizes on a fixed basis. To ameliorate this problem, for text heavy pages, we've created a class that fluidly scales text size and line-height to optimize readability for the user. Line length stays between 45-80 characters and line height scales to be larger on smaller screens.

To see Flow Text in action, slowly resize your browser and watch the size of this text body change! Use the button above to toggle off/on flow-text to see the difference!

To use flow-text on a body of text, simply just add the class flow-text to a tag, see the code below.

    <p class="flow-text">I am Flow Text</p>

Roboto

Headers

Blockquotes

Flow Text


text:
<?php get_header(); ?>

    <?php
        // Global variables for the post page
        $currentPostTitle = get_the_title();
        $featuredImage = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
    ?>

            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

                    <?php edit_post_link(); // Always handy to have Edit Post Links available ?>

                <?php
                    $category = get_the_category();
                    $category_id = get_cat_ID( $category[0]->cat_name );
                    $category_link = get_category_link( $category_id );
                ?>

                                <div class="SongAvatar" style="background-image:url(<?php echo $featuredImage; ?>);">

                                <a href="<?php echo $category_link; ?>"> Electro House
                                <?php echo $category[0]->cat_name; ?>

                                    <?php the_title(); ?>

                                Publish 3 days ago

                                        Play song

                                        Pause song

                                        Continues playing

Share

                                <?php the_tags('',' ',''); ?>

                            <?php if($post->post_content != ""): ?>

                                <?php the_content(); ?>

                            <?php endif; ?>

                                <?php comments_template(); ?>

                            <? endwhile; endif; ?>

                <?php $currentSongTitle = get_the_title(); ?>

                <?php if(get_field('soundcloudURL')): ?>
                   <li class= 'playlistItem' data-type='soundcloud' data-path='<?php the_field('soundcloudURL'); ?>' data-thumb='<?php echo $playlistImage; ?>'>

                <?php endif; ?>

                <?php query_posts(array('orderby' => 'rand', 'showposts' => 0 ));
                    if (have_posts()) : while (have_posts()) : the_post(); ?>

                    <?php $newSongTitle = get_the_title(); ?>
                    <?php if($newSongTitle != $currentSongTitle) : ?>
                        <?php if(get_field('soundcloudURL')): ?>
                            <li class= 'playlistItem' data-type='soundcloud' data-path='<?php the_field('soundcloudURL'); ?>' data-thumb='<?php echo $playlistImage; ?>'>

                        <?php endif; ?>
                    <?php endif; ?>
                <? endwhile; endif; ?>

            Related tracks

                <?
                query_posts(array('orderby' => 'rand', 'showposts' => 10 ));
                if (have_posts()) : while (have_posts()) : the_post();
                ?>

                    <?
                    $newName = get_the_title();
                    if ($newName != $currentPostTitle) :
                    ?>

                        <?php $featuredImage = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
                        <div class="SingleRelatedCover" style="background-image:url(<?php echo $featuredImage; ?>);">

<a href="<?php the_permalink();?>#"><?php the_title(); ?>

                            <?
                                $category = get_the_category();
                                $category_id = get_cat_ID( $category[0]->cat_name );
                                $category_link = get_category_link( $category_id );
                            ?>

<a href="<?php echo $category_link; ?>">
                                <?php echo $category[0]->cat_name; ?>

                    <?php endif; ?>

                <? endwhile; endif; ?>

<?php get_footer(); ?>


text:
/* jshint node: true */
'use strict';

module.exports = {
  name: 'number-input'
};


text:
@implementation DIOSComment

+ (void) getCommentWithID:(NSString*)eid
                  success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
                  failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
    [DIOSEntity getEntityWithName:@"comment" andID:eid success:success failure:failure];
}

+ (void) createCommentWithParams:(NSDictionary*)params
                      relationID:(NSString*)relationID
                            type:(NSString*)type
                         success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
                         failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {

    NSMutableDictionary *dict = [NSMutableDictionary new];
    NSString *href = [NSString stringWithFormat:@"%@/rest/type/%@/%@", [[[DIOSSession sharedSession] baseURL] absoluteString], @"comment", type];
// This is for older beta releases
//    NSString *relationKey = [NSString stringWithFormat:@"%@/rest/relation/comment/comment/entity_id", [[[DIOSSession sharedSession] baseURL] absoluteString]];
//
//    NSString *relationValue = [NSString stringWithFormat:@"%@/node/%@",[[[DIOSSession sharedSession] baseURL] absoluteString],relationID];

    NSString *relationKey = [NSString stringWithFormat:@"%@/relation/comment/comment/entity_id", [[[DIOSSession sharedSession] baseURL] absoluteString]];

    NSString *relationValue = [NSString stringWithFormat:@"%@/rest/type/%@/%@/node/%@",[[[DIOSSession sharedSession] baseURL] absoluteString],@"comment",type,relationID];

    NSDictionary *defaultDict = @{@"_links" : @{@"type" : @{@"href" : href}, relationKey:@[@{@"href" :relationValue}]}, @"entity_id":@[@{@"target_id":relationID,@"revision_id":@""}]};
    [dict addEntriesFromDictionary:defaultDict];
    [dict addEntriesFromDictionary:params];
    NSString *path = [NSString stringWithFormat:@"entity/comment"];
    [[DIOSSession sharedSession] sendRequestWithPath:path method:@"POST" params:dict success:success failure:failure];

}

+ (void) deleteCommentWithID:(NSString*)eid
                     success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
                     failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
    [DIOSEntity deleteEntityWithEntityName:@"comment" andID:eid success:success failure:failure];
}

+ (void) patchCommentWithID:(NSString*)eid
                  andParams:(NSDictionary *)params
                    success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
                    failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
    [DIOSEntity patchEntityWithEntityName:@"comment" type:@"comment" eid:eid andParams:params success:nil failure:nil];
}
@end


text:
import {Injectable} from '@angular/core';
import {Response} from '@angular/http';
import 'rxjs/add/operator/toPromise';
import {BaseHttpService} from "./base.http.service";

/**
 * This class provides the Products service with methods to manage entities.
 */
@Injectable()
export abstract class CrudService extends BaseHttpService {
    protected _baseModel: {new: () => any, [propName: string]: any};

    /**
     *
     * @returns {Promise<void>|Promise<T>|Promise<R>|MongoosePromise<void>}
     */
    list(filters?: any, relations?: String[]): Promise<any[]> {
        return this.get(
            this.baseUrl + 'list',
            {search : relations ? Object.assign(filters, {'with[]': relations}) : filters}
        )
            .then((res: Response) => {
                //noinspection TypeScriptUnresolvedFunction
                return this._baseModel ? res.json().map(r => Object.assign(new this._baseModel, r)) : res.json()
            })
            .catch(this.handleError);
    }

    save(obj: any): Promise<boolean> {
        return this.post(this.baseUrl, this.stripRelations(obj))
            .then((res: Response) => {
                return res.json();
            })
            .catch(this.handleError);
    }

    remove(id: any): Promise<boolean> {
        return this.delete(this.baseUrl, {body: {id: id}})
            .then((res) => res.json())
            .catch(this.handleError);
    }

    /**
     *  Strip related objects fields to avoid cascade update & reduce request size
     *
     * @param obj
     * @returns {{}}
     */
    protected stripRelations(obj: any)
    {
        let res = {};
        if (!obj) return {};

        for(let prop of Object.getOwnPropertyNames(obj)) {
            switch (typeof obj[prop]) {
                case 'function':
                    break;
                case 'object':
                    if(!obj[prop]) {
                        res = Object.assign(res, {
                            [prop ]: null
                        });
                        break;
                    }

                    if(obj[prop].constructor.name == 'Array') {
                        res = Object.assign(res, {
                            [prop]: obj[prop]
                        });

                    } else if (obj[prop] && obj[prop]._id) {
                        res = Object.assign(res, {
                            [prop ]: obj[prop]._id
                        });
                    }
                    break;
                default:
                    res = Object.assign(res, {
                        [prop]: obj[prop]
                    });
                    break;
            }
        }
console.log("prePost strip:", res);
        return res;
    }
}


text:
<!DOCTYPE html>

  <title>The page you were looking for requires authentication (403)</title>

The page you were looking for requires authentication.

Please login to view this resource.


text:
<?php
namespace Rooty\TorrentBundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\FixtureInterface;
use Rooty\TorrentBundle\Entity\MovieTranslation;
use Doctrine\Common\Persistence\ObjectManager;

class LoadMovieTranslationData implements FixtureInterface
{
    public function load(ObjectManager $manager)
    {
        $entity = new MovieTranslation();
        $entity->setTitle('Оригинал');
        $manager->persist($entity);

        $entity = new MovieTranslation();
        $entity->setTitle('Любительский (один голос)');
        $manager->persist($entity);

        $entity = new MovieTranslation();
        $entity->setTitle('Любительский (многоголосный)');
        $manager->persist($entity);

        $entity = new MovieTranslation();
        $entity->setTitle('Профессиональный (многоголосный)');
        $manager->persist($entity);

        $entity = new MovieTranslation();
        $entity->setTitle('Гоблин');
        $manager->persist($entity);

        $entity = new MovieTranslation();
        $entity->setTitle('Дублированный');
        $manager->persist($entity);

        $entity = new MovieTranslation();
        $entity->setTitle('Субтитры');
        $manager->persist($entity);

        $manager->flush();
    }
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace DesignScript.Editor.Core.UnitTest
{
    using DesignScript.Parser;
    using System.IO;

    class NodeProcessorImperativeTest
    {
        NodeProcessor nodeProcessor = null;
        List<Node> nodeList = null;
        CodeFragment[] fragmentArray = null;
        DesignScript.Parser.Parser parser;
        ProtoCore.Core core;

        [SetUp]
        public void Setup()
        {
            nodeList = new List<Node>();
            core = new ProtoCore.Core(new ProtoCore.Options());
        }

        public Stream ConvertToStream(string textContent)
        {
            char[] charArray = textContent.ToCharArray();
            List<char> textStream = new List<char>();
            MemoryStream stream;

            foreach(char character in charArray)
            {
                textStream.Add(character);
            }

            return stream = new MemoryStream(System.Text.Encoding.Default.GetBytes(new string(textStream.ToArray())));
        }

        [Test]
        public void TestImperativeBinaryExpressionNode()
        {
            string content = "[Imperative]x = 0;";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.IsTrue(fragmentArray.Length == 7);

            Assert.AreEqual(fragmentArray[0].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[0].Text, "[");
            Assert.AreEqual(fragmentArray[0].Line, 0);
            Assert.AreEqual(fragmentArray[0].ColStart, 0);
            Assert.AreEqual(fragmentArray[0].ColEnd, 0);

            Assert.AreEqual(fragmentArray[1].CodeType, CodeFragment.Type.Keyword);
            Assert.AreEqual(fragmentArray[1].Text, "Imperative");
            Assert.AreEqual(fragmentArray[1].Line, 0);
            Assert.AreEqual(fragmentArray[1].ColStart, 1);
            Assert.AreEqual(fragmentArray[1].ColEnd, 10);

            Assert.AreEqual(fragmentArray[2].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[2].Text, "]");
            Assert.AreEqual(fragmentArray[2].Line, 0);
            Assert.AreEqual(fragmentArray[2].ColStart, 11);
            Assert.AreEqual(fragmentArray[2].ColEnd, 11);

            Assert.AreEqual(fragmentArray[3].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[3].Text, ";");
            Assert.AreEqual(fragmentArray[3].Line, 0);
            Assert.AreEqual(fragmentArray[3].ColStart, 17);
            Assert.AreEqual(fragmentArray[3].ColEnd, 17);

            Assert.AreEqual(fragmentArray[4].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[4].Text, "=");
            Assert.AreEqual(fragmentArray[4].Line, 0);
            Assert.AreEqual(fragmentArray[4].ColStart, 14);
            Assert.AreEqual(fragmentArray[4].ColEnd, 14);

            Assert.AreEqual(fragmentArray[5].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[5].Text, "x");
            Assert.AreEqual(fragmentArray[5].Line, 0);
            Assert.AreEqual(fragmentArray[5].ColStart, 12);
            Assert.AreEqual(fragmentArray[5].ColEnd, 12);

            Assert.AreEqual(fragmentArray[6].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[6].Text, "0");
            Assert.AreEqual(fragmentArray[6].Line, 0);
            Assert.AreEqual(fragmentArray[6].ColStart, 16);
            Assert.AreEqual(fragmentArray[6].ColEnd, 16);
        }

        [Test]
        public void TestImperativeIntNode()
        {
            string content = "[Imperative] x = -2;";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.IsTrue(fragmentArray.Length == 8);

            Assert.AreEqual(fragmentArray[6].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[6].Text, "-");
            Assert.AreEqual(fragmentArray[6].Line, 0);
            Assert.AreEqual(fragmentArray[6].ColStart, 17);
            Assert.AreEqual(fragmentArray[6].ColEnd, 17);

            Assert.AreEqual(fragmentArray[7].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[7].Text, "2");
            Assert.AreEqual(fragmentArray[7].Line, 0);
            Assert.AreEqual(fragmentArray[7].ColStart, 18);
            Assert.AreEqual(fragmentArray[7].ColEnd, 18);

        }

        [Test]
        public void TestImperativeDoubleNode()
        {
            string content = "[Imperative] x = 2.1;";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.IsTrue(fragmentArray.Length == 7);

            Assert.AreEqual(fragmentArray[6].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[6].Text, "2.1");
            Assert.AreEqual(fragmentArray[6].Line, 0);
            Assert.AreEqual(fragmentArray[6].ColStart, 17);
            Assert.AreEqual(fragmentArray[6].ColEnd, 19);
        }

        [Test]
        public void TestImperativeBooleanNode()
        {
            string content = "[Imperative] x = true;";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.IsTrue(fragmentArray.Length == 7);

            Assert.AreEqual(fragmentArray[6].CodeType, CodeFragment.Type.Keyword);
            Assert.AreEqual(fragmentArray[6].Text, "true");
            Assert.AreEqual(fragmentArray[6].Line, 0);
            Assert.AreEqual(fragmentArray[6].ColStart, 17);
            Assert.AreEqual(fragmentArray[6].ColEnd, 20);

        }

        [Test]
        public void TestImperativeCharacterNode()
        {
            string content = "[Imperative] x = a;";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.IsTrue(fragmentArray.Length == 7);
            //Should be text not local
            Assert.AreEqual(fragmentArray[6].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[6].Text, "a");
            Assert.AreEqual(fragmentArray[6].Line, 0);
            Assert.AreEqual(fragmentArray[6].ColStart, 17);
            Assert.AreEqual(fragmentArray[6].ColEnd, 17);

        }

        [Test]
        public void TestImperativeStringNode()
        {
            string content = "[Imperative] x = test;";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length, 7);
            //Why local again should be text!
            Assert.AreEqual(fragmentArray[6].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[6].Text, "test");
            Assert.AreEqual(fragmentArray[6].Line, 0);
            Assert.AreEqual(fragmentArray[6].ColStart, 17);
            Assert.AreEqual(fragmentArray[6].ColEnd, 20);

        }

        [Test]
        public void TestImperativeArrayNode()
        {
            //list[1]
            string content = "[Imperative] list[1] = 0;";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length , 10);

            Assert.AreEqual(fragmentArray[5].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[5].Text, "[");
            Assert.AreEqual(fragmentArray[5].Line, 0);
            Assert.AreEqual(fragmentArray[5].ColStart, 17);
            Assert.AreEqual(fragmentArray[5].ColEnd, 17);

            Assert.AreEqual(fragmentArray[6].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[6].Text, "]");
            Assert.AreEqual(fragmentArray[6].Line, 0);
            Assert.AreEqual(fragmentArray[6].ColStart, 19);
            Assert.AreEqual(fragmentArray[6].ColEnd, 19);

            Assert.AreEqual(fragmentArray[7].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[7].Text, "list");
            Assert.AreEqual(fragmentArray[7].Line, 0);
            Assert.AreEqual(fragmentArray[7].ColStart, 13);
            Assert.AreEqual(fragmentArray[7].ColEnd, 16);

            Assert.AreEqual(fragmentArray[8].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[8].Text, "1");
            Assert.AreEqual(fragmentArray[8].Line, 0);
            Assert.AreEqual(fragmentArray[8].ColStart, 18);
            Assert.AreEqual(fragmentArray[8].ColEnd, 18);

        }

        [Test]
        public void TestImperativeTextNode()
        {
            //[Imperative]
            //{
            //  a = 'x';
            //  b = "This is an Imperative Block";
            //}
            string content = "[Imperative]{ a = 'x'; b = \"This is an Imperative Block\"; }";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length, 13);

            Assert.AreEqual(fragmentArray[8].CodeType, CodeFragment.Type.Text);
            Assert.AreEqual(fragmentArray[8].Text, "'x'");
            Assert.AreEqual(fragmentArray[8].Line, 0);
            Assert.AreEqual(fragmentArray[8].ColStart, 18);
            Assert.AreEqual(fragmentArray[8].ColEnd, 20);

            Assert.AreEqual(fragmentArray[12].CodeType, CodeFragment.Type.Text);
            Assert.AreEqual(fragmentArray[12].Text, "\"This is an Imperative Block\"");
            Assert.AreEqual(fragmentArray[12].Line, 0);
            Assert.AreEqual(fragmentArray[12].ColStart, 27);
            Assert.AreEqual(fragmentArray[12].ColEnd, 55);
        }

        [Test]
        public void TestImperativeExpressionListNode()
        {
            //somelist[] = {11,102,1003,1004};
            string content = "[Imperative] somelist[] = {11,102,1003,1004};";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length, 17);

            Assert.AreEqual(fragmentArray[8].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[8].Text, "{");
            Assert.AreEqual(fragmentArray[8].Line, 0);
            Assert.AreEqual(fragmentArray[8].ColStart, 26);
            Assert.AreEqual(fragmentArray[8].ColEnd, 26);

            Assert.AreEqual(fragmentArray[9].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[9].Text, "11");
            Assert.AreEqual(fragmentArray[9].Line, 0);
            Assert.AreEqual(fragmentArray[9].ColStart, 27);
            Assert.AreEqual(fragmentArray[9].ColEnd, 28);

            Assert.AreEqual(fragmentArray[10].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[10].Text, "102");
            Assert.AreEqual(fragmentArray[10].Line, 0);
            Assert.AreEqual(fragmentArray[10].ColStart, 30);
            Assert.AreEqual(fragmentArray[10].ColEnd, 32);

            Assert.AreEqual(fragmentArray[11].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[11].Text, "1003");
            Assert.AreEqual(fragmentArray[11].Line, 0);
            Assert.AreEqual(fragmentArray[11].ColStart, 34);
            Assert.AreEqual(fragmentArray[11].ColEnd, 37);

            Assert.AreEqual(fragmentArray[12].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[12].Text, "1004");
            Assert.AreEqual(fragmentArray[12].Line, 0);
            Assert.AreEqual(fragmentArray[12].ColStart, 39);
            Assert.AreEqual(fragmentArray[12].ColEnd, 42);

            Assert.AreEqual(fragmentArray[13].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[13].Text, ",");
            Assert.AreEqual(fragmentArray[13].Line, 0);
            Assert.AreEqual(fragmentArray[13].ColStart, 29);
            Assert.AreEqual(fragmentArray[13].ColEnd, 29);

            Assert.AreEqual(fragmentArray[14].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[14].Text, ",");
            Assert.AreEqual(fragmentArray[14].Line, 0);
            Assert.AreEqual(fragmentArray[14].ColStart, 33);
            Assert.AreEqual(fragmentArray[14].ColEnd, 33);

            Assert.AreEqual(fragmentArray[15].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[15].Text, ",");
            Assert.AreEqual(fragmentArray[15].Line, 0);
            Assert.AreEqual(fragmentArray[15].ColStart, 38);
            Assert.AreEqual(fragmentArray[15].ColEnd, 38);

            Assert.AreEqual(fragmentArray[16].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[16].Text, "}");
            Assert.AreEqual(fragmentArray[16].Line, 0);
            Assert.AreEqual(fragmentArray[16].ColStart, 43);
            Assert.AreEqual(fragmentArray[16].ColEnd, 43);
        }

        [Test]
        public void TestImperativeRangeExpNode()
        {
            //a = 1..100..#1;
            string content = "[Imperative] a = 1..100..#1;";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length, 12);

            Assert.AreEqual(fragmentArray[6].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[6].Text, "1");
            Assert.AreEqual(fragmentArray[6].Line, 0);
            Assert.AreEqual(fragmentArray[6].ColStart, 17);
            Assert.AreEqual(fragmentArray[6].ColEnd, 17);

            Assert.AreEqual(fragmentArray[7].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[7].Text, "100");
            Assert.AreEqual(fragmentArray[7].Line, 0);
            Assert.AreEqual(fragmentArray[7].ColStart, 20);
            Assert.AreEqual(fragmentArray[7].ColEnd, 22);

            Assert.AreEqual(fragmentArray[8].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[8].Text, "1");
            Assert.AreEqual(fragmentArray[8].Line, 0);
            Assert.AreEqual(fragmentArray[8].ColStart, 26);
            Assert.AreEqual(fragmentArray[8].ColEnd, 26);

            Assert.AreEqual(fragmentArray[9].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[9].Text, "..");
            Assert.AreEqual(fragmentArray[9].Line, 0);
            Assert.AreEqual(fragmentArray[9].ColStart, 18);
            Assert.AreEqual(fragmentArray[9].ColEnd, 19);

            Assert.AreEqual(fragmentArray[10].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[10].Text, "..");
            Assert.AreEqual(fragmentArray[10].Line, 0);
            Assert.AreEqual(fragmentArray[10].ColStart, 23);
            Assert.AreEqual(fragmentArray[10].ColEnd, 24);

            Assert.AreEqual(fragmentArray[11].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[11].Text, "#");
            Assert.AreEqual(fragmentArray[11].Line, 0);
            Assert.AreEqual(fragmentArray[11].ColStart, 25);
            Assert.AreEqual(fragmentArray[11].ColEnd, 25);
        }

        [Test]
        public void TestImperativeIdentifierNode()
        {
            //a;
            string content = "[Imperative] a";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length, 4);

            Assert.AreEqual(fragmentArray[3].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[3].Text, "a");
            Assert.AreEqual(fragmentArray[3].Line, 0);
            Assert.AreEqual(fragmentArray[3].ColStart, 13);
            Assert.AreEqual(fragmentArray[3].ColEnd, 13);

        }

        [Test]
        public void TestImperativeFunctionCallNode()
        {
            string content = "[Imperative] aVar = func(a, b, c);" ;
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length, 14);

            Assert.AreEqual(fragmentArray[6].CodeType, CodeFragment.Type.Function);
            Assert.AreEqual(fragmentArray[6].Text, "func");
            Assert.AreEqual(fragmentArray[6].Line, 0);
            Assert.AreEqual(fragmentArray[6].ColStart, 20);
            Assert.AreEqual(fragmentArray[6].ColEnd, 23);

            Assert.AreEqual(fragmentArray[7].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[7].Text, "(");
            Assert.AreEqual(fragmentArray[7].Line, 0);
            Assert.AreEqual(fragmentArray[7].ColStart, 24);
            Assert.AreEqual(fragmentArray[7].ColEnd, 24);

            Assert.AreEqual(fragmentArray[8].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[8].Text, "a");
            Assert.AreEqual(fragmentArray[8].Line, 0);
            Assert.AreEqual(fragmentArray[8].ColStart, 25);
            Assert.AreEqual(fragmentArray[8].ColEnd, 25);

            Assert.AreEqual(fragmentArray[9].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[9].Text, "b");
            Assert.AreEqual(fragmentArray[9].Line, 0);
            Assert.AreEqual(fragmentArray[9].ColStart, 28);
            Assert.AreEqual(fragmentArray[9].ColEnd, 28);

            Assert.AreEqual(fragmentArray[10].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[10].Text, "c");
            Assert.AreEqual(fragmentArray[10].Line, 0);
            Assert.AreEqual(fragmentArray[10].ColStart, 31);
            Assert.AreEqual(fragmentArray[10].ColEnd, 31);
        }

        [Test]
        public void TestImperativeFunctionDefinitionNode()
        {
            //def func : int (a : int, b : double, c : int){result = a + b * c;}
            string content = "[Imperative] def func : int (a : int, b : double, c : int){result = a + b * c;}";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length, 30);

            Assert.AreEqual(fragmentArray[3].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[3].Text, "{");
            Assert.AreEqual(fragmentArray[3].Line, 0);
            Assert.AreEqual(fragmentArray[3].ColStart, 58);
            Assert.AreEqual(fragmentArray[3].ColEnd, 58);

            Assert.AreEqual(fragmentArray[4].CodeType, CodeFragment.Type.Keyword);
            Assert.AreEqual(fragmentArray[4].Text, "def");
            Assert.AreEqual(fragmentArray[4].Line, 0);
            Assert.AreEqual(fragmentArray[4].ColStart, 13);// Expected 15 check!! It is 13
            Assert.AreEqual(fragmentArray[4].ColEnd, 15);

            Assert.AreEqual(fragmentArray[5].CodeType, CodeFragment.Type.Function);
            Assert.AreEqual(fragmentArray[5].Text, "func");
            Assert.AreEqual(fragmentArray[5].Line, 0);
            Assert.AreEqual(fragmentArray[5].ColStart, 17);
            Assert.AreEqual(fragmentArray[5].ColEnd, 20);

            Assert.AreEqual(fragmentArray[6].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[6].Text, "(");
            Assert.AreEqual(fragmentArray[6].Line, 0);
            Assert.AreEqual(fragmentArray[6].ColStart, 28);
            Assert.AreEqual(fragmentArray[6].ColEnd, 28);

            Assert.AreEqual(fragmentArray[7].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[7].Text, ":");
            Assert.AreEqual(fragmentArray[7].Line, 0);
            Assert.AreEqual(fragmentArray[7].ColStart, 22);
            Assert.AreEqual(fragmentArray[7].ColEnd, 22);

            Assert.AreEqual(fragmentArray[8].CodeType, CodeFragment.Type.Keyword);
            Assert.AreEqual(fragmentArray[8].Text, "int");
            Assert.AreEqual(fragmentArray[8].Line, 0);
            Assert.AreEqual(fragmentArray[8].ColStart, 24);
            Assert.AreEqual(fragmentArray[8].ColEnd, 26);

            Assert.AreEqual(fragmentArray[9].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[9].Text, "}");
            Assert.AreEqual(fragmentArray[9].Line, 0);
            Assert.AreEqual(fragmentArray[9].ColStart, 78);
            Assert.AreEqual(fragmentArray[9].ColEnd, 78);

            Assert.AreEqual(fragmentArray[10].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[10].Text, ")");
            Assert.AreEqual(fragmentArray[10].Line, 0);
            Assert.AreEqual(fragmentArray[10].ColStart, 57);
            Assert.AreEqual(fragmentArray[10].ColEnd, 57);

            Assert.AreEqual(fragmentArray[11].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[11].Text, ",");
            Assert.AreEqual(fragmentArray[11].Line, 0);
            Assert.AreEqual(fragmentArray[11].ColStart, 36);
            Assert.AreEqual(fragmentArray[11].ColEnd, 36);

            Assert.AreEqual(fragmentArray[12].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[12].Text, ",");
            Assert.AreEqual(fragmentArray[12].Line, 0);
            Assert.AreEqual(fragmentArray[12].ColStart, 48);
            Assert.AreEqual(fragmentArray[12].ColEnd, 48);

            Assert.AreEqual(fragmentArray[13].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[13].Text, ";");
            Assert.AreEqual(fragmentArray[13].Line, 0);
            Assert.AreEqual(fragmentArray[13].ColStart, 77);
            Assert.AreEqual(fragmentArray[13].ColEnd, 77);

            Assert.AreEqual(fragmentArray[14].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[14].Text, "=");
            Assert.AreEqual(fragmentArray[14].Line, 0);
            Assert.AreEqual(fragmentArray[14].ColStart, 66);
            Assert.AreEqual(fragmentArray[14].ColEnd, 66);

            Assert.AreEqual(fragmentArray[15].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[15].Text, "result");
            Assert.AreEqual(fragmentArray[15].Line, 0);
            Assert.AreEqual(fragmentArray[15].ColStart, 59);//Another one should be 64!!
            Assert.AreEqual(fragmentArray[15].ColEnd, 64);

            Assert.AreEqual(fragmentArray[16].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[16].Text, "+");
            Assert.AreEqual(fragmentArray[16].Line, 0);
            Assert.AreEqual(fragmentArray[16].ColStart, 70);
            Assert.AreEqual(fragmentArray[16].ColEnd, 70);

            Assert.AreEqual(fragmentArray[17].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[17].Text, "a");
            Assert.AreEqual(fragmentArray[17].Line, 0);
            Assert.AreEqual(fragmentArray[17].ColStart, 68);
            Assert.AreEqual(fragmentArray[17].ColEnd, 68);

            Assert.AreEqual(fragmentArray[18].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[18].Text, "*");
            Assert.AreEqual(fragmentArray[18].Line, 0);
            Assert.AreEqual(fragmentArray[18].ColStart, 74);
            Assert.AreEqual(fragmentArray[18].ColEnd, 74);

            Assert.AreEqual(fragmentArray[19].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[19].Text, "b");
            Assert.AreEqual(fragmentArray[19].Line, 0);
            Assert.AreEqual(fragmentArray[19].ColStart, 72);
            Assert.AreEqual(fragmentArray[19].ColEnd, 72);

            Assert.AreEqual(fragmentArray[20].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[20].Text, "c");
            Assert.AreEqual(fragmentArray[20].Line, 0);
            Assert.AreEqual(fragmentArray[20].ColStart, 76);
            Assert.AreEqual(fragmentArray[20].ColEnd, 76);

            Assert.AreEqual(fragmentArray[23].CodeType, CodeFragment.Type.Keyword);
            Assert.AreEqual(fragmentArray[23].Text, "int");
            Assert.AreEqual(fragmentArray[23].Line, 0);
            Assert.AreEqual(fragmentArray[23].ColStart, 33);
            Assert.AreEqual(fragmentArray[23].ColEnd, 35);

            Assert.AreEqual(fragmentArray[22].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[22].Text, ":");
            Assert.AreEqual(fragmentArray[22].Line, 0);
            Assert.AreEqual(fragmentArray[22].ColStart, 31);
            Assert.AreEqual(fragmentArray[22].ColEnd, 31);

            Assert.AreEqual(fragmentArray[21].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[21].Text, "a");
            Assert.AreEqual(fragmentArray[21].Line, 0);
            Assert.AreEqual(fragmentArray[21].ColStart, 29);
            Assert.AreEqual(fragmentArray[21].ColEnd, 29);

            Assert.AreEqual(fragmentArray[26].CodeType, CodeFragment.Type.Keyword);
            Assert.AreEqual(fragmentArray[26].Text, "double");
            Assert.AreEqual(fragmentArray[26].Line, 0);
            Assert.AreEqual(fragmentArray[26].ColStart, 42);
            Assert.AreEqual(fragmentArray[26].ColEnd, 47);

            Assert.AreEqual(fragmentArray[25].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[25].Text, ":");
            Assert.AreEqual(fragmentArray[25].Line, 0);
            Assert.AreEqual(fragmentArray[25].ColStart, 40);
            Assert.AreEqual(fragmentArray[25].ColEnd, 40);

            Assert.AreEqual(fragmentArray[24].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[24].Text, "b");
            Assert.AreEqual(fragmentArray[24].Line, 0);
            Assert.AreEqual(fragmentArray[24].ColStart, 38);
            Assert.AreEqual(fragmentArray[24].ColEnd, 38);

            Assert.AreEqual(fragmentArray[29].CodeType, CodeFragment.Type.Keyword);
            Assert.AreEqual(fragmentArray[29].Text, "int");
            Assert.AreEqual(fragmentArray[29].Line, 0);
            Assert.AreEqual(fragmentArray[29].ColStart, 54);
            Assert.AreEqual(fragmentArray[29].ColEnd, 56);

            Assert.AreEqual(fragmentArray[28].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[28].Text, ":");
            Assert.AreEqual(fragmentArray[28].Line, 0);
            Assert.AreEqual(fragmentArray[28].ColStart, 52);
            Assert.AreEqual(fragmentArray[28].ColEnd, 52);

            Assert.AreEqual(fragmentArray[27].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[27].Text, "c");
            Assert.AreEqual(fragmentArray[27].Line, 0);
            Assert.AreEqual(fragmentArray[27].ColStart, 50);
            Assert.AreEqual(fragmentArray[27].ColEnd, 50);

        }

        [Test]
        public void TestImperativeIfElseNode()
        {
            string content = "[Imperative] if ( a == b){a = 0;} else{a = a + b;}";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length, 24);

            Assert.AreEqual(fragmentArray[3].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[3].Text, "==");
            Assert.AreEqual(fragmentArray[3].Line, 0);
            Assert.AreEqual(fragmentArray[3].ColStart, 20);
            Assert.AreEqual(fragmentArray[3].ColEnd, 21);

            Assert.AreEqual(fragmentArray[4].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[4].Text, "a");
            Assert.AreEqual(fragmentArray[4].Line, 0);
            Assert.AreEqual(fragmentArray[4].ColStart, 18);
            Assert.AreEqual(fragmentArray[4].ColEnd, 18);

            Assert.AreEqual(fragmentArray[5].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[5].Text, "b");
            Assert.AreEqual(fragmentArray[5].Line, 0);
            Assert.AreEqual(fragmentArray[5].ColStart, 23);
            Assert.AreEqual(fragmentArray[5].ColEnd, 23);

            Assert.AreEqual(fragmentArray[6].CodeType, CodeFragment.Type.Keyword);
            Assert.AreEqual(fragmentArray[6].Text, "if");
            Assert.AreEqual(fragmentArray[6].Line, 0);
            Assert.AreEqual(fragmentArray[6].ColStart, 13);
            Assert.AreEqual(fragmentArray[6].ColEnd, 14);

            Assert.AreEqual(fragmentArray[7].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[7].Text, "{");
            Assert.AreEqual(fragmentArray[7].Line, 0);
            Assert.AreEqual(fragmentArray[7].ColStart, 25);
            Assert.AreEqual(fragmentArray[7].ColEnd, 25);

            Assert.AreEqual(fragmentArray[8].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[8].Text, "(");
            Assert.AreEqual(fragmentArray[8].Line, 0);
            Assert.AreEqual(fragmentArray[8].ColStart, 16);
            Assert.AreEqual(fragmentArray[8].ColEnd, 16);

            Assert.AreEqual(fragmentArray[9].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[9].Text, ")");
            Assert.AreEqual(fragmentArray[9].Line, 0);
            Assert.AreEqual(fragmentArray[9].ColStart, 24);
            Assert.AreEqual(fragmentArray[9].ColEnd, 24);

            Assert.AreEqual(fragmentArray[10].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[10].Text, "}");
            Assert.AreEqual(fragmentArray[10].Line, 0);
            Assert.AreEqual(fragmentArray[10].ColStart, 32);
            Assert.AreEqual(fragmentArray[10].ColEnd, 32);

            Assert.AreEqual(fragmentArray[11].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[11].Text, "{");
            Assert.AreEqual(fragmentArray[11].Line, 0);
            Assert.AreEqual(fragmentArray[11].ColStart, 38);
            Assert.AreEqual(fragmentArray[11].ColEnd, 38);

            Assert.AreEqual(fragmentArray[12].CodeType, CodeFragment.Type.Keyword);
            Assert.AreEqual(fragmentArray[12].Text, "else");
            Assert.AreEqual(fragmentArray[12].Line, 0);
            Assert.AreEqual(fragmentArray[12].ColStart, 34);//Expected 37!!
            Assert.AreEqual(fragmentArray[12].ColEnd, 37);

            Assert.AreEqual(fragmentArray[13].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[13].Text, "}");
            Assert.AreEqual(fragmentArray[13].Line, 0);
            Assert.AreEqual(fragmentArray[13].ColStart, 49);
            Assert.AreEqual(fragmentArray[13].ColEnd, 49);

            Assert.AreEqual(fragmentArray[14].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[14].Text, ";");
            Assert.AreEqual(fragmentArray[14].Line, 0);
            Assert.AreEqual(fragmentArray[14].ColStart, 31);
            Assert.AreEqual(fragmentArray[14].ColEnd, 31);

            Assert.AreEqual(fragmentArray[15].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[15].Text, "=");
            Assert.AreEqual(fragmentArray[15].Line, 0);
            Assert.AreEqual(fragmentArray[15].ColStart, 28);
            Assert.AreEqual(fragmentArray[15].ColEnd, 28);

            Assert.AreEqual(fragmentArray[16].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[16].Text, "a");
            Assert.AreEqual(fragmentArray[16].Line, 0);
            Assert.AreEqual(fragmentArray[16].ColStart, 26);
            Assert.AreEqual(fragmentArray[16].ColEnd, 26);

            Assert.AreEqual(fragmentArray[17].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[17].Text, "0");
            Assert.AreEqual(fragmentArray[17].Line, 0);
            Assert.AreEqual(fragmentArray[17].ColStart, 30);
            Assert.AreEqual(fragmentArray[17].ColEnd, 30);

            Assert.AreEqual(fragmentArray[18].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[18].Text, ";");
            Assert.AreEqual(fragmentArray[18].Line, 0);
            Assert.AreEqual(fragmentArray[18].ColStart, 48);
            Assert.AreEqual(fragmentArray[18].ColEnd, 48);

            Assert.AreEqual(fragmentArray[19].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[19].Text, "=");
            Assert.AreEqual(fragmentArray[19].Line, 0);
            Assert.AreEqual(fragmentArray[19].ColStart, 41);
            Assert.AreEqual(fragmentArray[19].ColEnd, 41);

            Assert.AreEqual(fragmentArray[20].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[20].Text, "a");
            Assert.AreEqual(fragmentArray[20].Line, 0);
            Assert.AreEqual(fragmentArray[20].ColStart, 39);
            Assert.AreEqual(fragmentArray[20].ColEnd, 39);

            Assert.AreEqual(fragmentArray[21].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[21].Text, "+");
            Assert.AreEqual(fragmentArray[21].Line, 0);
            Assert.AreEqual(fragmentArray[21].ColStart, 45);
            Assert.AreEqual(fragmentArray[21].ColEnd, 45);

            Assert.AreEqual(fragmentArray[22].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[22].Text, "a");
            Assert.AreEqual(fragmentArray[22].Line, 0);
            Assert.AreEqual(fragmentArray[22].ColStart, 43);
            Assert.AreEqual(fragmentArray[22].ColEnd, 43);

            Assert.AreEqual(fragmentArray[23].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[23].Text, "b");
            Assert.AreEqual(fragmentArray[23].Line, 0);
            Assert.AreEqual(fragmentArray[23].ColStart, 47);
            Assert.AreEqual(fragmentArray[23].ColEnd, 47);
        }

        [Test]
        public void TestImperativeWhileStmtNode()
        {
            string content = "[Imperative] while( y < ySize ){y = y + 1;}";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length, 17);

            Assert.AreEqual(fragmentArray[3].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[3].Text, "<");
            Assert.AreEqual(fragmentArray[3].Line, 0);
            Assert.AreEqual(fragmentArray[3].ColStart, 22);
            Assert.AreEqual(fragmentArray[3].ColEnd, 22);

            Assert.AreEqual(fragmentArray[4].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[4].Text, "y");
            Assert.AreEqual(fragmentArray[4].Line, 0);
            Assert.AreEqual(fragmentArray[4].ColStart, 20);
            Assert.AreEqual(fragmentArray[4].ColEnd, 20);

            Assert.AreEqual(fragmentArray[5].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[5].Text, "ySize");
            Assert.AreEqual(fragmentArray[5].Line, 0);
            Assert.AreEqual(fragmentArray[5].ColStart, 24);//Again expected 28!!
            Assert.AreEqual(fragmentArray[5].ColEnd, 28);

            Assert.AreEqual(fragmentArray[6].CodeType, CodeFragment.Type.Keyword);
            Assert.AreEqual(fragmentArray[6].Text, "while");
            Assert.AreEqual(fragmentArray[6].Line, 0);
            Assert.AreEqual(fragmentArray[6].ColStart, 13);//Expected 17
            Assert.AreEqual(fragmentArray[6].ColEnd, 17);

            Assert.AreEqual(fragmentArray[7].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[7].Text, "{");
            Assert.AreEqual(fragmentArray[7].Line, 0);
            Assert.AreEqual(fragmentArray[7].ColStart, 31);
            Assert.AreEqual(fragmentArray[7].ColEnd, 31);

            Assert.AreEqual(fragmentArray[8].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[8].Text, "(");
            Assert.AreEqual(fragmentArray[8].Line, 0);
            Assert.AreEqual(fragmentArray[8].ColStart, 18);
            Assert.AreEqual(fragmentArray[8].ColEnd, 18);

            Assert.AreEqual(fragmentArray[9].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[9].Text, ")");
            Assert.AreEqual(fragmentArray[9].Line, 0);
            Assert.AreEqual(fragmentArray[9].ColStart, 30);
            Assert.AreEqual(fragmentArray[9].ColEnd, 30);

            Assert.AreEqual(fragmentArray[10].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[10].Text, "}");
            Assert.AreEqual(fragmentArray[10].Line, 0);
            Assert.AreEqual(fragmentArray[10].ColStart, 42);
            Assert.AreEqual(fragmentArray[10].ColEnd, 42);

            Assert.AreEqual(fragmentArray[11].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[11].Text, ";");
            Assert.AreEqual(fragmentArray[11].Line, 0);
            Assert.AreEqual(fragmentArray[11].ColStart, 41);
            Assert.AreEqual(fragmentArray[11].ColEnd, 41);

            Assert.AreEqual(fragmentArray[12].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[12].Text, "=");
            Assert.AreEqual(fragmentArray[12].Line, 0);
            Assert.AreEqual(fragmentArray[12].ColStart, 34);
            Assert.AreEqual(fragmentArray[12].ColEnd, 34);

            Assert.AreEqual(fragmentArray[13].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[13].Text, "y");
            Assert.AreEqual(fragmentArray[13].Line, 0);
            Assert.AreEqual(fragmentArray[13].ColStart, 32);
            Assert.AreEqual(fragmentArray[13].ColEnd, 32);

            Assert.AreEqual(fragmentArray[14].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[14].Text, "+");
            Assert.AreEqual(fragmentArray[14].Line, 0);
            Assert.AreEqual(fragmentArray[14].ColStart, 38);
            Assert.AreEqual(fragmentArray[14].ColEnd, 38);

            Assert.AreEqual(fragmentArray[15].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[15].Text, "y");
            Assert.AreEqual(fragmentArray[15].Line, 0);
            Assert.AreEqual(fragmentArray[15].ColStart, 36);
            Assert.AreEqual(fragmentArray[15].ColEnd, 36);

            Assert.AreEqual(fragmentArray[16].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[16].Text, "1");
            Assert.AreEqual(fragmentArray[16].Line, 0);
            Assert.AreEqual(fragmentArray[16].ColStart, 40);
            Assert.AreEqual(fragmentArray[16].ColEnd, 40);
        }

        [Test]
        public void TestImperativeUnaryExpressionNode()
        {
            string content = "[Imperative]{ a = true; b = !a; }";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length, 14);

            Assert.AreEqual(fragmentArray[10].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[10].Text, "=");
            Assert.AreEqual(fragmentArray[10].Line, 0);
            Assert.AreEqual(fragmentArray[10].ColStart, 26);
            Assert.AreEqual(fragmentArray[10].ColEnd, 26);

            Assert.AreEqual(fragmentArray[11].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[11].Text, "b");
            Assert.AreEqual(fragmentArray[11].Line, 0);
            Assert.AreEqual(fragmentArray[11].ColStart, 24);
            Assert.AreEqual(fragmentArray[11].ColEnd, 24);

            Assert.AreEqual(fragmentArray[12].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[12].Text, "!");
            Assert.AreEqual(fragmentArray[12].Line, 0);
            Assert.AreEqual(fragmentArray[12].ColStart, 28);
            Assert.AreEqual(fragmentArray[12].ColEnd, 28);

            Assert.AreEqual(fragmentArray[13].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[13].Text, "a");
            Assert.AreEqual(fragmentArray[13].Line, 0);
            Assert.AreEqual(fragmentArray[13].ColStart, 29);
            Assert.AreEqual(fragmentArray[13].ColEnd, 29);
        }

        [Test]
        public void TestImperativeForLoopNode()
        {
            string content = "[Imperative] for (val in a){x = x + val;}";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length, 17);

            Assert.AreEqual(fragmentArray[3].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[3].Text, "val");
            Assert.AreEqual(fragmentArray[3].Line, 0);
            Assert.AreEqual(fragmentArray[3].ColStart, 18);
            Assert.AreEqual(fragmentArray[3].ColEnd, 20);

            Assert.AreEqual(fragmentArray[4].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[4].Text, "a");
            Assert.AreEqual(fragmentArray[4].Line, 0);
            Assert.AreEqual(fragmentArray[4].ColStart, 25);
            Assert.AreEqual(fragmentArray[4].ColEnd, 25);

            Assert.AreEqual(fragmentArray[5].CodeType, CodeFragment.Type.Keyword);
            Assert.AreEqual(fragmentArray[5].Text, "for");
            Assert.AreEqual(fragmentArray[5].Line, 0);
            Assert.AreEqual(fragmentArray[5].ColStart, 13);
            Assert.AreEqual(fragmentArray[5].ColEnd, 15);

            Assert.AreEqual(fragmentArray[6].CodeType, CodeFragment.Type.Keyword);
            Assert.AreEqual(fragmentArray[6].Text, "in");
            Assert.AreEqual(fragmentArray[6].Line, 0);
            Assert.AreEqual(fragmentArray[6].ColStart, 22);
            Assert.AreEqual(fragmentArray[6].ColEnd, 23);

            Assert.AreEqual(fragmentArray[7].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[7].Text, "{");
            Assert.AreEqual(fragmentArray[7].Line, 0);
            Assert.AreEqual(fragmentArray[7].ColStart, 27);
            Assert.AreEqual(fragmentArray[7].ColEnd, 27);

            Assert.AreEqual(fragmentArray[8].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[8].Text, "(");
            Assert.AreEqual(fragmentArray[8].Line, 0);
            Assert.AreEqual(fragmentArray[8].ColStart, 17);
            Assert.AreEqual(fragmentArray[8].ColEnd, 17);

            Assert.AreEqual(fragmentArray[9].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[9].Text, ")");
            Assert.AreEqual(fragmentArray[9].Line, 0);
            Assert.AreEqual(fragmentArray[9].ColStart, 26);
            Assert.AreEqual(fragmentArray[9].ColEnd, 26);

            Assert.AreEqual(fragmentArray[10].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[10].Text, "}");
            Assert.AreEqual(fragmentArray[10].Line, 0);
            Assert.AreEqual(fragmentArray[10].ColStart, 40);
            Assert.AreEqual(fragmentArray[10].ColEnd, 40);

            Assert.AreEqual(fragmentArray[11].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[11].Text, ";");
            Assert.AreEqual(fragmentArray[11].Line, 0);
            Assert.AreEqual(fragmentArray[11].ColStart, 39);
            Assert.AreEqual(fragmentArray[11].ColEnd, 39);

            Assert.AreEqual(fragmentArray[12].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[12].Text, "=");
            Assert.AreEqual(fragmentArray[12].Line, 0);
            Assert.AreEqual(fragmentArray[12].ColStart, 30);
            Assert.AreEqual(fragmentArray[12].ColEnd, 30);

            Assert.AreEqual(fragmentArray[13].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[13].Text, "x");
            Assert.AreEqual(fragmentArray[13].Line, 0);
            Assert.AreEqual(fragmentArray[13].ColStart, 28);
            Assert.AreEqual(fragmentArray[13].ColEnd, 28);

            Assert.AreEqual(fragmentArray[14].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[14].Text, "+");
            Assert.AreEqual(fragmentArray[14].Line, 0);
            Assert.AreEqual(fragmentArray[14].ColStart, 34);
            Assert.AreEqual(fragmentArray[14].ColEnd, 34);

            Assert.AreEqual(fragmentArray[15].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[15].Text, "x");
            Assert.AreEqual(fragmentArray[15].Line, 0);
            Assert.AreEqual(fragmentArray[15].ColStart, 32);
            Assert.AreEqual(fragmentArray[15].ColEnd, 32);

            Assert.AreEqual(fragmentArray[16].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[16].Text, "val");
            Assert.AreEqual(fragmentArray[16].Line, 0);
            Assert.AreEqual(fragmentArray[16].ColStart, 36);//Expected 38
            Assert.AreEqual(fragmentArray[16].ColEnd, 38);
        }

        [Test]
        public void TestImperativeVariableDeclaration()
        {
            string content = "[Imperative]{ a : pointer = 2 ; }";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length, 11);

            Assert.AreEqual(fragmentArray[9].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[9].Text, "=");
            Assert.AreEqual(fragmentArray[9].Line, 0);
            Assert.AreEqual(fragmentArray[9].ColStart, 26);
            Assert.AreEqual(fragmentArray[9].ColEnd, 26);

            Assert.AreEqual(fragmentArray[8].CodeType, CodeFragment.Type.UserType);
            Assert.AreEqual(fragmentArray[8].Text, "pointer");
            Assert.AreEqual(fragmentArray[8].Line, 0);
            Assert.AreEqual(fragmentArray[8].ColStart, 18);
            Assert.AreEqual(fragmentArray[8].ColEnd, 24);

            Assert.AreEqual(fragmentArray[7].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[7].Text, ":");
            Assert.AreEqual(fragmentArray[7].Line, 0);
            Assert.AreEqual(fragmentArray[7].ColStart, 16);
            Assert.AreEqual(fragmentArray[7].ColEnd, 16);

            Assert.AreEqual(fragmentArray[6].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[6].Text, "a");
            Assert.AreEqual(fragmentArray[6].Line, 0);
            Assert.AreEqual(fragmentArray[6].ColStart, 14);
            Assert.AreEqual(fragmentArray[6].ColEnd, 14);

            Assert.AreEqual(fragmentArray[5].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[5].Text, "2");
            Assert.AreEqual(fragmentArray[5].Line, 0);
            Assert.AreEqual(fragmentArray[5].ColStart, 28);
            Assert.AreEqual(fragmentArray[5].ColEnd, 28);
        }

        [Test]
        public void TestImperativeNegativeUnaryExpr()
        {
            //[Imperative]{
            //      a = 10;
            //      b = -a;
            //}
            string content = "[Imperative]{ a = 10; b = -a; }";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length, 14);

            Assert.AreEqual(fragmentArray[10].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[10].Text, "=");
            Assert.AreEqual(fragmentArray[10].Line, 0);
            Assert.AreEqual(fragmentArray[10].ColStart, 24);
            Assert.AreEqual(fragmentArray[10].ColEnd, 24);

            Assert.AreEqual(fragmentArray[11].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[11].Text, "b");
            Assert.AreEqual(fragmentArray[11].Line, 0);
            Assert.AreEqual(fragmentArray[11].ColStart, 22);
            Assert.AreEqual(fragmentArray[11].ColEnd, 22);

            Assert.AreEqual(fragmentArray[12].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[12].Text, "-");
            Assert.AreEqual(fragmentArray[12].Line, 0);
            Assert.AreEqual(fragmentArray[12].ColStart, 26);
            Assert.AreEqual(fragmentArray[12].ColEnd, 26);

            Assert.AreEqual(fragmentArray[13].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[13].Text, "a");
            Assert.AreEqual(fragmentArray[13].Line, 0);
            Assert.AreEqual(fragmentArray[13].ColStart, 27);
            Assert.AreEqual(fragmentArray[13].ColEnd, 27);
        }

        [Test]
        public void TestImperativeInlineConditionExpr()
        {
            //[Imperative]
            //{
            //  a = 3.141593;
            //  b = 100 ;
            //	i = 2 ;
            //	j : double = (i == 2) ? a : b;
            //}
            string content = "[Imperative]{ a = 3.141593 ; b = 100 ; i = 2 ; j : int = (i == 2) ? a : b; }";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length, 31);

            Assert.AreEqual(fragmentArray[29].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[29].Text, "=");
            Assert.AreEqual(fragmentArray[29].Line, 0);
            Assert.AreEqual(fragmentArray[29].ColStart, 55);
            Assert.AreEqual(fragmentArray[29].ColEnd, 55);

            Assert.AreEqual(fragmentArray[28].CodeType, CodeFragment.Type.Keyword);
            Assert.AreEqual(fragmentArray[28].Text, "int");
            Assert.AreEqual(fragmentArray[28].Line, 0);
            Assert.AreEqual(fragmentArray[28].ColStart, 51);
            Assert.AreEqual(fragmentArray[28].ColEnd, 53);

            Assert.AreEqual(fragmentArray[27].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[27].Text, ":");
            Assert.AreEqual(fragmentArray[27].Line, 0);
            Assert.AreEqual(fragmentArray[27].ColStart, 49);
            Assert.AreEqual(fragmentArray[27].ColEnd, 49);

            Assert.AreEqual(fragmentArray[26].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[26].Text, "j");
            Assert.AreEqual(fragmentArray[26].Line, 0);
            Assert.AreEqual(fragmentArray[26].ColStart, 47);
            Assert.AreEqual(fragmentArray[26].ColEnd, 47);

            Assert.AreEqual(fragmentArray[17].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[17].Text, "(");
            Assert.AreEqual(fragmentArray[17].Line, 0);
            Assert.AreEqual(fragmentArray[17].ColStart, 57);
            Assert.AreEqual(fragmentArray[17].ColEnd, 57);

            Assert.AreEqual(fragmentArray[18].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[18].Text, ")");
            Assert.AreEqual(fragmentArray[18].Line, 0);
            Assert.AreEqual(fragmentArray[18].ColStart, 64);
            Assert.AreEqual(fragmentArray[18].ColEnd, 64);

            Assert.AreEqual(fragmentArray[19].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[19].Text, "==");
            Assert.AreEqual(fragmentArray[19].Line, 0);
            Assert.AreEqual(fragmentArray[19].ColStart, 60);
            Assert.AreEqual(fragmentArray[19].ColEnd, 61);

            Assert.AreEqual(fragmentArray[20].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[20].Text, "i");
            Assert.AreEqual(fragmentArray[20].Line, 0);
            Assert.AreEqual(fragmentArray[20].ColStart, 58);
            Assert.AreEqual(fragmentArray[20].ColEnd, 58);

            Assert.AreEqual(fragmentArray[21].CodeType, CodeFragment.Type.Number);
            Assert.AreEqual(fragmentArray[21].Text, "2");
            Assert.AreEqual(fragmentArray[21].Line, 0);
            Assert.AreEqual(fragmentArray[21].ColStart, 63);
            Assert.AreEqual(fragmentArray[21].ColEnd, 63);

            Assert.AreEqual(fragmentArray[22].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[22].Text, "a");
            Assert.AreEqual(fragmentArray[22].Line, 0);
            Assert.AreEqual(fragmentArray[22].ColStart, 68);
            Assert.AreEqual(fragmentArray[22].ColEnd, 68);

            Assert.AreEqual(fragmentArray[23].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[23].Text, "b");
            Assert.AreEqual(fragmentArray[23].Line, 0);
            Assert.AreEqual(fragmentArray[23].ColStart, 72);
            Assert.AreEqual(fragmentArray[23].ColEnd, 72);

            Assert.AreEqual(fragmentArray[24].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[24].Text, "?");
            Assert.AreEqual(fragmentArray[24].Line, 0);
            Assert.AreEqual(fragmentArray[24].ColStart, 66);
            Assert.AreEqual(fragmentArray[24].ColEnd, 66);

            Assert.AreEqual(fragmentArray[25].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[25].Text, ":");
            Assert.AreEqual(fragmentArray[25].Line, 0);
            Assert.AreEqual(fragmentArray[25].ColStart, 70);
            Assert.AreEqual(fragmentArray[25].ColEnd, 70);
        }

        [Test]
        public void TestImperativeArrayExprList()
        {
            //[Imperative]
            //{
            //  Hello = { pt1, pt2 }.Translate();
            //}
            string content = "[Imperative]{ Hello = { pt1, pt2 }.Translate(); }";
            Scanner scanner = new Scanner(ConvertToStream(content));
            parser = new DesignScript.Parser.Parser(scanner, core);
            parser.Parse();
            nodeProcessor = new NodeProcessor(parser.root.Body);
            nodeProcessor.GenerateFragments(out fragmentArray);

            Assert.AreEqual(fragmentArray.Length, 17);

            Assert.AreEqual(fragmentArray[6].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[6].Text, "=");
            Assert.AreEqual(fragmentArray[6].Line, 0);
            Assert.AreEqual(fragmentArray[6].ColStart, 20);
            Assert.AreEqual(fragmentArray[6].ColEnd, 20);

            Assert.AreEqual(fragmentArray[7].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[7].Text, "Hello");
            Assert.AreEqual(fragmentArray[7].Line, 0);
            Assert.AreEqual(fragmentArray[7].ColStart, 14);
            Assert.AreEqual(fragmentArray[7].ColEnd, 18);

            Assert.AreEqual(fragmentArray[8].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[8].Text, ".");
            Assert.AreEqual(fragmentArray[8].Line, 0);
            Assert.AreEqual(fragmentArray[8].ColStart, 34);
            Assert.AreEqual(fragmentArray[8].ColEnd, 34);

            Assert.AreEqual(fragmentArray[9].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[9].Text, "{");
            Assert.AreEqual(fragmentArray[9].Line, 0);
            Assert.AreEqual(fragmentArray[9].ColStart, 22);
            Assert.AreEqual(fragmentArray[9].ColEnd, 22);

            Assert.AreEqual(fragmentArray[10].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[10].Text, "pt1");
            Assert.AreEqual(fragmentArray[10].Line, 0);
            Assert.AreEqual(fragmentArray[10].ColStart, 24);
            Assert.AreEqual(fragmentArray[10].ColEnd, 26);

            Assert.AreEqual(fragmentArray[11].CodeType, CodeFragment.Type.Local);
            Assert.AreEqual(fragmentArray[11].Text, "pt2");
            Assert.AreEqual(fragmentArray[11].Line, 0);
            Assert.AreEqual(fragmentArray[11].ColStart, 29);
            Assert.AreEqual(fragmentArray[11].ColEnd, 31);

            Assert.AreEqual(fragmentArray[12].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[12].Text, ",");
            Assert.AreEqual(fragmentArray[12].Line, 0);
            Assert.AreEqual(fragmentArray[12].ColStart, 27);
            Assert.AreEqual(fragmentArray[12].ColEnd, 27);

            Assert.AreEqual(fragmentArray[13].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[13].Text, "}");
            Assert.AreEqual(fragmentArray[13].Line, 0);
            Assert.AreEqual(fragmentArray[13].ColStart, 33);
            Assert.AreEqual(fragmentArray[13].ColEnd, 33);

            Assert.AreEqual(fragmentArray[14].CodeType, CodeFragment.Type.Function);
            Assert.AreEqual(fragmentArray[14].Text, "Translate");
            Assert.AreEqual(fragmentArray[14].Line, 0);
            Assert.AreEqual(fragmentArray[14].ColStart, 35);
            Assert.AreEqual(fragmentArray[14].ColEnd, 43);

            Assert.AreEqual(fragmentArray[15].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[15].Text, "(");
            Assert.AreEqual(fragmentArray[15].Line, 0);
            Assert.AreEqual(fragmentArray[15].ColStart, 44);
            Assert.AreEqual(fragmentArray[15].ColEnd, 44);

            Assert.AreEqual(fragmentArray[16].CodeType, CodeFragment.Type.Punctuation);
            Assert.AreEqual(fragmentArray[16].Text, ")");
            Assert.AreEqual(fragmentArray[16].Line, 0);
            Assert.AreEqual(fragmentArray[16].ColStart, 45);
            Assert.AreEqual(fragmentArray[16].ColEnd, 45);
        }
    }
}


text:
package com.malouane.popularmovies.vm;

import android.arch.lifecycle.ViewModel;
import android.arch.lifecycle.ViewModelProvider;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Provider;

public class PopMovisViewModelFactory implements ViewModelProvider.Factory {

  private final Map<Class<? extends ViewModel>, Provider<? extends ViewModel>> creators;

  @Inject public PopMovisViewModelFactory(
      Map<Class<? extends ViewModel>, Provider<? extends ViewModel>> creators) {
    this.creators = creators;
  }

  @Override public <T extends ViewModel> T create(Class<T> modelClass) {
    Provider<? extends ViewModel> creator = creators.get(modelClass);
    if (creator == null) {
      for (Map.Entry<Class<? extends ViewModel>, Provider<? extends ViewModel>> entry : creators.entrySet()) {
        if (modelClass.isAssignableFrom(entry.getKey())) {
          creator = entry.getValue();
          break;
        }
      }
    }
    if (creator == null) {
      throw new IllegalArgumentException("unknown model class " + modelClass);
    }
    try {
      return (T) creator.get();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title>/Library/Ruby/Gems/1.8/gems/mocha-0.5.6/lib/mocha/mock.rb - C0 code coverage information</title>

C0 code coverage information

Generated on Mon Jan 07 11:13:52 -0800 2008 with rcov 0.8.1.2

Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.

Name
      Total lines
      Lines of code
      Total coverage
      Code coverage

/Library/Ruby/Gems/1.8/gems/mocha-0.5.6/lib/mocha/mock.rb

      <tt>202</tt>

      <tt>89</tt>

<tt class='coverage_total'>76.2%</tt>

<tt class='coverage_code'>46.1%</tt>

  1 require 'mocha/expectation'
  2 require 'mocha/expectation_list'
  3 require 'mocha/stub'
  4 require 'mocha/missing_expectation'
  5 require 'mocha/metaclass'
  6
  7 module Mocha # :nodoc:
  8
  9   # Traditional mock object.
 10   #
 11   # Methods return an Expectation which can be further modified by methods on Expectation.
 12   class Mock
 13
 14     # :call-seq: expects(method_name) -> expectation
 15     #            expects(method_names) -> last expectation
 16     #
 17     # Adds an expectation that a method identified by +method_name+ symbol must be called exactly once with any parameters.
 18     # Returns the new expectation which can be further modified by methods on Expectation.
 19     #   object = mock()
 20     #   object.expects(:method1)
 21     #   object.method1
 22     #   # no error raised
 23     #
 24     #   object = mock()
 25     #   object.expects(:method1)
 26     #   # error raised, because method1 not called exactly once
 27     # If +method_names+ is a +Hash+, an expectation will be set up for each entry using the key as +method_name+ and value as +return_value+.
 28     #   object = mock()
 29     #   object.expects(:method1 => :result1, :method2 => :result2)
 30     #
 31     #   # exactly equivalent to
 32     #
 33     #   object = mock()
 34     #   object.expects(:method1).returns(:result1)
 35     #   object.expects(:method2).returns(:result2)
 36     #
 37     # Aliased by <tt>\_\_expects\_\_</tt>
 38     def expects(method_name_or_hash, backtrace = nil)
 39       if method_name_or_hash.is_a?(Hash) then
 40         method_name_or_hash.each do |method_name, return_value|
 41           ensure_method_not_already_defined(method_name)
 42           @expectations.add(Expectation.new(self, method_name, backtrace).returns(return_value))
 43         end
 44       else
 45         ensure_method_not_already_defined(method_name_or_hash)
 46         @expectations.add(Expectation.new(self, method_name_or_hash, backtrace))
 47       end
 48     end
 49
 50     # :call-seq: stubs(method_name) -> expectation
 51     #            stubs(method_names) -> last expectation
 52     #
 53     # Adds an expectation that a method identified by +method_name+ symbol may be called any number of times with any parameters.
 54     # Returns the new expectation which can be further modified by methods on Expectation.
 55     #   object = mock()
 56     #   object.stubs(:method1)
 57     #   object.method1
 58     #   object.method1
 59     #   # no error raised
 60     # If +method_names+ is a +Hash+, an expectation will be set up for each entry using the key as +method_name+ and value as +return_value+.
 61     #   object = mock()
 62     #   object.stubs(:method1 => :result1, :method2 => :result2)
 63     #
 64     #   # exactly equivalent to
 65     #
 66     #   object = mock()
 67     #   object.stubs(:method1).returns(:result1)
 68     #   object.stubs(:method2).returns(:result2)
 69     #
 70     # Aliased by <tt>\_\_stubs\_\_</tt>
 71     def stubs(method_name_or_hash, backtrace = nil)
 72       if method_name_or_hash.is_a?(Hash) then
 73         method_name_or_hash.each do |method_name, return_value|
 74           ensure_method_not_already_defined(method_name)
 75           @expectations.add(Stub.new(self, method_name, backtrace).returns(return_value))
 76         end
 77       else
 78         ensure_method_not_already_defined(method_name_or_hash)
 79         @expectations.add(Stub.new(self, method_name_or_hash, backtrace))
 80       end
 81     end
 82
 83     # :call-seq: responds_like(responder) -> mock
 84     #
 85     # Constrains the +mock+ so that it can only expect or stub methods to which +responder+ responds. The constraint is only applied at method invocation time.
 86     #
 87     # A +NoMethodError+ will be raised if the +responder+ does not <tt>respond_to?</tt> a method invocation (even if the method has been expected or stubbed).
 88     #
 89     # The +mock+ will delegate its <tt>respond_to?</tt> method to the +responder+.
 90     #   class Sheep
 91     #     def chew(grass); end
 92     #     def self.number_of_legs; end
 93     #   end
 94     #
 95     #   sheep = mock('sheep')
 96     #   sheep.expects(:chew)
 97     #   sheep.expects(:foo)
 98     #   sheep.respond_to?(:chew) # => true
 99     #   sheep.respond_to?(:foo) # => true
100     #   sheep.chew
101     #   sheep.foo
102     #   # no error raised
103     #
104     #   sheep = mock('sheep')
105     #   sheep.responds_like(Sheep.new)
106     #   sheep.expects(:chew)
107     #   sheep.expects(:foo)
108     #   sheep.respond_to?(:chew) # => true
109     #   sheep.respond_to?(:foo) # => false
110     #   sheep.chew
111     #   sheep.foo # => raises NoMethodError exception
112     #
113     #   sheep_class = mock('sheep_class')
114     #   sheep_class.responds_like(Sheep)
115     #   sheep_class.stubs(:number_of_legs).returns(4)
116     #   sheep_class.expects(:foo)
117     #   sheep_class.respond_to?(:number_of_legs) # => true
118     #   sheep_class.respond_to?(:foo) # => false
119     #   assert_equal 4, sheep_class.number_of_legs
120     #   sheep_class.foo # => raises NoMethodError exception
121     #
122     # Aliased by +quacks_like+
123     def responds_like(object)
124       @responder = object
125       self
126     end
127
128     # :stopdoc:
129
130     def initialize(name = nil, &block)
131       @mock_name = name
132       @expectations = ExpectationList.new
133       @everything_stubbed = false
134       @responder = nil
135       instance_eval(&block) if block
136     end
137
138     attr_reader :everything_stubbed, :expectations
139
140     alias_method :__expects__, :expects
141
142     alias_method :__stubs__, :stubs
143
144     alias_method :quacks_like, :responds_like
145
146     def add_expectation(expectation)
147       @expectations.add(expectation)
148     end
149
150     def stub_everything
151       @everything_stubbed = true
152     end
153
154     def method_missing(symbol, *arguments, &block)
155       if @responder and not @responder.respond_to?(symbol)
156         raise NoMethodError, "undefined method `#{symbol}' for #{self.mocha_inspect} which responds like #{@responder.mocha_inspect}"
157       end
158       matching_expectation = @expectations.detect(symbol, *arguments)
159       if matching_expectation then
160         matching_expectation.invoke(&block)
161       elsif @everything_stubbed then
162         return
163       else
164         unexpected_method_called(symbol, *arguments)
165       end
166     end
167
168     def respond_to?(symbol)
169       if @responder then
170         @responder.respond_to?(symbol)
171       else
172         @expectations.matches_method?(symbol)
173       end
174     end
175
176     def unexpected_method_called(symbol, *arguments)
177       MissingExpectation.new(self, symbol).with(*arguments).verify
178     end
179
180     def verify(&block)
181       @expectations.verify(&block)
182     end
183
184     def mocha_inspect
185       address = self.__id__ * 2
186       address += 0x100000000 if address < 0
187       @mock_name ? "#<Mock:#{@mock_name}>" : "#<Mock:0x#{'%x' % address}>"
188     end
189
190     def inspect
191       mocha_inspect
192     end
193
194     def ensure_method_not_already_defined(method_name)
195       self.__metaclass__.send(:undef_method, method_name) if self.__metaclass__.method_defined?(method_name)
196     end
197
198     # :startdoc:
199
200   end
201
202 end

Generated using the rcov code coverage analysis tool for Ruby
   version 0.8.1.2.


text:
require 'spec_helper'

describe RBattlenet::D3::Hero::FollowerItems, type: :community do

  describe "#find_hero_follower_items" do
    it "fetches hero follower items data" do
      with_connection("d3_hero_follower_items") do
        result = RBattlenet::D3::Hero::FollowerItems.find(battletag: "FaYe-2543", id: 104729462)
        expect(result.templar.neck.name).to eq "The Ess of Johan"
      end
    end
  end
end


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Copyright 2015 The AppAuth for Android Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing permissions and
 * limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="net.openid.appauth">

  <uses-permission android:name="android.permission.INTERNET" />

  <application>
    <activity android:name=".AuthorizationManagementActivity"
      android:exported="false"
      android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden"
      android:theme="@style/Theme.AppCompat.Translucent.NoTitleBar"
      android:launchMode="singleTask" />

    <activity android:name=".RedirectUriReceiverActivity" android:exported="true">
      <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:scheme="${appAuthRedirectScheme}"/>
      </intent-filter>
    </activity>
  </application>

  <queries>
    <intent>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="https" />
    </intent>
  </queries>

</manifest>


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

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

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

import java.util.Collection;
import java.util.Objects;

/**
 * A filter for testing that the value of a certain property is included in a
 * collection of values
 *
 * @author bas.rutten
 */
public class In extends AbstractFilter implements PropertyFilter {

    private final Collection<?> values;

    private final String propertyId;

    /**
     * @param propertyId the property that represents the collection
     * @param values     the objects that needs to be checked
     */
    public In(String propertyId, Collection<?> values) {
        this.propertyId = propertyId;
        this.values = values;
    }

    @Override
    public String getPropertyId() {
        return propertyId;
    }

    public Collection<?> getValues() {
        return values;
    }

    @Override
    public boolean evaluate(Object that) {
        if (that == null) {
            return false;
        }
        Object other = getProperty(that, getPropertyId());
        if (other == null) {
            return false;
        }

        return values.contains(other);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(values) + Objects.hashCode(propertyId);
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof In)) {
            return false;
        }
        In c = (In) obj;

        return Objects.equals(propertyId, c.getPropertyId()) && Objects.equals(values, c.getValues());
    }

    @Override
    public String toString() {
        return getPropertyId() + " " + super.toString() + " " + getValues();
    }
}


text:
The Flyweight pattern coserves memory by sharing large numbers of fine-grained objects efficiently.
Shared flyweight objects are immutable,that is,they cannot be changed as they represent the characteristics
that are shared with other objects.

Essentially Flyweight is an 'object normalization technique' in which common properties are factored out inot shared flyweight objects.(Note:the idea is similar to data model normalization,
a process in which the modeler attempts to minimize redundancy).

An example of the Flyweight Pattern is within the Javascript engine itself which maintains a list of immutable string that are shared across the applications.

Other examples include character and line-styles in a word processor,or 'digit receivers' in a public switched tempphone network apllication.Your will find flyweights mostly in utility in utility type application such as word processors,graphics programs,
and network apps;they are less often used in data-driven business type applications,


text:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
        class="com.company.mts.gui.project.MyProjectBrowse"
        extends="/com/haulmont/timesheets/gui/project/project-browse.xml"
        messagesPack="com.company.mts.gui.project">
    <layout>
        <split id="split">
            <vbox id="leftBox">
                <treeTable id="projectsTable">
                    <columns>
                        <column id="invoicing"/>
                    </columns>
                    <buttonsPanel id="buttonsPanel">
                        <button id="createInvoice"
                                caption="Create invoice"
                                invoke="createInvoice"/>
                    </buttonsPanel>
                </treeTable>
            </vbox>
        </split>
    </layout>
</window>


text:
package org.apache.storm.hbase.topology;

import java.util.HashMap;
import java.util.Map;
import org.apache.storm.Config;
import org.apache.storm.StormSubmitter;
import org.apache.storm.hbase.bolt.HBaseBolt;
import org.apache.storm.hbase.bolt.mapper.SimpleHBaseMapper;
import org.apache.storm.hbase.security.HBaseSecurityUtil;
import org.apache.storm.topology.TopologyBuilder;
import org.apache.storm.tuple.Fields;

public class PersistentWordCount {
    private static final String WORD_SPOUT = "WORD_SPOUT";
    private static final String COUNT_BOLT = "COUNT_BOLT";
    private static final String HBASE_BOLT = "HBASE_BOLT";

    public static void main(String[] args) throws Exception {
        Config config = new Config();

        Map<String, Object> hbConf = new HashMap<>();
        if (args.length > 0) {
            hbConf.put("hbase.rootdir", args[0]);
        }
        config.put("hbase.conf", hbConf);

        WordSpout spout = new WordSpout();
        WordCounter bolt = new WordCounter();

        SimpleHBaseMapper mapper = new SimpleHBaseMapper()
            .withRowKeyField("word")
            .withColumnFields(new Fields("word"))
            .withCounterFields(new Fields("count"))
            .withColumnFamily("cf");

        HBaseBolt hbase = new HBaseBolt("WordCount", mapper)
            .withConfigKey("hbase.conf");

        // wordSpout ==> countBolt ==> HBaseBolt
        TopologyBuilder builder = new TopologyBuilder();

        builder.setSpout(WORD_SPOUT, spout, 1);
        builder.setBolt(COUNT_BOLT, bolt, 1).shuffleGrouping(WORD_SPOUT);
        builder.setBolt(HBASE_BOLT, hbase, 1).fieldsGrouping(COUNT_BOLT, new Fields("word"));

        String topoName = "test";
        if (args.length == 2) {
            topoName = args[0];
        } else if (args.length == 4) {
            System.out.println("hdfs url: " + args[0] + ", keytab file: " + args[2] +
                               ", principal name: " + args[3] + ", toplogy name: " + args[1]);
            hbConf.put(HBaseSecurityUtil.STORM_KEYTAB_FILE_KEY, args[2]);
            hbConf.put(HBaseSecurityUtil.STORM_USER_NAME_KEY, args[3]);
            config.setNumWorkers(3);
            topoName = args[1];
        } else if (args.length != 1) {
            System.out.println("Usage: PersistentWordCount <hbase.rootdir> [topology name] [keytab file] [principal name]");
            return;
        }
        StormSubmitter.submitTopology(topoName, config, builder.createTopology());
    }
}