Skip to content

Commit

Permalink
rd-gen: add tests for documentation in models
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Dec 12, 2023
1 parent a291248 commit 7b00c64
Show file tree
Hide file tree
Showing 13 changed files with 886 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.jetbrains.rd.generator.test.cases.generator.cpp

import com.jetbrains.rd.generator.test.cases.generator.testModels.DocumentationModelRoot
import com.jetbrains.rd.generator.testframework.CppRdGenOutputTest
import org.junit.jupiter.api.Test

class CppDocumentationModelTest : CppRdGenOutputTest() {

companion object {
const val TEST_NAME = "documentationModelTest"
}

override val testName = TEST_NAME

override val verifyComments = true

override fun expectedFileCount(model: Class<*>) = when (model) {
DocumentationModelRoot::class.java -> 2
else -> 0
}

@Test
fun test1() = doTest<DocumentationModelRoot>(DocumentationModelRoot::class.java)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.jetbrains.rd.generator.test.cases.generator.csharp

import com.jetbrains.rd.generator.test.cases.generator.testModels.DocumentationModelRoot
import com.jetbrains.rd.generator.testframework.CSharpRdGenOutputTest
import org.junit.jupiter.api.Test

class CSharpDocumentationModelTest : CSharpRdGenOutputTest() {

companion object {
const val TEST_NAME = "documentationModelTest"
}

override val testName = TEST_NAME

override val verifyComments = true

@Test
fun test1() = doTest<DocumentationModelRoot>(DocumentationModelRoot::class.java)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.jetbrains.rd.generator.test.cases.generator.kotlin

import com.jetbrains.rd.generator.test.cases.generator.testModels.DocumentationModelRoot
import com.jetbrains.rd.generator.testframework.KotlinRdGenOutputTest
import org.junit.jupiter.api.Test

class KotlinDocumentationModelTest : KotlinRdGenOutputTest() {

companion object {
const val TEST_NAME = "documentationModelTest"
}

override val testName = TEST_NAME

override val verifyComments = true

@Test
fun test1() = doTest<DocumentationModelRoot>(DocumentationModelRoot::class.java)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.jetbrains.rd.generator.test.cases.generator.testModels

import com.jetbrains.rd.generator.nova.*
import com.jetbrains.rd.generator.test.cases.generator.cpp.CppDocumentationModelTest
import com.jetbrains.rd.generator.test.cases.generator.csharp.CSharpDocumentationModelTest
import com.jetbrains.rd.generator.test.cases.generator.kotlin.KotlinDocumentationModelTest
import com.jetbrains.rd.generator.testframework.CSharpRdGenOutputTest
import com.jetbrains.rd.generator.testframework.CppRdGenOutputTest
import com.jetbrains.rd.generator.testframework.KotlinRdGenOutputTest

object DocumentationModelRoot : Root(
*KotlinRdGenOutputTest.generators(KotlinDocumentationModelTest.TEST_NAME, "org.example"),
*CppRdGenOutputTest.generators(CppDocumentationModelTest.TEST_NAME, "org.example"),
*CSharpRdGenOutputTest.generators(CSharpDocumentationModelTest.TEST_NAME, "org.example")
) {
init {
documentation = "This is a documentation test,\nand it is also multiline."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ abstract class RdGenOutputTestBase {
protected abstract val fileExtensionNoDot: String
protected abstract val generatedSourcesDir: String

protected open val verifyComments = false

protected open fun expectedFileCount(model: Class<*>): Int = 1

protected inline fun <reified TModel> doTest(
Expand Down Expand Up @@ -97,9 +99,11 @@ abstract class RdGenOutputTestBase {
testFolder.deleteRecursively()
}

private fun processLines(lines: List<String>) = lines
.map { it.trimEnd() }
.filter { !it.trim().startsWith("//") }
private fun processLines(lines: List<String>): Sequence<String> {
val result = lines.asSequence().map { it.trimEnd() }
return if (verifyComments) result
else result.filter { !it.trim().startsWith("//") }
}
protected fun processText(lines: List<String>) = processLines(lines).joinToString("\n")

protected fun getGoldFile(resourceRelativePath: String): File {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a RdGen v1.13.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Linq;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using JetBrains.Annotations;

using JetBrains.Core;
using JetBrains.Diagnostics;
using JetBrains.Collections;
using JetBrains.Collections.Viewable;
using JetBrains.Lifetimes;
using JetBrains.Serialization;
using JetBrains.Rd;
using JetBrains.Rd.Base;
using JetBrains.Rd.Impl;
using JetBrains.Rd.Tasks;
using JetBrains.Rd.Util;
using JetBrains.Rd.Text;


// ReSharper disable RedundantEmptyObjectCreationArgumentList
// ReSharper disable InconsistentNaming
// ReSharper disable RedundantOverflowCheckingContext


namespace org.example
{


/// <summary>
/// This is a documentation test,
and it is also multiline.
/// <p>Generated from: ModelWithDocumentation.kt:14</p>
/// </summary>
public class DocumentationModelRoot : RdExtBase
{
//fields
//public fields

//private fields
//primary constructor
private DocumentationModelRoot(
)
{
}
//secondary constructor
//deconstruct trait
//statics



protected override long SerializationHash => -7782552752810534509L;

protected override Action<ISerializers> Register => RegisterDeclaredTypesSerializers;
public static void RegisterDeclaredTypesSerializers(ISerializers serializers)
{

serializers.RegisterToplevelOnce(typeof(DocumentationModelRoot), DocumentationModelRoot.RegisterDeclaredTypesSerializers);
}

public DocumentationModelRoot(Lifetime lifetime, IProtocol protocol) : this()
{
Identify(protocol.Identities, RdId.Root.Mix("DocumentationModelRoot"));
this.BindTopLevel(lifetime, protocol, "DocumentationModelRoot");
}

//constants

//custom body
//methods
//equals trait
//hash code trait
//pretty print
public override void Print(PrettyPrinter printer)
{
printer.Println("DocumentationModelRoot (");
printer.Print(")");
}
//toString
public override string ToString()
{
var printer = new SingleLinePrettyPrinter();
Print(printer);
return printer.ToString();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@file:Suppress("EXPERIMENTAL_API_USAGE","EXPERIMENTAL_UNSIGNED_LITERALS","PackageDirectoryMismatch","UnusedImport","unused","LocalVariableName","CanBeVal","PropertyName","EnumEntryName","ClassName","ObjectPropertyName","UnnecessaryVariable","SpellCheckingInspection")
package org.example

import com.jetbrains.rd.framework.*
import com.jetbrains.rd.framework.base.*
import com.jetbrains.rd.framework.impl.*

import com.jetbrains.rd.util.lifetime.*
import com.jetbrains.rd.util.reactive.*
import com.jetbrains.rd.util.string.*
import com.jetbrains.rd.util.*
import kotlin.time.Duration
import kotlin.reflect.KClass
import kotlin.jvm.JvmStatic



/**
* This is a documentation test,
and it is also multiline.
* #### Generated from [ModelWithDocumentation.kt:14]
*/
class DocumentationModelRoot private constructor(
) : RdExtBase() {
//companion

companion object : ISerializersOwner {

override fun registerSerializersCore(serializers: ISerializers) {
DocumentationModelRoot.register(serializers)
}





const val serializationHash = -7782552752810534509L

}
override val serializersOwner: ISerializersOwner get() = DocumentationModelRoot
override val serializationHash: Long get() = DocumentationModelRoot.serializationHash

//fields
//methods
//initializer
//secondary constructor
//equals trait
//hash code trait
//pretty print
override fun print(printer: PrettyPrinter) {
printer.println("DocumentationModelRoot (")
printer.print(")")
}
//deepClone
override fun deepClone(): DocumentationModelRoot {
return DocumentationModelRoot(
)
}
//contexts
//threading
override val extThreading: ExtThreadingKind get() = ExtThreadingKind.Default
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a RdGen v1.13.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#include "DocumentationModelRoot.Generated.h"


#include "DocumentationModelRoot/DocumentationModelRoot.Generated.h"
#include "DocumentationModelRoot/DocumentationModelRoot.Generated.h"

#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable:4250 )
#pragma warning( disable:4307 )
#pragma warning( disable:4267 )
#pragma warning( disable:4244 )
#pragma warning( disable:4100 )
#endif

namespace org.example {
// companion

DocumentationModelRoot::DocumentationModelRootSerializersOwner const DocumentationModelRoot::serializersOwner;

void DocumentationModelRoot::DocumentationModelRootSerializersOwner::registerSerializersCore(rd::Serializers const& serializers) const
{
}

void DocumentationModelRoot::connect(rd::Lifetime lifetime, rd::IProtocol const * protocol)
{
DocumentationModelRoot::serializersOwner.registry(protocol->get_serializers());

identify(*(protocol->get_identity()), rd::RdId::Null().mix("DocumentationModelRoot"));
bind(lifetime, protocol, "DocumentationModelRoot");
}

// constants
// initializer
void DocumentationModelRoot::initialize()
{
serializationHash = -7782552752810534509L;
}
// primary ctor
// secondary constructor
// default ctors and dtors
DocumentationModelRoot::DocumentationModelRoot()
{
initialize();
}
// reader
// writer
// virtual init
void DocumentationModelRoot::init(rd::Lifetime lifetime) const
{
rd::RdExtBase::init(lifetime);
}
// identify
void DocumentationModelRoot::identify(const rd::Identities &identities, rd::RdId const &id) const
{
rd::RdBindableBase::identify(identities, id);
}
// getters
// intern
// equals trait
// equality operators
bool operator==(const DocumentationModelRoot &lhs, const DocumentationModelRoot &rhs) {
return &lhs == &rhs;
}
bool operator!=(const DocumentationModelRoot &lhs, const DocumentationModelRoot &rhs){
return !(lhs == rhs);
}
// hash code trait
// type name trait
// static type name trait
// polymorphic to string
std::string DocumentationModelRoot::toString() const
{
std::string res = "DocumentationModelRoot\n";
return res;
}
// external to string
std::string to_string(const DocumentationModelRoot & value)
{
return value.toString();
}
}

#ifdef _MSC_VER
#pragma warning( pop )
#endif

Loading

0 comments on commit 7b00c64

Please sign in to comment.