<commit_before>package net.bytebuddy.asm;

import net.bytebuddy.utility.OpenedClassReader;
import org.hamcrest.CoreMatchers;
import org.junit.Test;
import org.objectweb.asm.Attribute;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Opcodes;

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;

public class ClassVisitorFactoryOtherTest {

    private static final String FOO = "foo";

    @Test(expected = IllegalArgumentException.class)
    public void testInvalidInput() {
        ClassVisitorFactory.of(Object.class);
    }

    @Test
    public void testGetter() {
        assertThat(ClassVisitorFactory.of(ClassVisitor.class).getType(), is((Object) ClassVisitor.class));
    }

    @Test
    public void testAttributeWrapped() {
        final Attribute sample = new Attribute(FOO) {
            /* empty */
        };
        ClassVisitorFactory.of(ClassVisitor.class).wrap(new ClassVisitor(OpenedClassReader.ASM_API) {

            @Override
            public void visitAttribute(Attribute attribute) {
                assertThat(attribute, not(sameInstance(sample)));
                try {
                    assertThat(attribute.getClass().getField("delegate").get(attribute), sameInstance((Object) sample));
                } catch (Exception e) {
                    throw new AssertionError(e);
                }
            }
        }).visitAttribute(sample);
    }
}<commit_msg>Extend attribute wrapper test.<commit_after>package net.bytebuddy.asm;

import net.bytebuddy.utility.OpenedClassReader;
import org.hamcrest.CoreMatchers;
import org.junit.Test;
import org.objectweb.asm.Attribute;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Opcodes;

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;

public class ClassVisitorFactoryOtherTest {

    private static final String FOO = "foo";

    @Test(expected = IllegalArgumentException.class)
    public void testInvalidInput() {
        ClassVisitorFactory.of(Object.class);
    }

    @Test
    public void testGetter() {
        assertThat(ClassVisitorFactory.of(ClassVisitor.class).getType(), is((Object) ClassVisitor.class));
    }

    @Test
    public void testAttributeWrapped() {
        final Attribute sample = new Attribute(FOO) {

            @Override
            public boolean isUnknown() {
                return false;
            }

            @Override
            public boolean isCodeAttribute() {
                return true;
            }
        };
        ClassVisitorFactory.of(ClassVisitor.class).wrap(new ClassVisitor(OpenedClassReader.ASM_API) {

            @Override
            public void visitAttribute(Attribute attribute) {
                assertThat(attribute, not(sameInstance(sample)));
                assertThat(attribute.type, is(FOO));
                assertThat(attribute.isUnknown(), is(false));
                assertThat(attribute.isCodeAttribute(), is(true));
                try {
                    assertThat(attribute.getClass().getField("delegate").get(attribute), sameInstance((Object) sample));
                } catch (Exception e) {
                    throw new AssertionError(e);
                }
            }
        }).visitAttribute(sample);
    }
}
{'fraction_non_alphanumeric': 0.10102843315184513, 'fraction_numerical': 0.0, 'mean_word_length': 2.552094522019334, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2408066', 'n_tokens_mistral': 862, 'n_tokens_neox': 846, 'n_words': 164}